aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS2
-rw-r--r--Documentation/ABI/testing/sysfs-bus-pci10
-rw-r--r--Documentation/PCI/pci-error-recovery.txt119
-rw-r--r--Documentation/arm/SA1100/ADSBitsy2
-rw-r--r--Documentation/arm/SA1100/Assabet2
-rw-r--r--Documentation/arm/SA1100/Brutus2
-rw-r--r--Documentation/arm/SA1100/GraphicsClient4
-rw-r--r--Documentation/arm/SA1100/GraphicsMaster4
-rw-r--r--Documentation/arm/SA1100/Victor2
-rw-r--r--Documentation/intel_txt.txt210
-rw-r--r--Documentation/kernel-parameters.txt11
-rw-r--r--Documentation/vgaarbiter.txt194
-rw-r--r--Documentation/video4linux/CARDLIST.cx238852
-rw-r--r--Documentation/video4linux/CARDLIST.cx881
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx5
-rw-r--r--Documentation/video4linux/CARDLIST.saa71344
-rw-r--r--Documentation/video4linux/CARDLIST.tuner1
-rw-r--r--Documentation/video4linux/CQcam.txt4
-rw-r--r--Documentation/video4linux/gspca.txt6
-rw-r--r--Documentation/video4linux/si4713.txt176
-rw-r--r--Documentation/x86/zero-page.txt1
-rw-r--r--MAINTAINERS4
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/include/asm/agp.h4
-rw-r--r--arch/alpha/include/asm/pci.h1
-rw-r--r--arch/alpha/include/asm/percpu.h100
-rw-r--r--arch/alpha/include/asm/tlbflush.h1
-rw-r--r--arch/alpha/kernel/vmlinux.lds.S9
-rw-r--r--arch/arm/boot/compressed/head-sa1100.S2
-rw-r--r--arch/arm/include/asm/pci.h2
-rw-r--r--arch/arm/kernel/vmlinux.lds.S1
-rw-r--r--arch/arm/lib/lib1funcs.S2
-rw-r--r--arch/arm/lib/sha1.S2
-rw-r--r--arch/arm/mach-sa1100/include/mach/assabet.h2
-rw-r--r--arch/arm/mach-sa1100/include/mach/hardware.h2
-rw-r--r--arch/arm/mach-sa1100/include/mach/memory.h2
-rw-r--r--arch/arm/mach-sa1100/include/mach/neponset.h2
-rw-r--r--arch/arm/mach-sa1100/include/mach/system.h2
-rw-r--r--arch/arm/mach-sa1100/include/mach/uncompress.h2
-rw-r--r--arch/arm/mach-sa1100/pm.c2
-rw-r--r--arch/arm/mach-sa1100/time.c2
-rw-r--r--arch/arm/mm/proc-xscale.S2
-rw-r--r--arch/arm/plat-iop/setup.c2
-rw-r--r--arch/arm/plat-omap/include/mach/system.h2
-rw-r--r--arch/avr32/kernel/vmlinux.lds.S9
-rw-r--r--arch/blackfin/kernel/vmlinux.lds.S5
-rw-r--r--arch/blackfin/mm/sram-alloc.c6
-rw-r--r--arch/cris/include/asm/mmu_context.h3
-rw-r--r--arch/cris/kernel/vmlinux.lds.S9
-rw-r--r--arch/cris/mm/fault.c2
-rw-r--r--arch/frv/kernel/vmlinux.lds.S2
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.c10
-rw-r--r--arch/h8300/include/asm/pci.h1
-rw-r--r--arch/h8300/kernel/vmlinux.lds.S5
-rw-r--r--arch/ia64/Kconfig7
-rw-r--r--arch/ia64/include/asm/agp.h4
-rw-r--r--arch/ia64/include/asm/pci.h14
-rw-r--r--arch/ia64/kernel/setup.c6
-rw-r--r--arch/ia64/kernel/smp.c3
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S16
-rw-r--r--arch/ia64/sn/kernel/setup.c2
-rw-r--r--arch/m32r/kernel/vmlinux.lds.S10
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds10
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds9
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S7
-rw-r--r--arch/microblaze/kernel/vmlinux.lds.S6
-rw-r--r--arch/mips/include/asm/pci.h2
-rw-r--r--arch/mips/kernel/vmlinux.lds.S21
-rw-r--r--arch/mn10300/include/asm/pci.h13
-rw-r--r--arch/mn10300/kernel/vmlinux.lds.S8
-rw-r--r--arch/parisc/include/asm/agp.h4
-rw-r--r--arch/parisc/include/asm/pci.h1
-rw-r--r--arch/parisc/kernel/vmlinux.lds.S8
-rw-r--r--arch/powerpc/Kconfig32
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/powerpc/boot/4xx.c142
-rw-r--r--arch/powerpc/boot/4xx.h1
-rw-r--r--arch/powerpc/boot/Makefile6
-rw-r--r--arch/powerpc/boot/cuboot-hotfoot.c142
-rw-r--r--arch/powerpc/boot/cuboot-kilauea.c49
-rw-r--r--arch/powerpc/boot/dcr.h4
-rw-r--r--arch/powerpc/boot/dts/arches.dts50
-rw-r--r--arch/powerpc/boot/dts/canyonlands.dts49
-rw-r--r--arch/powerpc/boot/dts/eiger.dts421
-rw-r--r--arch/powerpc/boot/dts/gef_sbc310.dts64
-rw-r--r--arch/powerpc/boot/dts/hotfoot.dts294
-rw-r--r--arch/powerpc/boot/dts/kilauea.dts44
-rw-r--r--arch/powerpc/boot/dts/mgcoge.dts53
-rw-r--r--arch/powerpc/boot/dts/mpc8272ads.dts8
-rw-r--r--arch/powerpc/boot/dts/mpc8377_rdb.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8377_wlan.dts464
-rw-r--r--arch/powerpc/boot/dts/mpc8378_rdb.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8379_rdb.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8536ds.dts40
-rw-r--r--arch/powerpc/boot/dts/mpc8536ds_36b.dts475
-rw-r--r--arch/powerpc/boot/dts/mpc8548cds.dts20
-rw-r--r--arch/powerpc/boot/dts/mpc8569mds.dts45
-rw-r--r--arch/powerpc/boot/dts/p2020rdb.dts586
-rw-r--r--arch/powerpc/boot/dts/sbc8349.dts60
-rw-r--r--arch/powerpc/boot/dts/sbc8560.dts1
-rw-r--r--arch/powerpc/boot/mktree.c10
-rw-r--r--arch/powerpc/boot/ppcboot-hotfoot.h133
-rwxr-xr-xarch/powerpc/boot/wrapper3
-rw-r--r--arch/powerpc/configs/40x/kilauea_defconfig298
-rw-r--r--arch/powerpc/configs/44x/arches_defconfig382
-rw-r--r--arch/powerpc/configs/44x/canyonlands_defconfig350
-rw-r--r--arch/powerpc/configs/44x/eiger_defconfig1252
-rw-r--r--arch/powerpc/configs/83xx/sbc834x_defconfig320
-rw-r--r--arch/powerpc/configs/mgcoge_defconfig86
-rw-r--r--arch/powerpc/configs/mpc85xx_defconfig1
-rw-r--r--arch/powerpc/include/asm/agp.h4
-rw-r--r--arch/powerpc/include/asm/bitops.h196
-rw-r--r--arch/powerpc/include/asm/cell-regs.h11
-rw-r--r--arch/powerpc/include/asm/cputhreads.h16
-rw-r--r--arch/powerpc/include/asm/device.h7
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h318
-rw-r--r--arch/powerpc/include/asm/exception-64e.h205
-rw-r--r--arch/powerpc/include/asm/exception-64s.h (renamed from arch/powerpc/include/asm/exception.h)25
-rw-r--r--arch/powerpc/include/asm/hardirq.h30
-rw-r--r--arch/powerpc/include/asm/hw_irq.h5
-rw-r--r--arch/powerpc/include/asm/iommu.h10
-rw-r--r--arch/powerpc/include/asm/irq.h7
-rw-r--r--arch/powerpc/include/asm/machdep.h6
-rw-r--r--arch/powerpc/include/asm/mmu-40x.h3
-rw-r--r--arch/powerpc/include/asm/mmu-44x.h6
-rw-r--r--arch/powerpc/include/asm/mmu-8xx.h3
-rw-r--r--arch/powerpc/include/asm/mmu-book3e.h208
-rw-r--r--arch/powerpc/include/asm/mmu-hash32.h16
-rw-r--r--arch/powerpc/include/asm/mmu-hash64.h22
-rw-r--r--arch/powerpc/include/asm/mmu.h46
-rw-r--r--arch/powerpc/include/asm/mmu_context.h15
-rw-r--r--arch/powerpc/include/asm/nvram.h3
-rw-r--r--arch/powerpc/include/asm/paca.h23
-rw-r--r--arch/powerpc/include/asm/page.h4
-rw-r--r--arch/powerpc/include/asm/page_64.h10
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h40
-rw-r--r--arch/powerpc/include/asm/pci.h12
-rw-r--r--arch/powerpc/include/asm/pgalloc.h46
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc32.h9
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64-64k.h4
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64.h67
-rw-r--r--arch/powerpc/include/asm/pmc.h16
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h6
-rw-r--r--arch/powerpc/include/asm/ppc-pci.h1
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h26
-rw-r--r--arch/powerpc/include/asm/pte-40x.h2
-rw-r--r--arch/powerpc/include/asm/pte-44x.h2
-rw-r--r--arch/powerpc/include/asm/pte-8xx.h1
-rw-r--r--arch/powerpc/include/asm/pte-book3e.h84
-rw-r--r--arch/powerpc/include/asm/pte-common.h25
-rw-r--r--arch/powerpc/include/asm/pte-fsl-booke.h9
-rw-r--r--arch/powerpc/include/asm/pte-hash32.h1
-rw-r--r--arch/powerpc/include/asm/reg.h141
-rw-r--r--arch/powerpc/include/asm/reg_booke.h50
-rw-r--r--arch/powerpc/include/asm/setup.h2
-rw-r--r--arch/powerpc/include/asm/smp.h10
-rw-r--r--arch/powerpc/include/asm/swiotlb.h8
-rw-r--r--arch/powerpc/include/asm/systbl.h4
-rw-r--r--arch/powerpc/include/asm/tlb.h38
-rw-r--r--arch/powerpc/include/asm/tlbflush.h11
-rw-r--r--arch/powerpc/include/asm/vdso.h3
-rw-r--r--arch/powerpc/kernel/Makefile19
-rw-r--r--arch/powerpc/kernel/asm-offsets.c19
-rw-r--r--arch/powerpc/kernel/cpu_setup_6xx.S2
-rw-r--r--arch/powerpc/kernel/cputable.c62
-rw-r--r--arch/powerpc/kernel/dma-iommu.c2
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c53
-rw-r--r--arch/powerpc/kernel/dma.c13
-rw-r--r--arch/powerpc/kernel/entry_32.S20
-rw-r--r--arch/powerpc/kernel/entry_64.S102
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S1001
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S78
-rw-r--r--arch/powerpc/kernel/fpu.S2
-rw-r--r--arch/powerpc/kernel/head_32.S40
-rw-r--r--arch/powerpc/kernel/head_40x.S124
-rw-r--r--arch/powerpc/kernel/head_44x.S58
-rw-r--r--arch/powerpc/kernel/head_64.S83
-rw-r--r--arch/powerpc/kernel/head_8xx.S13
-rw-r--r--arch/powerpc/kernel/head_booke.h50
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S100
-rw-r--r--arch/powerpc/kernel/ibmebus.c2
-rw-r--r--arch/powerpc/kernel/lparcfg.c3
-rw-r--r--arch/powerpc/kernel/misc_32.S7
-rw-r--r--arch/powerpc/kernel/of_platform.c2
-rw-r--r--arch/powerpc/kernel/paca.c3
-rw-r--r--arch/powerpc/kernel/pci-common.c133
-rw-r--r--arch/powerpc/kernel/pci_32.c105
-rw-r--r--arch/powerpc/kernel/pci_64.c335
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c359
-rw-r--r--arch/powerpc/kernel/perf_counter.c68
-rw-r--r--arch/powerpc/kernel/process.c16
-rw-r--r--arch/powerpc/kernel/prom_init.c107
-rw-r--r--arch/powerpc/kernel/rtas.c7
-rw-r--r--arch/powerpc/kernel/setup_32.c8
-rw-r--r--arch/powerpc/kernel/setup_64.c95
-rw-r--r--arch/powerpc/kernel/smp.c15
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c12
-rw-r--r--arch/powerpc/kernel/sysfs.c3
-rw-r--r--arch/powerpc/kernel/time.c33
-rw-r--r--arch/powerpc/kernel/vdso.c7
-rw-r--r--arch/powerpc/kernel/vdso32/Makefile1
-rw-r--r--arch/powerpc/kernel/vdso64/Makefile2
-rw-r--r--arch/powerpc/kernel/vector.S2
-rw-r--r--arch/powerpc/kernel/vio.c2
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S17
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S18
-rw-r--r--arch/powerpc/mm/40x_mmu.c4
-rw-r--r--arch/powerpc/mm/Makefile1
-rw-r--r--arch/powerpc/mm/fsl_booke_mmu.c2
-rw-r--r--arch/powerpc/mm/hash_low_32.S4
-rw-r--r--arch/powerpc/mm/hugetlbpage.c8
-rw-r--r--arch/powerpc/mm/init_32.c2
-rw-r--r--arch/powerpc/mm/init_64.c55
-rw-r--r--arch/powerpc/mm/mmu_context_nohash.c96
-rw-r--r--arch/powerpc/mm/mmu_decl.h37
-rw-r--r--arch/powerpc/mm/pgtable.c179
-rw-r--r--arch/powerpc/mm/pgtable_32.c2
-rw-r--r--arch/powerpc/mm/pgtable_64.c59
-rw-r--r--arch/powerpc/mm/slb.c46
-rw-r--r--arch/powerpc/mm/stab.c2
-rw-r--r--arch/powerpc/mm/tlb_hash32.c3
-rw-r--r--arch/powerpc/mm/tlb_hash64.c20
-rw-r--r--arch/powerpc/mm/tlb_low_64e.S770
-rw-r--r--arch/powerpc/mm/tlb_nohash.c268
-rw-r--r--arch/powerpc/mm/tlb_nohash_low.S87
-rw-r--r--arch/powerpc/platforms/40x/Kconfig10
-rw-r--r--arch/powerpc/platforms/40x/ppc40x_simple.c3
-rw-r--r--arch/powerpc/platforms/44x/Kconfig12
-rw-r--r--arch/powerpc/platforms/44x/ppc44x_simple.c1
-rw-r--r--arch/powerpc/platforms/82xx/mgcoge.c69
-rw-r--r--arch/powerpc/platforms/82xx/mpc8272_ads.c22
-rw-r--r--arch/powerpc/platforms/83xx/Kconfig4
-rw-r--r--arch/powerpc/platforms/83xx/mpc837x_rdb.c28
-rw-r--r--arch/powerpc/platforms/83xx/mpc83xx.h4
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig9
-rw-r--r--arch/powerpc/platforms/85xx/Makefile3
-rw-r--r--arch/powerpc/platforms/85xx/mpc8536_ds.c3
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ds.c3
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c7
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_rdb.c141
-rw-r--r--arch/powerpc/platforms/85xx/sbc8560.c39
-rw-r--r--arch/powerpc/platforms/85xx/smp.c23
-rw-r--r--arch/powerpc/platforms/86xx/gef_ppc9a.c37
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c3
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_smp.c1
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype38
-rw-r--r--arch/powerpc/platforms/amigaone/setup.c6
-rw-r--r--arch/powerpc/platforms/cell/Kconfig7
-rw-r--r--arch/powerpc/platforms/cell/celleb_setup.c3
-rw-r--r--arch/powerpc/platforms/cell/iommu.c2
-rw-r--r--arch/powerpc/platforms/cell/smp.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/Makefile3
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c1
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c1
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h5
-rw-r--r--arch/powerpc/platforms/cell/spufs/sputrace.c272
-rw-r--r--arch/powerpc/platforms/cell/spufs/sputrace.h39
-rw-r--r--arch/powerpc/platforms/iseries/exception.S59
-rw-r--r--arch/powerpc/platforms/iseries/exception.h6
-rw-r--r--arch/powerpc/platforms/iseries/mf.c2
-rw-r--r--arch/powerpc/platforms/pasemi/idle.c2
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c8
-rw-r--r--arch/powerpc/platforms/powermac/feature.c13
-rw-r--r--arch/powerpc/platforms/powermac/pci.c61
-rw-r--r--arch/powerpc/platforms/powermac/smp.c2
-rw-r--r--arch/powerpc/platforms/ps3/mm.c2
-rw-r--r--arch/powerpc/platforms/ps3/smp.c2
-rw-r--r--arch/powerpc/platforms/ps3/system-bus.c6
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c10
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c2
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c9
-rw-r--r--arch/powerpc/platforms/pseries/setup.c4
-rw-r--r--arch/powerpc/platforms/pseries/smp.c2
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c18
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c6
-rw-r--r--arch/powerpc/sysdev/ipic.c7
-rw-r--r--arch/powerpc/sysdev/mmio_nvram.c32
-rw-r--r--arch/powerpc/sysdev/mpic.c13
-rw-r--r--arch/powerpc/sysdev/qe_lib/gpio.c4
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe_ic.c5
-rw-r--r--arch/powerpc/xmon/Makefile2
-rw-r--r--arch/powerpc/xmon/xmon.c2
-rw-r--r--arch/s390/include/asm/percpu.h32
-rw-r--r--arch/s390/kernel/vmlinux.lds.S9
-rw-r--r--arch/sh/include/asm/pci.h1
-rw-r--r--arch/sh/kernel/vmlinux.lds.S10
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/include/asm/agp.h4
-rw-r--r--arch/sparc/include/asm/pci_32.h1
-rw-r--r--arch/sparc/include/asm/pci_64.h1
-rw-r--r--arch/sparc/kernel/smp_64.c132
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S8
-rw-r--r--arch/um/include/asm/common.lds.S5
-rw-r--r--arch/um/include/asm/pci.h1
-rw-r--r--arch/um/kernel/dyn.lds.S2
-rw-r--r--arch/um/kernel/uml.lds.S2
-rw-r--r--arch/x86/Kconfig13
-rw-r--r--arch/x86/include/asm/agp.h4
-rw-r--r--arch/x86/include/asm/bootparam.h3
-rw-r--r--arch/x86/include/asm/cacheflush.h54
-rw-r--r--arch/x86/include/asm/fixmap.h3
-rw-r--r--arch/x86/include/asm/iomap.h9
-rw-r--r--arch/x86/include/asm/mtrr.h6
-rw-r--r--arch/x86/include/asm/pat.h5
-rw-r--r--arch/x86/include/asm/pci.h1
-rw-r--r--arch/x86/include/asm/percpu.h9
-rw-r--r--arch/x86/kernel/Makefile1
-rw-r--r--arch/x86/kernel/cpu/cpu_debug.c4
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c8
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c2
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c46
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c14
-rw-r--r--arch/x86/kernel/pci-dma.c4
-rw-r--r--arch/x86/kernel/quirks.c2
-rw-r--r--arch/x86/kernel/reboot.c7
-rw-r--r--arch/x86/kernel/setup.c23
-rw-r--r--arch/x86/kernel/setup_percpu.c364
-rw-r--r--arch/x86/kernel/smpboot.c16
-rw-r--r--arch/x86/kernel/tboot.c447
-rw-r--r--arch/x86/kernel/vmlinux.lds.S11
-rw-r--r--arch/x86/mm/iomap_32.c27
-rw-r--r--arch/x86/mm/ioremap.c18
-rw-r--r--arch/x86/mm/pageattr.c29
-rw-r--r--arch/x86/mm/pat.c353
-rw-r--r--arch/x86/pci/amd_bus.c64
-rw-r--r--arch/x86/pci/common.c69
-rw-r--r--arch/x86/power/cpu.c2
-rw-r--r--arch/xtensa/kernel/vmlinux.lds.S13
-rw-r--r--block/as-iosched.c10
-rw-r--r--block/cfq-iosched.c10
-rw-r--r--drivers/acpi/acpica/hwsleep.c3
-rw-r--r--drivers/acpi/pci_root.c17
-rw-r--r--drivers/acpi/power.c58
-rw-r--r--drivers/acpi/scan.c1
-rw-r--r--drivers/acpi/sleep.c12
-rw-r--r--drivers/acpi/wakeup.c4
-rw-r--r--drivers/block/ps3vram.c2
-rw-r--r--drivers/char/agp/agp.h15
-rw-r--r--drivers/char/agp/ali-agp.c4
-rw-r--r--drivers/char/agp/amd-k7-agp.c10
-rw-r--r--drivers/char/agp/amd64-agp.c7
-rw-r--r--drivers/char/agp/ati-agp.c7
-rw-r--r--drivers/char/agp/backend.c32
-rw-r--r--drivers/char/agp/efficeon-agp.c4
-rw-r--r--drivers/char/agp/generic.c20
-rw-r--r--drivers/char/agp/hp-agp.c8
-rw-r--r--drivers/char/agp/i460-agp.c17
-rw-r--r--drivers/char/agp/intel-agp.c182
-rw-r--r--drivers/char/agp/nvidia-agp.c2
-rw-r--r--drivers/char/agp/parisc-agp.c12
-rw-r--r--drivers/char/agp/sgi-agp.c8
-rw-r--r--drivers/char/agp/sworks-agp.c10
-rw-r--r--drivers/char/agp/uninorth-agp.c53
-rw-r--r--drivers/char/generic_nvram.c27
-rw-r--r--drivers/char/hvc_console.c2
-rw-r--r--drivers/char/hvc_vio.c4
-rw-r--r--drivers/char/hvsi.c3
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c12
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c15
-rw-r--r--drivers/gpu/Makefile2
-rw-r--r--drivers/gpu/vga/Kconfig10
-rw-r--r--drivers/gpu/vga/Makefile1
-rw-r--r--drivers/gpu/vga/vgaarb.c1205
-rw-r--r--drivers/ide/at91_ide.c2
-rw-r--r--drivers/ide/ide-cd.c32
-rw-r--r--drivers/ide/ide-disk_proc.c129
-rw-r--r--drivers/ide/ide-floppy_proc.c30
-rw-r--r--drivers/ide/ide-ioctls.c8
-rw-r--r--drivers/ide/ide-iops.c17
-rw-r--r--drivers/ide/ide-probe.c31
-rw-r--r--drivers/ide/ide-proc.c340
-rw-r--r--drivers/ide/ide-tape.c160
-rw-r--r--drivers/ide/ide-taskfile.c126
-rw-r--r--drivers/ide/palm_bk3710.c2
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c2
-rw-r--r--drivers/macintosh/macio_asic.c6
-rw-r--r--drivers/macintosh/therm_windtunnel.c4
-rw-r--r--drivers/media/common/ir-functions.c15
-rw-r--r--drivers/media/common/ir-keymaps.c5022
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c20
-rw-r--r--drivers/media/common/tuners/tda18271-priv.h20
-rw-r--r--drivers/media/common/tuners/tda18271.h3
-rw-r--r--drivers/media/common/tuners/tuner-simple.c6
-rw-r--r--drivers/media/common/tuners/tuner-types.c25
-rw-r--r--drivers/media/dvb/Kconfig13
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c218
-rw-r--r--drivers/media/dvb/bt8xx/dst.c2
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c150
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c231
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.h9
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c8
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c35
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h5
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig6
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c70
-rw-r--r--drivers/media/dvb/dvb-usb/af9005-remote.c76
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c20
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.h460
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c92
-rw-r--r--drivers/media/dvb/dvb-usb/cinergyT2-core.c74
-rw-r--r--drivers/media/dvb/dvb-usb/cinergyT2-fe.c1
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c260
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c387
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c244
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c10
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c114
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c36
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h6
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c73
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h17
-rw-r--r--drivers/media/dvb/dvb-usb/dw2102.c403
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c68
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c97
-rw-r--r--drivers/media/dvb/dvb-usb/opera1.c55
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c6
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c102
-rw-r--r--drivers/media/dvb/firewire/firedtv-avc.c143
-rw-r--r--drivers/media/dvb/frontends/Kconfig7
-rw-r--r--drivers/media/dvb/frontends/Makefile1
-rw-r--r--drivers/media/dvb/frontends/cx22700.c2
-rw-r--r--drivers/media/dvb/frontends/cx24113.c6
-rw-r--r--drivers/media/dvb/frontends/cx24123.c2
-rw-r--r--drivers/media/dvb/frontends/dib0070.c2
-rw-r--r--drivers/media/dvb/frontends/dib7000p.c2
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c75
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h4
-rw-r--r--drivers/media/dvb/frontends/lgs8gxx.c484
-rw-r--r--drivers/media/dvb/frontends/lgs8gxx.h11
-rw-r--r--drivers/media/dvb/frontends/lgs8gxx_priv.h12
-rw-r--r--drivers/media/dvb/frontends/mt312.c7
-rw-r--r--drivers/media/dvb/frontends/stb6100.c4
-rw-r--r--drivers/media/dvb/frontends/stv0900_core.c8
-rw-r--r--drivers/media/dvb/frontends/stv0900_sw.c2
-rw-r--r--drivers/media/dvb/frontends/stv6110.c48
-rw-r--r--drivers/media/dvb/frontends/stv6110.h2
-rw-r--r--drivers/media/dvb/frontends/tda10021.c2
-rw-r--r--drivers/media/dvb/frontends/tda8261.c4
-rw-r--r--drivers/media/dvb/frontends/ves1820.c2
-rw-r--r--drivers/media/dvb/frontends/zl10036.c2
-rw-r--r--drivers/media/dvb/frontends/zl10039.c308
-rw-r--r--drivers/media/dvb/frontends/zl10039.h40
-rw-r--r--drivers/media/dvb/frontends/zl10353.c14
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c2
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c6
-rw-r--r--drivers/media/radio/Kconfig59
-rw-r--r--drivers/media/radio/Makefile4
-rw-r--r--drivers/media/radio/radio-cadet.c6
-rw-r--r--drivers/media/radio/radio-si470x.c1863
-rw-r--r--drivers/media/radio/radio-si4713.c367
-rw-r--r--drivers/media/radio/si470x/Kconfig37
-rw-r--r--drivers/media/radio/si470x/Makefile9
-rw-r--r--drivers/media/radio/si470x/radio-si470x-common.c798
-rw-r--r--drivers/media/radio/si470x/radio-si470x-i2c.c401
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c988
-rw-r--r--drivers/media/radio/si470x/radio-si470x.h225
-rw-r--r--drivers/media/radio/si4713-i2c.c2060
-rw-r--r--drivers/media/radio/si4713-i2c.h237
-rw-r--r--drivers/media/video/Kconfig6
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c2
-rw-r--r--drivers/media/video/au0828/au0828-i2c.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c14
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c27
-rw-r--r--drivers/media/video/cafe_ccic.c1
-rw-r--r--drivers/media/video/cx18/cx18-cards.c8
-rw-r--r--drivers/media/video/cx18/cx18-cards.h18
-rw-r--r--drivers/media/video/cx18/cx18-driver.c41
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c2
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c59
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c2
-rw-r--r--drivers/media/video/cx231xx/cx231xx-conf-reg.h8
-rw-r--r--drivers/media/video/cx231xx/cx231xx-i2c.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-video.c4
-rw-r--r--drivers/media/video/cx231xx/cx231xx.h2
-rw-r--r--drivers/media/video/cx23885/cimax2.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c57
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c77
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c30
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c54
-rw-r--r--drivers/media/video/cx23885/cx23885-i2c.c1
-rw-r--r--drivers/media/video/cx23885/cx23885.h14
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c15
-rw-r--r--drivers/media/video/cx25840/cx25840-firmware.c48
-rw-r--r--drivers/media/video/cx88/cx88-cards.c56
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c16
-rw-r--r--drivers/media/video/cx88/cx88-input.c78
-rw-r--r--drivers/media/video/cx88/cx88.h1
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c115
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c161
-rw-r--r--drivers/media/video/em28xx/em28xx.h8
-rw-r--r--drivers/media/video/gspca/Kconfig21
-rw-r--r--drivers/media/video/gspca/Makefile2
-rw-r--r--drivers/media/video/gspca/conex.c2
-rw-r--r--drivers/media/video/gspca/etoms.c4
-rw-r--r--drivers/media/video/gspca/gspca.c66
-rw-r--r--drivers/media/video/gspca/gspca.h5
-rw-r--r--drivers/media/video/gspca/jeilinj.c388
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.c4
-rw-r--r--drivers/media/video/gspca/mr97310a.c853
-rw-r--r--drivers/media/video/gspca/pac207.c37
-rw-r--r--drivers/media/video/gspca/pac7311.c2
-rw-r--r--drivers/media/video/gspca/sn9c20x.c235
-rw-r--r--drivers/media/video/gspca/sonixj.c40
-rw-r--r--drivers/media/video/gspca/spca501.c2
-rw-r--r--drivers/media/video/gspca/spca506.c2
-rw-r--r--drivers/media/video/gspca/spca508.c59
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.c4
-rw-r--r--drivers/media/video/gspca/sunplus.c386
-rw-r--r--drivers/media/video/gspca/t613.c210
-rw-r--r--drivers/media/video/gspca/tv8532.c2
-rw-r--r--drivers/media/video/gspca/vc032x.c1126
-rw-r--r--drivers/media/video/gspca/zc3xx.c2
-rw-r--r--drivers/media/video/hdpvr/hdpvr-control.c24
-rw-r--r--drivers/media/video/hdpvr/hdpvr-core.c12
-rw-r--r--drivers/media/video/hdpvr/hdpvr-i2c.c1
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c6
-rw-r--r--drivers/media/video/ir-kbd-i2c.c64
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.c70
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.h3
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-gpio.c13
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c2
-rw-r--r--drivers/media/video/meye.c3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-audio.c5
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c1
-rw-r--r--drivers/media/video/pwc/pwc-if.c78
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c2
-rw-r--r--drivers/media/video/pwc/pwc.h7
-rw-r--r--drivers/media/video/saa6588.c60
-rw-r--r--drivers/media/video/saa7134/Kconfig1
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c242
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c213
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c17
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c120
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c5
-rw-r--r--drivers/media/video/saa7134/saa7134.h9
-rw-r--r--drivers/media/video/sn9c102/sn9c102_devtable.h2
-rw-r--r--drivers/media/video/stk-webcam.c1
-rw-r--r--drivers/media/video/stv680.c9
-rw-r--r--drivers/media/video/tuner-core.c4
-rw-r--r--drivers/media/video/tveeprom.c4
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c255
-rw-r--r--drivers/media/video/uvc/uvc_driver.c570
-rw-r--r--drivers/media/video/uvc/uvc_isight.c7
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c277
-rw-r--r--drivers/media/video/uvc/uvc_video.c434
-rw-r--r--drivers/media/video/uvc/uvcvideo.h278
-rw-r--r--drivers/media/video/v4l1-compat.c5
-rw-r--r--drivers/media/video/v4l2-common.c52
-rw-r--r--drivers/media/video/v4l2-compat-ioctl32.c67
-rw-r--r--drivers/media/video/v4l2-ioctl.c33
-rw-r--r--drivers/media/video/vino.c1
-rw-r--r--drivers/media/video/w9968cf.c1
-rw-r--r--drivers/media/video/zoran/zoran_card.c3
-rw-r--r--drivers/media/video/zr364xx.c1226
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c2
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c2
-rw-r--r--drivers/mtd/maps/bfin-async-flash.c2
-rw-r--r--drivers/mtd/maps/ceiva.c2
-rw-r--r--drivers/mtd/maps/dc21285.c4
-rw-r--r--drivers/mtd/maps/ipaq-flash.c2
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c2
-rw-r--r--drivers/mtd/maps/sa1100-flash.c2
-rw-r--r--drivers/mtd/mtdblock.c4
-rw-r--r--drivers/mtd/mtdpart.c2
-rw-r--r--drivers/net/smc91x.c4
-rw-r--r--drivers/net/smc91x.h2
-rw-r--r--drivers/pci/Makefile3
-rw-r--r--drivers/pci/dmar.c7
-rw-r--r--drivers/pci/hotplug/Makefile2
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c117
-rw-r--r--drivers/pci/hotplug/acpiphp.h3
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c187
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c3
-rw-r--r--drivers/pci/hotplug/pciehp.h9
-rw-r--r--drivers/pci/hotplug/pciehp_acpi.c7
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c5
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c10
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c137
-rw-r--r--drivers/pci/hotplug/pcihp_slot.c187
-rw-r--r--drivers/pci/hotplug/shpchp.h9
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c62
-rw-r--r--drivers/pci/intel-iommu.c17
-rw-r--r--drivers/pci/legacy.c34
-rw-r--r--drivers/pci/msi.c283
-rw-r--r--drivers/pci/pci-acpi.c29
-rw-r--r--drivers/pci/pci-driver.c132
-rw-r--r--drivers/pci/pci-stub.c45
-rw-r--r--drivers/pci/pci-sysfs.c37
-rw-r--r--drivers/pci/pci.c106
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/pcie/aer/aer_inject.c25
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c22
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h34
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c107
-rw-r--r--drivers/pci/pcie/aer/aerdrv_errprint.c190
-rw-r--r--drivers/pci/pcie/aspm.c495
-rw-r--r--drivers/pci/pcie/portdrv_core.c6
-rw-r--r--drivers/pci/pcie/portdrv_pci.c1
-rw-r--r--drivers/pci/probe.c33
-rw-r--r--drivers/pci/quirks.c36
-rw-r--r--drivers/pci/search.c31
-rw-r--r--drivers/pci/setup-bus.c22
-rw-r--r--drivers/pci/setup-res.c1
-rw-r--r--drivers/pcmcia/yenta_socket.c16
-rw-r--r--drivers/ps3/ps3stor_lib.c65
-rw-r--r--drivers/rtc/rtc-sa1100.c2
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/ps3fb.c2
-rw-r--r--drivers/video/sa1100fb.c2
-rw-r--r--drivers/xen/events.c13
-rw-r--r--fs/afs/write.c1
-rw-r--r--fs/block_dev.c1
-rw-r--r--fs/btrfs/disk-io.c1
-rw-r--r--fs/btrfs/ordered-data.c1
-rw-r--r--fs/fs-writeback.c345
-rw-r--r--fs/fuse/inode.c2
-rw-r--r--fs/inode.c4
-rw-r--r--fs/jbd2/commit.c1
-rw-r--r--fs/nfs/super.c2
-rw-r--r--fs/nfs/write.c1
-rw-r--r--fs/nilfs2/the_nilfs.c4
-rw-r--r--fs/super.c6
-rw-r--r--fs/sync.c9
-rw-r--r--fs/ubifs/budget.c20
-rw-r--r--fs/ubifs/super.c1
-rw-r--r--include/acpi/acpi_bus.h18
-rw-r--r--include/asm-generic/pci.h13
-rw-r--r--include/asm-generic/vmlinux.lds.h24
-rw-r--r--include/linux/agp_backend.h5
-rw-r--r--include/linux/backing-dev.h3
-rw-r--r--include/linux/dma-mapping.h1
-rw-r--r--include/linux/dvb/dmx.h2
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/ide.h30
-rw-r--r--include/linux/io-mapping.h17
-rw-r--r--include/linux/mtd/partitions.h2
-rw-r--r--include/linux/page-flags.h4
-rw-r--r--include/linux/pci.h14
-rw-r--r--include/linux/pci_hotplug.h16
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/percpu-defs.h66
-rw-r--r--include/linux/percpu.h88
-rw-r--r--include/linux/tboot.h162
-rw-r--r--include/linux/usb/video.h164
-rw-r--r--include/linux/vgaarb.h200
-rw-r--r--include/linux/videodev2.h105
-rw-r--r--include/linux/vmalloc.h6
-rw-r--r--include/linux/writeback.h5
-rw-r--r--include/media/ir-common.h138
-rw-r--r--include/media/ir-kbd-i2c.h22
-rw-r--r--include/media/radio-si4713.h30
-rw-r--r--include/media/si4713.h49
-rw-r--r--include/media/tuner.h1
-rw-r--r--include/media/v4l2-subdev.h5
-rw-r--r--include/trace/events/ext4.h6
-rw-r--r--init/main.c24
-rw-r--r--kernel/cpu.c15
-rw-r--r--kernel/gcov/Kconfig2
-rw-r--r--kernel/module.c6
-rw-r--r--kernel/perf_counter.c7
-rw-r--r--kernel/sched.c4
-rw-r--r--kernel/smp.c40
-rw-r--r--kernel/sysctl.c4
-rw-r--r--kernel/trace/trace_events.c6
-rw-r--r--lib/Kconfig.debug17
-rw-r--r--lib/inflate.c2
-rw-r--r--mm/Kconfig2
-rw-r--r--mm/Makefile2
-rw-r--r--mm/allocpercpu.c28
-rw-r--r--mm/backing-dev.c90
-rw-r--r--mm/kmemleak-test.c6
-rw-r--r--mm/page-writeback.c27
-rw-r--r--mm/percpu.c1420
-rw-r--r--mm/quicklist.c2
-rw-r--r--mm/slub.c6
-rw-r--r--mm/vmalloc.c338
-rw-r--r--net/ipv4/syncookies.c5
-rw-r--r--net/ipv6/syncookies.c5
-rw-r--r--net/rds/ib_stats.c2
-rw-r--r--net/rds/iw_stats.c2
-rw-r--r--net/rds/page.c2
-rw-r--r--scripts/module-common.lds8
-rw-r--r--security/Kconfig30
691 files changed, 36071 insertions, 14775 deletions
diff --git a/CREDITS b/CREDITS
index 1a41bf4addd0..72b487869788 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2800,7 +2800,7 @@ D: Starter of Linux1394 effort
2800S: ask per mail for current address 2800S: ask per mail for current address
2801 2801
2802N: Nicolas Pitre 2802N: Nicolas Pitre
2803E: nico@cam.org 2803E: nico@fluxnic.net
2804D: StrongARM SA1100 support integrator & hacker 2804D: StrongARM SA1100 support integrator & hacker
2805D: Xscale PXA architecture 2805D: Xscale PXA architecture
2806D: unified SMC 91C9x/91C11x ethernet driver (smc91x) 2806D: unified SMC 91C9x/91C11x ethernet driver (smc91x)
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index 6bf68053e4b8..25be3250f7d6 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -84,6 +84,16 @@ Description:
84 from this part of the device tree. 84 from this part of the device tree.
85 Depends on CONFIG_HOTPLUG. 85 Depends on CONFIG_HOTPLUG.
86 86
87What: /sys/bus/pci/devices/.../reset
88Date: July 2009
89Contact: Michael S. Tsirkin <mst@redhat.com>
90Description:
91 Some devices allow an individual function to be reset
92 without affecting other functions in the same device.
93 For devices that have this support, a file named reset
94 will be present in sysfs. Writing 1 to this file
95 will perform reset.
96
87What: /sys/bus/pci/devices/.../vpd 97What: /sys/bus/pci/devices/.../vpd
88Date: February 2008 98Date: February 2008
89Contact: Ben Hutchings <bhutchings@solarflare.com> 99Contact: Ben Hutchings <bhutchings@solarflare.com>
diff --git a/Documentation/PCI/pci-error-recovery.txt b/Documentation/PCI/pci-error-recovery.txt
index 6650af432523..e83f2ea76415 100644
--- a/Documentation/PCI/pci-error-recovery.txt
+++ b/Documentation/PCI/pci-error-recovery.txt
@@ -4,15 +4,17 @@
4 February 2, 2006 4 February 2, 2006
5 5
6 Current document maintainer: 6 Current document maintainer:
7 Linas Vepstas <linas@austin.ibm.com> 7 Linas Vepstas <linasvepstas@gmail.com>
8 updated by Richard Lary <rlary@us.ibm.com>
9 and Mike Mason <mmlnx@us.ibm.com> on 27-Jul-2009
8 10
9 11
10Many PCI bus controllers are able to detect a variety of hardware 12Many PCI bus controllers are able to detect a variety of hardware
11PCI errors on the bus, such as parity errors on the data and address 13PCI errors on the bus, such as parity errors on the data and address
12busses, as well as SERR and PERR errors. Some of the more advanced 14busses, as well as SERR and PERR errors. Some of the more advanced
13chipsets are able to deal with these errors; these include PCI-E chipsets, 15chipsets are able to deal with these errors; these include PCI-E chipsets,
14and the PCI-host bridges found on IBM Power4 and Power5-based pSeries 16and the PCI-host bridges found on IBM Power4, Power5 and Power6-based
15boxes. A typical action taken is to disconnect the affected device, 17pSeries boxes. A typical action taken is to disconnect the affected device,
16halting all I/O to it. The goal of a disconnection is to avoid system 18halting all I/O to it. The goal of a disconnection is to avoid system
17corruption; for example, to halt system memory corruption due to DMA's 19corruption; for example, to halt system memory corruption due to DMA's
18to "wild" addresses. Typically, a reconnection mechanism is also 20to "wild" addresses. Typically, a reconnection mechanism is also
@@ -37,10 +39,11 @@ is forced by the need to handle multi-function devices, that is,
37devices that have multiple device drivers associated with them. 39devices that have multiple device drivers associated with them.
38In the first stage, each driver is allowed to indicate what type 40In the first stage, each driver is allowed to indicate what type
39of reset it desires, the choices being a simple re-enabling of I/O 41of reset it desires, the choices being a simple re-enabling of I/O
40or requesting a hard reset (a full electrical #RST of the PCI card). 42or requesting a slot reset.
41If any driver requests a full reset, that is what will be done.
42 43
43After a full reset and/or a re-enabling of I/O, all drivers are 44If any driver requests a slot reset, that is what will be done.
45
46After a reset and/or a re-enabling of I/O, all drivers are
44again notified, so that they may then perform any device setup/config 47again notified, so that they may then perform any device setup/config
45that may be required. After these have all completed, a final 48that may be required. After these have all completed, a final
46"resume normal operations" event is sent out. 49"resume normal operations" event is sent out.
@@ -101,7 +104,7 @@ if it implements any, it must implement error_detected(). If a callback
101is not implemented, the corresponding feature is considered unsupported. 104is not implemented, the corresponding feature is considered unsupported.
102For example, if mmio_enabled() and resume() aren't there, then it 105For example, if mmio_enabled() and resume() aren't there, then it
103is assumed that the driver is not doing any direct recovery and requires 106is assumed that the driver is not doing any direct recovery and requires
104a reset. If link_reset() is not implemented, the card is assumed as 107a slot reset. If link_reset() is not implemented, the card is assumed to
105not care about link resets. Typically a driver will want to know about 108not care about link resets. Typically a driver will want to know about
106a slot_reset(). 109a slot_reset().
107 110
@@ -111,7 +114,7 @@ sequence described below.
111 114
112STEP 0: Error Event 115STEP 0: Error Event
113------------------- 116-------------------
114PCI bus error is detect by the PCI hardware. On powerpc, the slot 117A PCI bus error is detected by the PCI hardware. On powerpc, the slot
115is isolated, in that all I/O is blocked: all reads return 0xffffffff, 118is isolated, in that all I/O is blocked: all reads return 0xffffffff,
116all writes are ignored. 119all writes are ignored.
117 120
@@ -139,7 +142,7 @@ The driver must return one of the following result codes:
139 a chance to extract some diagnostic information (see 142 a chance to extract some diagnostic information (see
140 mmio_enable, below). 143 mmio_enable, below).
141 - PCI_ERS_RESULT_NEED_RESET: 144 - PCI_ERS_RESULT_NEED_RESET:
142 Driver returns this if it can't recover without a hard 145 Driver returns this if it can't recover without a
143 slot reset. 146 slot reset.
144 - PCI_ERS_RESULT_DISCONNECT: 147 - PCI_ERS_RESULT_DISCONNECT:
145 Driver returns this if it doesn't want to recover at all. 148 Driver returns this if it doesn't want to recover at all.
@@ -169,11 +172,11 @@ is STEP 6 (Permanent Failure).
169 172
170>>> The current powerpc implementation doesn't much care if the device 173>>> The current powerpc implementation doesn't much care if the device
171>>> attempts I/O at this point, or not. I/O's will fail, returning 174>>> attempts I/O at this point, or not. I/O's will fail, returning
172>>> a value of 0xff on read, and writes will be dropped. If the device 175>>> a value of 0xff on read, and writes will be dropped. If more than
173>>> driver attempts more than 10K I/O's to a frozen adapter, it will 176>>> EEH_MAX_FAILS I/O's are attempted to a frozen adapter, EEH
174>>> assume that the device driver has gone into an infinite loop, and 177>>> assumes that the device driver has gone into an infinite loop
175>>> it will panic the kernel. There doesn't seem to be any other 178>>> and prints an error to syslog. A reboot is then required to
176>>> way of stopping a device driver that insists on spinning on I/O. 179>>> get the device working again.
177 180
178STEP 2: MMIO Enabled 181STEP 2: MMIO Enabled
179------------------- 182-------------------
@@ -182,15 +185,14 @@ DMA), and then calls the mmio_enabled() callback on all affected
182device drivers. 185device drivers.
183 186
184This is the "early recovery" call. IOs are allowed again, but DMA is 187This is the "early recovery" call. IOs are allowed again, but DMA is
185not (hrm... to be discussed, I prefer not), with some restrictions. This 188not, with some restrictions. This is NOT a callback for the driver to
186is NOT a callback for the driver to start operations again, only to 189start operations again, only to peek/poke at the device, extract diagnostic
187peek/poke at the device, extract diagnostic information, if any, and 190information, if any, and eventually do things like trigger a device local
188eventually do things like trigger a device local reset or some such, 191reset or some such, but not restart operations. This callback is made if
189but not restart operations. This is callback is made if all drivers on 192all drivers on a segment agree that they can try to recover and if no automatic
190a segment agree that they can try to recover and if no automatic link reset 193link reset was performed by the HW. If the platform can't just re-enable IOs
191was performed by the HW. If the platform can't just re-enable IOs without 194without a slot reset or a link reset, it will not call this callback, and
192a slot reset or a link reset, it wont call this callback, and instead 195instead will have gone directly to STEP 3 (Link Reset) or STEP 4 (Slot Reset)
193will have gone directly to STEP 3 (Link Reset) or STEP 4 (Slot Reset)
194 196
195>>> The following is proposed; no platform implements this yet: 197>>> The following is proposed; no platform implements this yet:
196>>> Proposal: All I/O's should be done _synchronously_ from within 198>>> Proposal: All I/O's should be done _synchronously_ from within
@@ -228,9 +230,6 @@ proceeds to either STEP3 (Link Reset) or to STEP 5 (Resume Operations).
228If any driver returned PCI_ERS_RESULT_NEED_RESET, then the platform 230If any driver returned PCI_ERS_RESULT_NEED_RESET, then the platform
229proceeds to STEP 4 (Slot Reset) 231proceeds to STEP 4 (Slot Reset)
230 232
231>>> The current powerpc implementation does not implement this callback.
232
233
234STEP 3: Link Reset 233STEP 3: Link Reset
235------------------ 234------------------
236The platform resets the link, and then calls the link_reset() callback 235The platform resets the link, and then calls the link_reset() callback
@@ -253,16 +252,33 @@ The platform then proceeds to either STEP 4 (Slot Reset) or STEP 5
253 252
254>>> The current powerpc implementation does not implement this callback. 253>>> The current powerpc implementation does not implement this callback.
255 254
256
257STEP 4: Slot Reset 255STEP 4: Slot Reset
258------------------ 256------------------
259The platform performs a soft or hard reset of the device, and then
260calls the slot_reset() callback.
261 257
262A soft reset consists of asserting the adapter #RST line and then 258In response to a return value of PCI_ERS_RESULT_NEED_RESET, the
259the platform will peform a slot reset on the requesting PCI device(s).
260The actual steps taken by a platform to perform a slot reset
261will be platform-dependent. Upon completion of slot reset, the
262platform will call the device slot_reset() callback.
263
264Powerpc platforms implement two levels of slot reset:
265soft reset(default) and fundamental(optional) reset.
266
267Powerpc soft reset consists of asserting the adapter #RST line and then
263restoring the PCI BAR's and PCI configuration header to a state 268restoring the PCI BAR's and PCI configuration header to a state
264that is equivalent to what it would be after a fresh system 269that is equivalent to what it would be after a fresh system
265power-on followed by power-on BIOS/system firmware initialization. 270power-on followed by power-on BIOS/system firmware initialization.
271Soft reset is also known as hot-reset.
272
273Powerpc fundamental reset is supported by PCI Express cards only
274and results in device's state machines, hardware logic, port states and
275configuration registers to initialize to their default conditions.
276
277For most PCI devices, a soft reset will be sufficient for recovery.
278Optional fundamental reset is provided to support a limited number
279of PCI Express PCI devices for which a soft reset is not sufficient
280for recovery.
281
266If the platform supports PCI hotplug, then the reset might be 282If the platform supports PCI hotplug, then the reset might be
267performed by toggling the slot electrical power off/on. 283performed by toggling the slot electrical power off/on.
268 284
@@ -274,10 +290,12 @@ may result in hung devices, kernel panics, or silent data corruption.
274 290
275This call gives drivers the chance to re-initialize the hardware 291This call gives drivers the chance to re-initialize the hardware
276(re-download firmware, etc.). At this point, the driver may assume 292(re-download firmware, etc.). At this point, the driver may assume
277that he card is in a fresh state and is fully functional. In 293that the card is in a fresh state and is fully functional. The slot
278particular, interrupt generation should work normally. 294is unfrozen and the driver has full access to PCI config space,
295memory mapped I/O space and DMA. Interrupts (Legacy, MSI, or MSI-X)
296will also be available.
279 297
280Drivers should not yet restart normal I/O processing operations 298Drivers should not restart normal I/O processing operations
281at this point. If all device drivers report success on this 299at this point. If all device drivers report success on this
282callback, the platform will call resume() to complete the sequence, 300callback, the platform will call resume() to complete the sequence,
283and let the driver restart normal I/O processing. 301and let the driver restart normal I/O processing.
@@ -302,11 +320,21 @@ driver performs device init only from PCI function 0:
302 - PCI_ERS_RESULT_DISCONNECT 320 - PCI_ERS_RESULT_DISCONNECT
303 Same as above. 321 Same as above.
304 322
323Drivers for PCI Express cards that require a fundamental reset must
324set the needs_freset bit in the pci_dev structure in their probe function.
325For example, the QLogic qla2xxx driver sets the needs_freset bit for certain
326PCI card types:
327
328+ /* Set EEH reset type to fundamental if required by hba */
329+ if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha))
330+ pdev->needs_freset = 1;
331+
332
305Platform proceeds either to STEP 5 (Resume Operations) or STEP 6 (Permanent 333Platform proceeds either to STEP 5 (Resume Operations) or STEP 6 (Permanent
306Failure). 334Failure).
307 335
308>>> The current powerpc implementation does not currently try a 336>>> The current powerpc implementation does not try a power-cycle
309>>> power-cycle reset if the driver returned PCI_ERS_RESULT_DISCONNECT. 337>>> reset if the driver returned PCI_ERS_RESULT_DISCONNECT.
310>>> However, it probably should. 338>>> However, it probably should.
311 339
312 340
@@ -348,7 +376,7 @@ software errors.
348 376
349Conclusion; General Remarks 377Conclusion; General Remarks
350--------------------------- 378---------------------------
351The way those callbacks are called is platform policy. A platform with 379The way the callbacks are called is platform policy. A platform with
352no slot reset capability may want to just "ignore" drivers that can't 380no slot reset capability may want to just "ignore" drivers that can't
353recover (disconnect them) and try to let other cards on the same segment 381recover (disconnect them) and try to let other cards on the same segment
354recover. Keep in mind that in most real life cases, though, there will 382recover. Keep in mind that in most real life cases, though, there will
@@ -361,8 +389,8 @@ That is, the recovery API only requires that:
361 389
362 - There is no guarantee that interrupt delivery can proceed from any 390 - There is no guarantee that interrupt delivery can proceed from any
363device on the segment starting from the error detection and until the 391device on the segment starting from the error detection and until the
364resume callback is sent, at which point interrupts are expected to be 392slot_reset callback is called, at which point interrupts are expected
365fully operational. 393to be fully operational.
366 394
367 - There is no guarantee that interrupt delivery is stopped, that is, 395 - There is no guarantee that interrupt delivery is stopped, that is,
368a driver that gets an interrupt after detecting an error, or that detects 396a driver that gets an interrupt after detecting an error, or that detects
@@ -381,16 +409,23 @@ anyway :)
381>>> Implementation details for the powerpc platform are discussed in 409>>> Implementation details for the powerpc platform are discussed in
382>>> the file Documentation/powerpc/eeh-pci-error-recovery.txt 410>>> the file Documentation/powerpc/eeh-pci-error-recovery.txt
383 411
384>>> As of this writing, there are six device drivers with patches 412>>> As of this writing, there is a growing list of device drivers with
385>>> implementing error recovery. Not all of these patches are in 413>>> patches implementing error recovery. Not all of these patches are in
386>>> mainline yet. These may be used as "examples": 414>>> mainline yet. These may be used as "examples":
387>>> 415>>>
388>>> drivers/scsi/ipr.c 416>>> drivers/scsi/ipr
389>>> drivers/scsi/sym53cxx_2 417>>> drivers/scsi/sym53c8xx_2
418>>> drivers/scsi/qla2xxx
419>>> drivers/scsi/lpfc
420>>> drivers/next/bnx2.c
390>>> drivers/next/e100.c 421>>> drivers/next/e100.c
391>>> drivers/net/e1000 422>>> drivers/net/e1000
423>>> drivers/net/e1000e
392>>> drivers/net/ixgb 424>>> drivers/net/ixgb
425>>> drivers/net/ixgbe
426>>> drivers/net/cxgb3
393>>> drivers/net/s2io.c 427>>> drivers/net/s2io.c
428>>> drivers/net/qlge
394 429
395The End 430The End
396------- 431-------
diff --git a/Documentation/arm/SA1100/ADSBitsy b/Documentation/arm/SA1100/ADSBitsy
index ab47c3833908..7197a9e958ee 100644
--- a/Documentation/arm/SA1100/ADSBitsy
+++ b/Documentation/arm/SA1100/ADSBitsy
@@ -40,4 +40,4 @@ Notes:
40 mode, the timing is off so the image is corrupted. This will be 40 mode, the timing is off so the image is corrupted. This will be
41 fixed soon. 41 fixed soon.
42 42
43Any contribution can be sent to nico@cam.org and will be greatly welcome! 43Any contribution can be sent to nico@fluxnic.net and will be greatly welcome!
diff --git a/Documentation/arm/SA1100/Assabet b/Documentation/arm/SA1100/Assabet
index 78bc1c1b04e5..91f7ce7ba426 100644
--- a/Documentation/arm/SA1100/Assabet
+++ b/Documentation/arm/SA1100/Assabet
@@ -240,7 +240,7 @@ Then, rebooting the Assabet is just a matter of waiting for the login prompt.
240 240
241 241
242Nicolas Pitre 242Nicolas Pitre
243nico@cam.org 243nico@fluxnic.net
244June 12, 2001 244June 12, 2001
245 245
246 246
diff --git a/Documentation/arm/SA1100/Brutus b/Documentation/arm/SA1100/Brutus
index 2254c8f0b326..b1cfd405dccc 100644
--- a/Documentation/arm/SA1100/Brutus
+++ b/Documentation/arm/SA1100/Brutus
@@ -60,7 +60,7 @@ little modifications.
60 60
61Any contribution is welcome. 61Any contribution is welcome.
62 62
63Please send patches to nico@cam.org 63Please send patches to nico@fluxnic.net
64 64
65Have Fun ! 65Have Fun !
66 66
diff --git a/Documentation/arm/SA1100/GraphicsClient b/Documentation/arm/SA1100/GraphicsClient
index 8fa7e8027ff1..6c9c4f5a36e1 100644
--- a/Documentation/arm/SA1100/GraphicsClient
+++ b/Documentation/arm/SA1100/GraphicsClient
@@ -4,7 +4,7 @@ For more details, contact Applied Data Systems or see
4http://www.applieddata.net/products.html 4http://www.applieddata.net/products.html
5 5
6The original Linux support for this product has been provided by 6The original Linux support for this product has been provided by
7Nicolas Pitre <nico@cam.org>. Continued development work by 7Nicolas Pitre <nico@fluxnic.net>. Continued development work by
8Woojung Huh <whuh@applieddata.net> 8Woojung Huh <whuh@applieddata.net>
9 9
10It's currently possible to mount a root filesystem via NFS providing a 10It's currently possible to mount a root filesystem via NFS providing a
@@ -94,5 +94,5 @@ Notes:
94 mode, the timing is off so the image is corrupted. This will be 94 mode, the timing is off so the image is corrupted. This will be
95 fixed soon. 95 fixed soon.
96 96
97Any contribution can be sent to nico@cam.org and will be greatly welcome! 97Any contribution can be sent to nico@fluxnic.net and will be greatly welcome!
98 98
diff --git a/Documentation/arm/SA1100/GraphicsMaster b/Documentation/arm/SA1100/GraphicsMaster
index dd28745ac521..ee7c6595f23f 100644
--- a/Documentation/arm/SA1100/GraphicsMaster
+++ b/Documentation/arm/SA1100/GraphicsMaster
@@ -4,7 +4,7 @@ For more details, contact Applied Data Systems or see
4http://www.applieddata.net/products.html 4http://www.applieddata.net/products.html
5 5
6The original Linux support for this product has been provided by 6The original Linux support for this product has been provided by
7Nicolas Pitre <nico@cam.org>. Continued development work by 7Nicolas Pitre <nico@fluxnic.net>. Continued development work by
8Woojung Huh <whuh@applieddata.net> 8Woojung Huh <whuh@applieddata.net>
9 9
10Use 'make graphicsmaster_config' before any 'make config'. 10Use 'make graphicsmaster_config' before any 'make config'.
@@ -50,4 +50,4 @@ Notes:
50 mode, the timing is off so the image is corrupted. This will be 50 mode, the timing is off so the image is corrupted. This will be
51 fixed soon. 51 fixed soon.
52 52
53Any contribution can be sent to nico@cam.org and will be greatly welcome! 53Any contribution can be sent to nico@fluxnic.net and will be greatly welcome!
diff --git a/Documentation/arm/SA1100/Victor b/Documentation/arm/SA1100/Victor
index 01e81fc49461..f938a29fdc20 100644
--- a/Documentation/arm/SA1100/Victor
+++ b/Documentation/arm/SA1100/Victor
@@ -9,7 +9,7 @@ Of course Victor is using Linux as its main operating system.
9The Victor implementation for Linux is maintained by Nicolas Pitre: 9The Victor implementation for Linux is maintained by Nicolas Pitre:
10 10
11 nico@visuaide.com 11 nico@visuaide.com
12 nico@cam.org 12 nico@fluxnic.net
13 13
14For any comments, please feel free to contact me through the above 14For any comments, please feel free to contact me through the above
15addresses. 15addresses.
diff --git a/Documentation/intel_txt.txt b/Documentation/intel_txt.txt
new file mode 100644
index 000000000000..f40a1f030019
--- /dev/null
+++ b/Documentation/intel_txt.txt
@@ -0,0 +1,210 @@
1Intel(R) TXT Overview:
2=====================
3
4Intel's technology for safer computing, Intel(R) Trusted Execution
5Technology (Intel(R) TXT), defines platform-level enhancements that
6provide the building blocks for creating trusted platforms.
7
8Intel TXT was formerly known by the code name LaGrande Technology (LT).
9
10Intel TXT in Brief:
11o Provides dynamic root of trust for measurement (DRTM)
12o Data protection in case of improper shutdown
13o Measurement and verification of launched environment
14
15Intel TXT is part of the vPro(TM) brand and is also available some
16non-vPro systems. It is currently available on desktop systems
17based on the Q35, X38, Q45, and Q43 Express chipsets (e.g. Dell
18Optiplex 755, HP dc7800, etc.) and mobile systems based on the GM45,
19PM45, and GS45 Express chipsets.
20
21For more information, see http://www.intel.com/technology/security/.
22This site also has a link to the Intel TXT MLE Developers Manual,
23which has been updated for the new released platforms.
24
25Intel TXT has been presented at various events over the past few
26years, some of which are:
27 LinuxTAG 2008:
28 http://www.linuxtag.org/2008/en/conf/events/vp-donnerstag/
29 details.html?talkid=110
30 TRUST2008:
31 http://www.trust2008.eu/downloads/Keynote-Speakers/
32 3_David-Grawrock_The-Front-Door-of-Trusted-Computing.pdf
33 IDF 2008, Shanghai:
34 http://inteldeveloperforum.com.edgesuite.net/shanghai_2008/
35 aep/PROS003/index.html
36 IDFs 2006, 2007 (I'm not sure if/where they are online)
37
38Trusted Boot Project Overview:
39=============================
40
41Trusted Boot (tboot) is an open source, pre- kernel/VMM module that
42uses Intel TXT to perform a measured and verified launch of an OS
43kernel/VMM.
44
45It is hosted on SourceForge at http://sourceforge.net/projects/tboot.
46The mercurial source repo is available at http://www.bughost.org/
47repos.hg/tboot.hg.
48
49Tboot currently supports launching Xen (open source VMM/hypervisor
50w/ TXT support since v3.2), and now Linux kernels.
51
52
53Value Proposition for Linux or "Why should you care?"
54=====================================================
55
56While there are many products and technologies that attempt to
57measure or protect the integrity of a running kernel, they all
58assume the kernel is "good" to begin with. The Integrity
59Measurement Architecture (IMA) and Linux Integrity Module interface
60are examples of such solutions.
61
62To get trust in the initial kernel without using Intel TXT, a
63static root of trust must be used. This bases trust in BIOS
64starting at system reset and requires measurement of all code
65executed between system reset through the completion of the kernel
66boot as well as data objects used by that code. In the case of a
67Linux kernel, this means all of BIOS, any option ROMs, the
68bootloader and the boot config. In practice, this is a lot of
69code/data, much of which is subject to change from boot to boot
70(e.g. changing NICs may change option ROMs). Without reference
71hashes, these measurement changes are difficult to assess or
72confirm as benign. This process also does not provide DMA
73protection, memory configuration/alias checks and locks, crash
74protection, or policy support.
75
76By using the hardware-based root of trust that Intel TXT provides,
77many of these issues can be mitigated. Specifically: many
78pre-launch components can be removed from the trust chain, DMA
79protection is provided to all launched components, a large number
80of platform configuration checks are performed and values locked,
81protection is provided for any data in the event of an improper
82shutdown, and there is support for policy-based execution/verification.
83This provides a more stable measurement and a higher assurance of
84system configuration and initial state than would be otherwise
85possible. Since the tboot project is open source, source code for
86almost all parts of the trust chain is available (excepting SMM and
87Intel-provided firmware).
88
89How Does it Work?
90=================
91
92o Tboot is an executable that is launched by the bootloader as
93 the "kernel" (the binary the bootloader executes).
94o It performs all of the work necessary to determine if the
95 platform supports Intel TXT and, if so, executes the GETSEC[SENTER]
96 processor instruction that initiates the dynamic root of trust.
97 - If tboot determines that the system does not support Intel TXT
98 or is not configured correctly (e.g. the SINIT AC Module was
99 incorrect), it will directly launch the kernel with no changes
100 to any state.
101 - Tboot will output various information about its progress to the
102 terminal, serial port, and/or an in-memory log; the output
103 locations can be configured with a command line switch.
104o The GETSEC[SENTER] instruction will return control to tboot and
105 tboot then verifies certain aspects of the environment (e.g. TPM NV
106 lock, e820 table does not have invalid entries, etc.).
107o It will wake the APs from the special sleep state the GETSEC[SENTER]
108 instruction had put them in and place them into a wait-for-SIPI
109 state.
110 - Because the processors will not respond to an INIT or SIPI when
111 in the TXT environment, it is necessary to create a small VT-x
112 guest for the APs. When they run in this guest, they will
113 simply wait for the INIT-SIPI-SIPI sequence, which will cause
114 VMEXITs, and then disable VT and jump to the SIPI vector. This
115 approach seemed like a better choice than having to insert
116 special code into the kernel's MP wakeup sequence.
117o Tboot then applies an (optional) user-defined launch policy to
118 verify the kernel and initrd.
119 - This policy is rooted in TPM NV and is described in the tboot
120 project. The tboot project also contains code for tools to
121 create and provision the policy.
122 - Policies are completely under user control and if not present
123 then any kernel will be launched.
124 - Policy action is flexible and can include halting on failures
125 or simply logging them and continuing.
126o Tboot adjusts the e820 table provided by the bootloader to reserve
127 its own location in memory as well as to reserve certain other
128 TXT-related regions.
129o As part of it's launch, tboot DMA protects all of RAM (using the
130 VT-d PMRs). Thus, the kernel must be booted with 'intel_iommu=on'
131 in order to remove this blanket protection and use VT-d's
132 page-level protection.
133o Tboot will populate a shared page with some data about itself and
134 pass this to the Linux kernel as it transfers control.
135 - The location of the shared page is passed via the boot_params
136 struct as a physical address.
137o The kernel will look for the tboot shared page address and, if it
138 exists, map it.
139o As one of the checks/protections provided by TXT, it makes a copy
140 of the VT-d DMARs in a DMA-protected region of memory and verifies
141 them for correctness. The VT-d code will detect if the kernel was
142 launched with tboot and use this copy instead of the one in the
143 ACPI table.
144o At this point, tboot and TXT are out of the picture until a
145 shutdown (S<n>)
146o In order to put a system into any of the sleep states after a TXT
147 launch, TXT must first be exited. This is to prevent attacks that
148 attempt to crash the system to gain control on reboot and steal
149 data left in memory.
150 - The kernel will perform all of its sleep preparation and
151 populate the shared page with the ACPI data needed to put the
152 platform in the desired sleep state.
153 - Then the kernel jumps into tboot via the vector specified in the
154 shared page.
155 - Tboot will clean up the environment and disable TXT, then use the
156 kernel-provided ACPI information to actually place the platform
157 into the desired sleep state.
158 - In the case of S3, tboot will also register itself as the resume
159 vector. This is necessary because it must re-establish the
160 measured environment upon resume. Once the TXT environment
161 has been restored, it will restore the TPM PCRs and then
162 transfer control back to the kernel's S3 resume vector.
163 In order to preserve system integrity across S3, the kernel
164 provides tboot with a set of memory ranges (kernel
165 code/data/bss, S3 resume code, and AP trampoline) that tboot
166 will calculate a MAC (message authentication code) over and then
167 seal with the TPM. On resume and once the measured environment
168 has been re-established, tboot will re-calculate the MAC and
169 verify it against the sealed value. Tboot's policy determines
170 what happens if the verification fails.
171
172That's pretty much it for TXT support.
173
174
175Configuring the System:
176======================
177
178This code works with 32bit, 32bit PAE, and 64bit (x86_64) kernels.
179
180In BIOS, the user must enable: TPM, TXT, VT-x, VT-d. Not all BIOSes
181allow these to be individually enabled/disabled and the screens in
182which to find them are BIOS-specific.
183
184grub.conf needs to be modified as follows:
185 title Linux 2.6.29-tip w/ tboot
186 root (hd0,0)
187 kernel /tboot.gz logging=serial,vga,memory
188 module /vmlinuz-2.6.29-tip intel_iommu=on ro
189 root=LABEL=/ rhgb console=ttyS0,115200 3
190 module /initrd-2.6.29-tip.img
191 module /Q35_SINIT_17.BIN
192
193The kernel option for enabling Intel TXT support is found under the
194Security top-level menu and is called "Enable Intel(R) Trusted
195Execution Technology (TXT)". It is marked as EXPERIMENTAL and
196depends on the generic x86 support (to allow maximum flexibility in
197kernel build options), since the tboot code will detect whether the
198platform actually supports Intel TXT and thus whether any of the
199kernel code is executed.
200
201The Q35_SINIT_17.BIN file is what Intel TXT refers to as an
202Authenticated Code Module. It is specific to the chipset in the
203system and can also be found on the Trusted Boot site. It is an
204(unencrypted) module signed by Intel that is used as part of the
205DRTM process to verify and configure the system. It is signed
206because it operates at a higher privilege level in the system than
207any other macrocode and its correct operation is critical to the
208establishment of the DRTM. The process for determining the correct
209SINIT ACM for a system is documented in the SINIT-guide.txt file
210that is on the tboot SourceForge site under the SINIT ACM downloads.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 3a238644c811..4c12a290bee5 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1971,11 +1971,12 @@ and is between 256 and 4096 characters. It is defined in the file
1971 Format: { 0 | 1 } 1971 Format: { 0 | 1 }
1972 See arch/parisc/kernel/pdc_chassis.c 1972 See arch/parisc/kernel/pdc_chassis.c
1973 1973
1974 percpu_alloc= [X86] Select which percpu first chunk allocator to use. 1974 percpu_alloc= Select which percpu first chunk allocator to use.
1975 Allowed values are one of "lpage", "embed" and "4k". 1975 Currently supported values are "embed" and "page".
1976 See comments in arch/x86/kernel/setup_percpu.c for 1976 Archs may support subset or none of the selections.
1977 details on each allocator. This parameter is primarily 1977 See comments in mm/percpu.c for details on each
1978 for debugging and performance comparison. 1978 allocator. This parameter is primarily for debugging
1979 and performance comparison.
1979 1980
1980 pf. [PARIDE] 1981 pf. [PARIDE]
1981 See Documentation/blockdev/paride.txt. 1982 See Documentation/blockdev/paride.txt.
diff --git a/Documentation/vgaarbiter.txt b/Documentation/vgaarbiter.txt
new file mode 100644
index 000000000000..987f9b0a5ece
--- /dev/null
+++ b/Documentation/vgaarbiter.txt
@@ -0,0 +1,194 @@
1
2VGA Arbiter
3===========
4
5Graphic devices are accessed through ranges in I/O or memory space. While most
6modern devices allow relocation of such ranges, some "Legacy" VGA devices
7implemented on PCI will typically have the same "hard-decoded" addresses as
8they did on ISA. For more details see "PCI Bus Binding to IEEE Std 1275-1994
9Standard for Boot (Initialization Configuration) Firmware Revision 2.1"
10Section 7, Legacy Devices.
11
12The Resource Access Control (RAC) module inside the X server [0] existed for
13the legacy VGA arbitration task (besides other bus management tasks) when more
14than one legacy device co-exists on the same machine. But the problem happens
15when these devices are trying to be accessed by different userspace clients
16(e.g. two server in parallel). Their address assignments conflict. Moreover,
17ideally, being an userspace application, it is not the role of the the X
18server to control bus resources. Therefore an arbitration scheme outside of
19the X server is needed to control the sharing of these resources. This
20document introduces the operation of the VGA arbiter implemented for Linux
21kernel.
22
23----------------------------------------------------------------------------
24
25I. Details and Theory of Operation
26 I.1 vgaarb
27 I.2 libpciaccess
28 I.3 xf86VGAArbiter (X server implementation)
29II. Credits
30III.References
31
32
33I. Details and Theory of Operation
34==================================
35
36I.1 vgaarb
37----------
38
39The vgaarb is a module of the Linux Kernel. When it is initially loaded, it
40scans all PCI devices and adds the VGA ones inside the arbitration. The
41arbiter then enables/disables the decoding on different devices of the VGA
42legacy instructions. Device which do not want/need to use the arbiter may
43explicitly tell it by calling vga_set_legacy_decoding().
44
45The kernel exports a char device interface (/dev/vga_arbiter) to the clients,
46which has the following semantics:
47
48 open : open user instance of the arbiter. By default, it's attached to
49 the default VGA device of the system.
50
51 close : close user instance. Release locks made by the user
52
53 read : return a string indicating the status of the target like:
54
55 "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)"
56
57 An IO state string is of the form {io,mem,io+mem,none}, mc and
58 ic are respectively mem and io lock counts (for debugging/
59 diagnostic only). "decodes" indicate what the card currently
60 decodes, "owns" indicates what is currently enabled on it, and
61 "locks" indicates what is locked by this card. If the card is
62 unplugged, we get "invalid" then for card_ID and an -ENODEV
63 error is returned for any command until a new card is targeted.
64
65
66 write : write a command to the arbiter. List of commands:
67
68 target <card_ID> : switch target to card <card_ID> (see below)
69 lock <io_state> : acquires locks on target ("none" is an invalid io_state)
70 trylock <io_state> : non-blocking acquire locks on target (returns EBUSY if
71 unsuccessful)
72 unlock <io_state> : release locks on target
73 unlock all : release all locks on target held by this user (not
74 implemented yet)
75 decodes <io_state> : set the legacy decoding attributes for the card
76
77 poll : event if something changes on any card (not just the
78 target)
79
80 card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default"
81 to go back to the system default card (TODO: not implemented yet). Currently,
82 only PCI is supported as a prefix, but the userland API may support other bus
83 types in the future, even if the current kernel implementation doesn't.
84
85Note about locks:
86
87The driver keeps track of which user has which locks on which card. It
88supports stacking, like the kernel one. This complexifies the implementation
89a bit, but makes the arbiter more tolerant to user space problems and able
90to properly cleanup in all cases when a process dies.
91Currently, a max of 16 cards can have locks simultaneously issued from
92user space for a given user (file descriptor instance) of the arbiter.
93
94In the case of devices hot-{un,}plugged, there is a hook - pci_notify() - to
95notify them being added/removed in the system and automatically added/removed
96in the arbiter.
97
98There's also a in-kernel API of the arbiter in the case of DRM, vgacon and
99others which may use the arbiter.
100
101
102I.2 libpciaccess
103----------------
104
105To use the vga arbiter char device it was implemented an API inside the
106libpciaccess library. One fieldd was added to struct pci_device (each device
107on the system):
108
109 /* the type of resource decoded by the device */
110 int vgaarb_rsrc;
111
112Besides it, in pci_system were added:
113
114 int vgaarb_fd;
115 int vga_count;
116 struct pci_device *vga_target;
117 struct pci_device *vga_default_dev;
118
119
120The vga_count is usually need to keep informed how many cards are being
121arbitrated, so for instance if there's only one then it can totally escape the
122scheme.
123
124
125These functions below acquire VGA resources for the given card and mark those
126resources as locked. If the resources requested are "normal" (and not legacy)
127resources, the arbiter will first check whether the card is doing legacy
128decoding for that type of resource. If yes, the lock is "converted" into a
129legacy resource lock. The arbiter will first look for all VGA cards that
130might conflict and disable their IOs and/or Memory access, including VGA
131forwarding on P2P bridges if necessary, so that the requested resources can
132be used. Then, the card is marked as locking these resources and the IO and/or
133Memory access is enabled on the card (including VGA forwarding on parent
134P2P bridges if any). In the case of vga_arb_lock(), the function will block
135if some conflicting card is already locking one of the required resources (or
136any resource on a different bus segment, since P2P bridges don't differentiate
137VGA memory and IO afaik). If the card already owns the resources, the function
138succeeds. vga_arb_trylock() will return (-EBUSY) instead of blocking. Nested
139calls are supported (a per-resource counter is maintained).
140
141
142Set the target device of this client.
143 int pci_device_vgaarb_set_target (struct pci_device *dev);
144
145
146For instance, in x86 if two devices on the same bus want to lock different
147resources, both will succeed (lock). If devices are in different buses and
148trying to lock different resources, only the first who tried succeeds.
149 int pci_device_vgaarb_lock (void);
150 int pci_device_vgaarb_trylock (void);
151
152Unlock resources of device.
153 int pci_device_vgaarb_unlock (void);
154
155Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA
156Memory, both, or none. All cards default to both, the card driver (fbdev for
157example) should tell the arbiter if it has disabled legacy decoding, so the
158card can be left out of the arbitration process (and can be safe to take
159interrupts at any time.
160 int pci_device_vgaarb_decodes (int new_vgaarb_rsrc);
161
162Connects to the arbiter device, allocates the struct
163 int pci_device_vgaarb_init (void);
164
165Close the connection
166 void pci_device_vgaarb_fini (void);
167
168
169I.3 xf86VGAArbiter (X server implementation)
170--------------------------------------------
171
172(TODO)
173
174X server basically wraps all the functions that touch VGA registers somehow.
175
176
177II. Credits
178===========
179
180Benjamin Herrenschmidt (IBM?) started this work when he discussed such design
181with the Xorg community in 2005 [1, 2]. In the end of 2007, Paulo Zanoni and
182Tiago Vignatti (both of C3SL/Federal University of Paraná) proceeded his work
183enhancing the kernel code to adapt as a kernel module and also did the
184implementation of the user space side [3]. Now (2009) Tiago Vignatti and Dave
185Airlie finally put this work in shape and queued to Jesse Barnes' PCI tree.
186
187
188III. References
189==============
190
191[0] http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347
192[1] http://lists.freedesktop.org/archives/xorg/2005-March/006663.html
193[2] http://lists.freedesktop.org/archives/xorg/2005-March/006745.html
194[3] http://lists.freedesktop.org/archives/xorg/2007-October/029507.html
diff --git a/Documentation/video4linux/CARDLIST.cx23885 b/Documentation/video4linux/CARDLIST.cx23885
index 450b8f8c389b..525edb37c758 100644
--- a/Documentation/video4linux/CARDLIST.cx23885
+++ b/Documentation/video4linux/CARDLIST.cx23885
@@ -21,3 +21,5 @@
21 20 -> Hauppauge WinTV-HVR1255 [0070:2251] 21 20 -> Hauppauge WinTV-HVR1255 [0070:2251]
22 21 -> Hauppauge WinTV-HVR1210 [0070:2291,0070:2295] 22 21 -> Hauppauge WinTV-HVR1210 [0070:2291,0070:2295]
23 22 -> Mygica X8506 DMB-TH [14f1:8651] 23 22 -> Mygica X8506 DMB-TH [14f1:8651]
24 23 -> Magic-Pro ProHDTV Extreme 2 [14f1:8657]
25 24 -> Hauppauge WinTV-HVR1850 [0070:8541]
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88
index 0736518b2f88..3385f8b094a5 100644
--- a/Documentation/video4linux/CARDLIST.cx88
+++ b/Documentation/video4linux/CARDLIST.cx88
@@ -80,3 +80,4 @@
80 79 -> Terratec Cinergy HT PCI MKII [153b:1177] 80 79 -> Terratec Cinergy HT PCI MKII [153b:1177]
81 80 -> Hauppauge WinTV-IR Only [0070:9290] 81 80 -> Hauppauge WinTV-IR Only [0070:9290]
82 81 -> Leadtek WinFast DTV1800 Hybrid [107d:6654] 82 81 -> Leadtek WinFast DTV1800 Hybrid [107d:6654]
83 82 -> WinFast DTV2000 H rev. J [107d:6f2b]
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index e352d754875c..b13fcbd5d94b 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -7,7 +7,7 @@
7 6 -> Terratec Cinergy 200 USB (em2800) 7 6 -> Terratec Cinergy 200 USB (em2800)
8 7 -> Leadtek Winfast USB II (em2800) [0413:6023] 8 7 -> Leadtek Winfast USB II (em2800) [0413:6023]
9 8 -> Kworld USB2800 (em2800) 9 8 -> Kworld USB2800 (em2800)
10 9 -> Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker (em2820/em2840) [1b80:e302,2304:0207,2304:021a] 10 9 -> Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker (em2820/em2840) [1b80:e302,1b80:e304,2304:0207,2304:021a]
11 10 -> Hauppauge WinTV HVR 900 (em2880) [2040:6500] 11 10 -> Hauppauge WinTV HVR 900 (em2880) [2040:6500]
12 11 -> Terratec Hybrid XS (em2880) [0ccd:0042] 12 11 -> Terratec Hybrid XS (em2880) [0ccd:0042]
13 12 -> Kworld PVR TV 2800 RF (em2820/em2840) 13 12 -> Kworld PVR TV 2800 RF (em2820/em2840)
@@ -33,7 +33,7 @@
33 34 -> Terratec Cinergy A Hybrid XS (em2860) [0ccd:004f] 33 34 -> Terratec Cinergy A Hybrid XS (em2860) [0ccd:004f]
34 35 -> Typhoon DVD Maker (em2860) 34 35 -> Typhoon DVD Maker (em2860)
35 36 -> NetGMBH Cam (em2860) 35 36 -> NetGMBH Cam (em2860)
36 37 -> Gadmei UTV330 (em2860) 36 37 -> Gadmei UTV330 (em2860) [eb1a:50a6]
37 38 -> Yakumo MovieMixer (em2861) 37 38 -> Yakumo MovieMixer (em2861)
38 39 -> KWorld PVRTV 300U (em2861) [eb1a:e300] 38 39 -> KWorld PVRTV 300U (em2861) [eb1a:e300]
39 40 -> Plextor ConvertX PX-TV100U (em2861) [093b:a005] 39 40 -> Plextor ConvertX PX-TV100U (em2861) [093b:a005]
@@ -67,3 +67,4 @@
67 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313] 67 69 -> KWorld ATSC 315U HDTV TV Box (em2882) [eb1a:a313]
68 70 -> Evga inDtube (em2882) 68 70 -> Evga inDtube (em2882)
69 71 -> Silvercrest Webcam 1.3mpix (em2820/em2840) 69 71 -> Silvercrest Webcam 1.3mpix (em2820/em2840)
70 72 -> Gadmei UTV330+ (em2861)
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index c913e5614195..0ac4d2544778 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -167,3 +167,7 @@
167166 -> Beholder BeholdTV 607 RDS [5ace:6073] 167166 -> Beholder BeholdTV 607 RDS [5ace:6073]
168167 -> Beholder BeholdTV 609 RDS [5ace:6092] 168167 -> Beholder BeholdTV 609 RDS [5ace:6092]
169168 -> Beholder BeholdTV 609 RDS [5ace:6093] 169168 -> Beholder BeholdTV 609 RDS [5ace:6093]
170169 -> Compro VideoMate S350/S300 [185b:c900]
171170 -> AverMedia AverTV Studio 505 [1461:a115]
172171 -> Beholder BeholdTV X7 [5ace:7595]
173172 -> RoverMedia TV Link Pro FM [19d1:0138]
diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner
index be67844074dd..ba9fa679e2d3 100644
--- a/Documentation/video4linux/CARDLIST.tuner
+++ b/Documentation/video4linux/CARDLIST.tuner
@@ -78,3 +78,4 @@ tuner=77 - TCL tuner MF02GIP-5N-E
78tuner=78 - Philips FMD1216MEX MK3 Hybrid Tuner 78tuner=78 - Philips FMD1216MEX MK3 Hybrid Tuner
79tuner=79 - Philips PAL/SECAM multi (FM1216 MK5) 79tuner=79 - Philips PAL/SECAM multi (FM1216 MK5)
80tuner=80 - Philips FQ1216LME MK3 PAL/SECAM w/active loopthrough 80tuner=80 - Philips FQ1216LME MK3 PAL/SECAM w/active loopthrough
81tuner=81 - Partsnic (Daewoo) PTI-5NF05
diff --git a/Documentation/video4linux/CQcam.txt b/Documentation/video4linux/CQcam.txt
index 04986efb731c..d230878e473e 100644
--- a/Documentation/video4linux/CQcam.txt
+++ b/Documentation/video4linux/CQcam.txt
@@ -18,8 +18,8 @@ Table of Contents
18 18
191.0 Introduction 191.0 Introduction
20 20
21 The file ../drivers/char/c-qcam.c is a device driver for the 21 The file ../../drivers/media/video/c-qcam.c is a device driver for
22Logitech (nee Connectix) parallel port interface color CCD camera. 22the Logitech (nee Connectix) parallel port interface color CCD camera.
23This is a fairly inexpensive device for capturing images. Logitech 23This is a fairly inexpensive device for capturing images. Logitech
24does not currently provide information for developers, but many people 24does not currently provide information for developers, but many people
25have engineered several solutions for non-Microsoft use of the Color 25have engineered several solutions for non-Microsoft use of the Color
diff --git a/Documentation/video4linux/gspca.txt b/Documentation/video4linux/gspca.txt
index 573f95b58807..4686e84dd800 100644
--- a/Documentation/video4linux/gspca.txt
+++ b/Documentation/video4linux/gspca.txt
@@ -140,6 +140,7 @@ spca500 04fc:7333 PalmPixDC85
140sunplus 04fc:ffff Pure DigitalDakota 140sunplus 04fc:ffff Pure DigitalDakota
141spca501 0506:00df 3Com HomeConnect Lite 141spca501 0506:00df 3Com HomeConnect Lite
142sunplus 052b:1513 Megapix V4 142sunplus 052b:1513 Megapix V4
143sunplus 052b:1803 MegaImage VI
143tv8532 0545:808b Veo Stingray 144tv8532 0545:808b Veo Stingray
144tv8532 0545:8333 Veo Stingray 145tv8532 0545:8333 Veo Stingray
145sunplus 0546:3155 Polaroid PDC3070 146sunplus 0546:3155 Polaroid PDC3070
@@ -182,6 +183,7 @@ ov534 06f8:3002 Hercules Blog Webcam
182ov534 06f8:3003 Hercules Dualpix HD Weblog 183ov534 06f8:3003 Hercules Dualpix HD Weblog
183sonixj 06f8:3004 Hercules Classic Silver 184sonixj 06f8:3004 Hercules Classic Silver
184sonixj 06f8:3008 Hercules Deluxe Optical Glass 185sonixj 06f8:3008 Hercules Deluxe Optical Glass
186pac7311 06f8:3009 Hercules Classic Link
185spca508 0733:0110 ViewQuest VQ110 187spca508 0733:0110 ViewQuest VQ110
186spca508 0130:0130 Clone Digital Webcam 11043 188spca508 0130:0130 Clone Digital Webcam 11043
187spca501 0733:0401 Intel Create and Share 189spca501 0733:0401 Intel Create and Share
@@ -235,8 +237,10 @@ pac7311 093a:2621 PAC731x
235pac7311 093a:2622 Genius Eye 312 237pac7311 093a:2622 Genius Eye 312
236pac7311 093a:2624 PAC7302 238pac7311 093a:2624 PAC7302
237pac7311 093a:2626 Labtec 2200 239pac7311 093a:2626 Labtec 2200
240pac7311 093a:2629 Genious iSlim 300
238pac7311 093a:262a Webcam 300k 241pac7311 093a:262a Webcam 300k
239pac7311 093a:262c Philips SPC 230 NC 242pac7311 093a:262c Philips SPC 230 NC
243jeilinj 0979:0280 Sakar 57379
240zc3xx 0ac8:0302 Z-star Vimicro zc0302 244zc3xx 0ac8:0302 Z-star Vimicro zc0302
241vc032x 0ac8:0321 Vimicro generic vc0321 245vc032x 0ac8:0321 Vimicro generic vc0321
242vc032x 0ac8:0323 Vimicro Vc0323 246vc032x 0ac8:0323 Vimicro Vc0323
@@ -247,6 +251,7 @@ zc3xx 0ac8:305b Z-star Vimicro zc0305b
247zc3xx 0ac8:307b Ldlc VC302+Ov7620 251zc3xx 0ac8:307b Ldlc VC302+Ov7620
248vc032x 0ac8:c001 Sony embedded vimicro 252vc032x 0ac8:c001 Sony embedded vimicro
249vc032x 0ac8:c002 Sony embedded vimicro 253vc032x 0ac8:c002 Sony embedded vimicro
254vc032x 0ac8:c301 Samsung Q1 Ultra Premium
250spca508 0af9:0010 Hama USB Sightcam 100 255spca508 0af9:0010 Hama USB Sightcam 100
251spca508 0af9:0011 Hama USB Sightcam 100 256spca508 0af9:0011 Hama USB Sightcam 100
252sonixb 0c45:6001 Genius VideoCAM NB 257sonixb 0c45:6001 Genius VideoCAM NB
@@ -284,6 +289,7 @@ sonixj 0c45:613a Microdia Sonix PC Camera
284sonixj 0c45:613b Surfer SN-206 289sonixj 0c45:613b Surfer SN-206
285sonixj 0c45:613c Sonix Pccam168 290sonixj 0c45:613c Sonix Pccam168
286sonixj 0c45:6143 Sonix Pccam168 291sonixj 0c45:6143 Sonix Pccam168
292sonixj 0c45:6148 Digitus DA-70811/ZSMC USB PC Camera ZS211/Microdia
287sn9c20x 0c45:6240 PC Camera (SN9C201 + MT9M001) 293sn9c20x 0c45:6240 PC Camera (SN9C201 + MT9M001)
288sn9c20x 0c45:6242 PC Camera (SN9C201 + MT9M111) 294sn9c20x 0c45:6242 PC Camera (SN9C201 + MT9M111)
289sn9c20x 0c45:6248 PC Camera (SN9C201 + OV9655) 295sn9c20x 0c45:6248 PC Camera (SN9C201 + OV9655)
diff --git a/Documentation/video4linux/si4713.txt b/Documentation/video4linux/si4713.txt
new file mode 100644
index 000000000000..25abdb78209d
--- /dev/null
+++ b/Documentation/video4linux/si4713.txt
@@ -0,0 +1,176 @@
1Driver for I2C radios for the Silicon Labs Si4713 FM Radio Transmitters
2
3Copyright (c) 2009 Nokia Corporation
4Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
5
6
7Information about the Device
8============================
9This chip is a Silicon Labs product. It is a I2C device, currently on 0x63 address.
10Basically, it has transmission and signal noise level measurement features.
11
12The Si4713 integrates transmit functions for FM broadcast stereo transmission.
13The chip also allows integrated receive power scanning to identify low signal
14power FM channels.
15
16The chip is programmed using commands and responses. There are also several
17properties which can change the behavior of this chip.
18
19Users must comply with local regulations on radio frequency (RF) transmission.
20
21Device driver description
22=========================
23There are two modules to handle this device. One is a I2C device driver
24and the other is a platform driver.
25
26The I2C device driver exports a v4l2-subdev interface to the kernel.
27All properties can also be accessed by v4l2 extended controls interface, by
28using the v4l2-subdev calls (g_ext_ctrls, s_ext_ctrls).
29
30The platform device driver exports a v4l2 radio device interface to user land.
31So, it uses the I2C device driver as a sub device in order to send the user
32commands to the actual device. Basically it is a wrapper to the I2C device driver.
33
34Applications can use v4l2 radio API to specify frequency of operation, mute state,
35etc. But mostly of its properties will be present in the extended controls.
36
37When the v4l2 mute property is set to 1 (true), the driver will turn the chip off.
38
39Properties description
40======================
41
42The properties can be accessed using v4l2 extended controls.
43Here is an output from v4l2-ctl util:
44/ # v4l2-ctl -d /dev/radio0 --all -L
45Driver Info:
46 Driver name : radio-si4713
47 Card type : Silicon Labs Si4713 Modulator
48 Bus info :
49 Driver version: 0
50 Capabilities : 0x00080800
51 RDS Output
52 Modulator
53Audio output: 0 (FM Modulator Audio Out)
54Frequency: 1408000 (88.000000 MHz)
55Video Standard = 0x00000000
56Modulator:
57 Name : FM Modulator
58 Capabilities : 62.5 Hz stereo rds
59 Frequency range : 76.0 MHz - 108.0 MHz
60 Subchannel modulation: stereo+rds
61
62User Controls
63
64 mute (bool) : default=1 value=0
65
66FM Radio Modulator Controls
67
68 rds_signal_deviation (int) : min=0 max=90000 step=10 default=200 value=200 flags=slider
69 rds_program_id (int) : min=0 max=65535 step=1 default=0 value=0
70 rds_program_type (int) : min=0 max=31 step=1 default=0 value=0
71 rds_ps_name (str) : min=0 max=96 step=8 value='si4713 '
72 rds_radio_text (str) : min=0 max=384 step=32 value=''
73 audio_limiter_feature_enabled (bool) : default=1 value=1
74 audio_limiter_release_time (int) : min=250 max=102390 step=50 default=5010 value=5010 flags=slider
75 audio_limiter_deviation (int) : min=0 max=90000 step=10 default=66250 value=66250 flags=slider
76audio_compression_feature_enabl (bool) : default=1 value=1
77 audio_compression_gain (int) : min=0 max=20 step=1 default=15 value=15 flags=slider
78 audio_compression_threshold (int) : min=-40 max=0 step=1 default=-40 value=-40 flags=slider
79 audio_compression_attack_time (int) : min=0 max=5000 step=500 default=0 value=0 flags=slider
80 audio_compression_release_time (int) : min=100000 max=1000000 step=100000 default=1000000 value=1000000 flags=slider
81 pilot_tone_feature_enabled (bool) : default=1 value=1
82 pilot_tone_deviation (int) : min=0 max=90000 step=10 default=6750 value=6750 flags=slider
83 pilot_tone_frequency (int) : min=0 max=19000 step=1 default=19000 value=19000 flags=slider
84 pre_emphasis_settings (menu) : min=0 max=2 default=1 value=1
85 tune_power_level (int) : min=0 max=120 step=1 default=88 value=88 flags=slider
86 tune_antenna_capacitor (int) : min=0 max=191 step=1 default=0 value=110 flags=slider
87/ #
88
89Here is a summary of them:
90
91* Pilot is an audible tone sent by the device.
92
93pilot_frequency - Configures the frequency of the stereo pilot tone.
94pilot_deviation - Configures pilot tone frequency deviation level.
95pilot_enabled - Enables or disables the pilot tone feature.
96
97* The si4713 device is capable of applying audio compression to the transmitted signal.
98
99acomp_enabled - Enables or disables the audio dynamic range control feature.
100acomp_gain - Sets the gain for audio dynamic range control.
101acomp_threshold - Sets the threshold level for audio dynamic range control.
102acomp_attack_time - Sets the attack time for audio dynamic range control.
103acomp_release_time - Sets the release time for audio dynamic range control.
104
105* Limiter setups audio deviation limiter feature. Once a over deviation occurs,
106it is possible to adjust the front-end gain of the audio input and always
107prevent over deviation.
108
109limiter_enabled - Enables or disables the limiter feature.
110limiter_deviation - Configures audio frequency deviation level.
111limiter_release_time - Sets the limiter release time.
112
113* Tuning power
114
115power_level - Sets the output power level for signal transmission.
116antenna_capacitor - This selects the value of antenna tuning capacitor manually
117or automatically if set to zero.
118
119* RDS related
120
121rds_ps_name - Sets the RDS ps name field for transmission.
122rds_radio_text - Sets the RDS radio text for transmission.
123rds_pi - Sets the RDS PI field for transmission.
124rds_pty - Sets the RDS PTY field for transmission.
125
126* Region related
127
128preemphasis - sets the preemphasis to be applied for transmission.
129
130RNL
131===
132
133This device also has an interface to measure received noise level. To do that, you should
134ioctl the device node. Here is an code of example:
135
136int main (int argc, char *argv[])
137{
138 struct si4713_rnl rnl;
139 int fd = open("/dev/radio0", O_RDWR);
140 int rval;
141
142 if (argc < 2)
143 return -EINVAL;
144
145 if (fd < 0)
146 return fd;
147
148 sscanf(argv[1], "%d", &rnl.frequency);
149
150 rval = ioctl(fd, SI4713_IOC_MEASURE_RNL, &rnl);
151 if (rval < 0)
152 return rval;
153
154 printf("received noise level: %d\n", rnl.rnl);
155
156 close(fd);
157}
158
159The struct si4713_rnl and SI4713_IOC_MEASURE_RNL are defined under
160include/media/si4713.h.
161
162Stereo/Mono and RDS subchannels
163===============================
164
165The device can also be configured using the available sub channels for
166transmission. To do that use S/G_MODULATOR ioctl and configure txsubchans properly.
167Refer to v4l2-spec for proper use of this ioctl.
168
169Testing
170=======
171Testing is usually done with v4l2-ctl utility for managing FM tuner cards.
172The tool can be found in v4l-dvb repository under v4l2-apps/util directory.
173
174Example for setting rds ps name:
175# v4l2-ctl -d /dev/radio0 --set-ctrl=rds_ps_name="Dummy"
176
diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt
index 4f913857b8a2..feb37e177010 100644
--- a/Documentation/x86/zero-page.txt
+++ b/Documentation/x86/zero-page.txt
@@ -12,6 +12,7 @@ Offset Proto Name Meaning
12000/040 ALL screen_info Text mode or frame buffer information 12000/040 ALL screen_info Text mode or frame buffer information
13 (struct screen_info) 13 (struct screen_info)
14040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info) 14040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info)
15058/008 ALL tboot_addr Physical address of tboot shared page
15060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information 16060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information
16 (struct ist_info) 17 (struct ist_info)
17080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!! 18080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!!
diff --git a/MAINTAINERS b/MAINTAINERS
index 837b5985ac40..64b9e447545c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3317,7 +3317,7 @@ S: Supported
3317F: drivers/net/wireless/mwl8k.c 3317F: drivers/net/wireless/mwl8k.c
3318 3318
3319MARVELL SOC MMC/SD/SDIO CONTROLLER DRIVER 3319MARVELL SOC MMC/SD/SDIO CONTROLLER DRIVER
3320M: Nicolas Pitre <nico@cam.org> 3320M: Nicolas Pitre <nico@fluxnic.net>
3321S: Maintained 3321S: Maintained
3322 3322
3323MARVELL YUKON / SYSKONNECT DRIVER 3323MARVELL YUKON / SYSKONNECT DRIVER
@@ -4689,7 +4689,7 @@ F: include/linux/sl?b*.h
4689F: mm/sl?b.c 4689F: mm/sl?b.c
4690 4690
4691SMC91x ETHERNET DRIVER 4691SMC91x ETHERNET DRIVER
4692M: Nicolas Pitre <nico@cam.org> 4692M: Nicolas Pitre <nico@fluxnic.net>
4693S: Maintained 4693S: Maintained
4694F: drivers/net/smc91x.* 4694F: drivers/net/smc91x.*
4695 4695
diff --git a/Makefile b/Makefile
index 60de4ef31254..433493a2b77b 100644
--- a/Makefile
+++ b/Makefile
@@ -325,7 +325,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
325MODFLAGS = -DMODULE 325MODFLAGS = -DMODULE
326CFLAGS_MODULE = $(MODFLAGS) 326CFLAGS_MODULE = $(MODFLAGS)
327AFLAGS_MODULE = $(MODFLAGS) 327AFLAGS_MODULE = $(MODFLAGS)
328LDFLAGS_MODULE = 328LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds
329CFLAGS_KERNEL = 329CFLAGS_KERNEL =
330AFLAGS_KERNEL = 330AFLAGS_KERNEL =
331CFLAGS_GCOV = -fprofile-arcs -ftest-coverage 331CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
diff --git a/arch/alpha/include/asm/agp.h b/arch/alpha/include/asm/agp.h
index 26c179135293..a94d48b8677f 100644
--- a/arch/alpha/include/asm/agp.h
+++ b/arch/alpha/include/asm/agp.h
@@ -9,10 +9,6 @@
9#define unmap_page_from_agp(page) 9#define unmap_page_from_agp(page)
10#define flush_agp_cache() mb() 10#define flush_agp_cache() mb()
11 11
12/* Convert a physical address to an address suitable for the GART. */
13#define phys_to_gart(x) (x)
14#define gart_to_phys(x) (x)
15
16/* GATT allocation. Returns/accepts GATT kernel virtual address. */ 12/* GATT allocation. Returns/accepts GATT kernel virtual address. */
17#define alloc_gatt_pages(order) \ 13#define alloc_gatt_pages(order) \
18 ((char *)__get_free_pages(GFP_KERNEL, (order))) 14 ((char *)__get_free_pages(GFP_KERNEL, (order)))
diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index d22ace99d13d..dd8dcabf160f 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -52,7 +52,6 @@ struct pci_controller {
52 bus numbers. */ 52 bus numbers. */
53 53
54#define pcibios_assign_all_busses() 1 54#define pcibios_assign_all_busses() 1
55#define pcibios_scan_all_fns(a, b) 0
56 55
57#define PCIBIOS_MIN_IO alpha_mv.min_io_address 56#define PCIBIOS_MIN_IO alpha_mv.min_io_address
58#define PCIBIOS_MIN_MEM alpha_mv.min_mem_address 57#define PCIBIOS_MIN_MEM alpha_mv.min_mem_address
diff --git a/arch/alpha/include/asm/percpu.h b/arch/alpha/include/asm/percpu.h
index b663f1f10b6a..2c12378e3aa9 100644
--- a/arch/alpha/include/asm/percpu.h
+++ b/arch/alpha/include/asm/percpu.h
@@ -1,102 +1,18 @@
1#ifndef __ALPHA_PERCPU_H 1#ifndef __ALPHA_PERCPU_H
2#define __ALPHA_PERCPU_H 2#define __ALPHA_PERCPU_H
3 3
4#include <linux/compiler.h>
5#include <linux/threads.h>
6#include <linux/percpu-defs.h>
7
8/*
9 * Determine the real variable name from the name visible in the
10 * kernel sources.
11 */
12#define per_cpu_var(var) per_cpu__##var
13
14#ifdef CONFIG_SMP
15
16/*
17 * per_cpu_offset() is the offset that has to be added to a
18 * percpu variable to get to the instance for a certain processor.
19 */
20extern unsigned long __per_cpu_offset[NR_CPUS];
21
22#define per_cpu_offset(x) (__per_cpu_offset[x])
23
24#define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
25#ifdef CONFIG_DEBUG_PREEMPT
26#define my_cpu_offset per_cpu_offset(smp_processor_id())
27#else
28#define my_cpu_offset __my_cpu_offset
29#endif
30
31#ifndef MODULE
32#define SHIFT_PERCPU_PTR(var, offset) RELOC_HIDE(&per_cpu_var(var), (offset))
33#define PER_CPU_DEF_ATTRIBUTES
34#else
35/* 4/*
36 * To calculate addresses of locally defined variables, GCC uses 32-bit 5 * To calculate addresses of locally defined variables, GCC uses
37 * displacement from the GP. Which doesn't work for per cpu variables in 6 * 32-bit displacement from the GP. Which doesn't work for per cpu
38 * modules, as an offset to the kernel per cpu area is way above 4G. 7 * variables in modules, as an offset to the kernel per cpu area is
8 * way above 4G.
39 * 9 *
40 * This forces allocation of a GOT entry for per cpu variable using 10 * Always use weak definitions for percpu variables in modules.
41 * ldq instruction with a 'literal' relocation.
42 */
43#define SHIFT_PERCPU_PTR(var, offset) ({ \
44 extern int simple_identifier_##var(void); \
45 unsigned long __ptr, tmp_gp; \
46 asm ( "br %1, 1f \n\
47 1: ldgp %1, 0(%1) \n\
48 ldq %0, per_cpu__" #var"(%1)\t!literal" \
49 : "=&r"(__ptr), "=&r"(tmp_gp)); \
50 (typeof(&per_cpu_var(var)))(__ptr + (offset)); })
51
52#define PER_CPU_DEF_ATTRIBUTES __used
53
54#endif /* MODULE */
55
56/*
57 * A percpu variable may point to a discarded regions. The following are
58 * established ways to produce a usable pointer from the percpu variable
59 * offset.
60 */ 11 */
61#define per_cpu(var, cpu) \ 12#if defined(MODULE) && defined(CONFIG_SMP)
62 (*SHIFT_PERCPU_PTR(var, per_cpu_offset(cpu))) 13#define ARCH_NEEDS_WEAK_PER_CPU
63#define __get_cpu_var(var) \
64 (*SHIFT_PERCPU_PTR(var, my_cpu_offset))
65#define __raw_get_cpu_var(var) \
66 (*SHIFT_PERCPU_PTR(var, __my_cpu_offset))
67
68#else /* ! SMP */
69
70#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu_var(var)))
71#define __get_cpu_var(var) per_cpu_var(var)
72#define __raw_get_cpu_var(var) per_cpu_var(var)
73
74#define PER_CPU_DEF_ATTRIBUTES
75
76#endif /* SMP */
77
78#ifdef CONFIG_SMP
79#define PER_CPU_BASE_SECTION ".data.percpu"
80#else
81#define PER_CPU_BASE_SECTION ".data"
82#endif
83
84#ifdef CONFIG_SMP
85
86#ifdef MODULE
87#define PER_CPU_SHARED_ALIGNED_SECTION ""
88#else
89#define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned"
90#endif
91#define PER_CPU_FIRST_SECTION ".first"
92
93#else
94
95#define PER_CPU_SHARED_ALIGNED_SECTION ""
96#define PER_CPU_FIRST_SECTION ""
97
98#endif 14#endif
99 15
100#define PER_CPU_ATTRIBUTES 16#include <asm-generic/percpu.h>
101 17
102#endif /* __ALPHA_PERCPU_H */ 18#endif /* __ALPHA_PERCPU_H */
diff --git a/arch/alpha/include/asm/tlbflush.h b/arch/alpha/include/asm/tlbflush.h
index 9d87aaa08c0d..e89e0c2e15b1 100644
--- a/arch/alpha/include/asm/tlbflush.h
+++ b/arch/alpha/include/asm/tlbflush.h
@@ -2,6 +2,7 @@
2#define _ALPHA_TLBFLUSH_H 2#define _ALPHA_TLBFLUSH_H
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/sched.h>
5#include <asm/compiler.h> 6#include <asm/compiler.h>
6#include <asm/pgalloc.h> 7#include <asm/pgalloc.h>
7 8
diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S
index b9d6568e5f7f..6dc03c35caa0 100644
--- a/arch/alpha/kernel/vmlinux.lds.S
+++ b/arch/alpha/kernel/vmlinux.lds.S
@@ -134,13 +134,6 @@ SECTIONS
134 __bss_stop = .; 134 __bss_stop = .;
135 _end = .; 135 _end = .;
136 136
137 /* Sections to be discarded */
138 /DISCARD/ : {
139 EXIT_TEXT
140 EXIT_DATA
141 *(.exitcall.exit)
142 }
143
144 .mdebug 0 : { 137 .mdebug 0 : {
145 *(.mdebug) 138 *(.mdebug)
146 } 139 }
@@ -150,4 +143,6 @@ SECTIONS
150 143
151 STABS_DEBUG 144 STABS_DEBUG
152 DWARF_DEBUG 145 DWARF_DEBUG
146
147 DISCARDS
153} 148}
diff --git a/arch/arm/boot/compressed/head-sa1100.S b/arch/arm/boot/compressed/head-sa1100.S
index 4c8c0e46027d..6179d94dd5c6 100644
--- a/arch/arm/boot/compressed/head-sa1100.S
+++ b/arch/arm/boot/compressed/head-sa1100.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/boot/compressed/head-sa1100.S 2 * linux/arch/arm/boot/compressed/head-sa1100.S
3 * 3 *
4 * Copyright (C) 1999 Nicolas Pitre <nico@cam.org> 4 * Copyright (C) 1999 Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * SA1100 specific tweaks. This is merged into head.S by the linker. 6 * SA1100 specific tweaks. This is merged into head.S by the linker.
7 * 7 *
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index 0abf386ba3d3..226cddd2fb65 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -6,8 +6,6 @@
6 6
7#include <mach/hardware.h> /* for PCIBIOS_MIN_* */ 7#include <mach/hardware.h> /* for PCIBIOS_MIN_* */
8 8
9#define pcibios_scan_all_fns(a, b) 0
10
11#ifdef CONFIG_PCI_HOST_ITE8152 9#ifdef CONFIG_PCI_HOST_ITE8152
12/* ITE bridge requires setting latency timer to avoid early bus access 10/* ITE bridge requires setting latency timer to avoid early bus access
13 termination by PIC bus mater devices 11 termination by PIC bus mater devices
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 69371028a202..5cc4812c9763 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -83,6 +83,7 @@ SECTIONS
83 EXIT_TEXT 83 EXIT_TEXT
84 EXIT_DATA 84 EXIT_DATA
85 *(.exitcall.exit) 85 *(.exitcall.exit)
86 *(.discard)
86 *(.ARM.exidx.exit.text) 87 *(.ARM.exidx.exit.text)
87 *(.ARM.extab.exit.text) 88 *(.ARM.extab.exit.text)
88#ifndef CONFIG_HOTPLUG_CPU 89#ifndef CONFIG_HOTPLUG_CPU
diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index 67964bcfc854..6dc06487f3c3 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines 2 * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines
3 * 3 *
4 * Author: Nicolas Pitre <nico@cam.org> 4 * Author: Nicolas Pitre <nico@fluxnic.net>
5 * - contributed to gcc-3.4 on Sep 30, 2003 5 * - contributed to gcc-3.4 on Sep 30, 2003
6 * - adapted for the Linux kernel on Oct 2, 2003 6 * - adapted for the Linux kernel on Oct 2, 2003
7 */ 7 */
diff --git a/arch/arm/lib/sha1.S b/arch/arm/lib/sha1.S
index 09b548cac1a4..eb0edb80d7b8 100644
--- a/arch/arm/lib/sha1.S
+++ b/arch/arm/lib/sha1.S
@@ -3,7 +3,7 @@
3 * 3 *
4 * SHA transform optimized for ARM 4 * SHA transform optimized for ARM
5 * 5 *
6 * Copyright: (C) 2005 by Nicolas Pitre <nico@cam.org> 6 * Copyright: (C) 2005 by Nicolas Pitre <nico@fluxnic.net>
7 * Created: September 17, 2005 7 * Created: September 17, 2005
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/arm/mach-sa1100/include/mach/assabet.h b/arch/arm/mach-sa1100/include/mach/assabet.h
index 3959b20d5d1c..28c2cf50c259 100644
--- a/arch/arm/mach-sa1100/include/mach/assabet.h
+++ b/arch/arm/mach-sa1100/include/mach/assabet.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/mach-sa1100/include/mach/assabet.h 2 * arch/arm/mach-sa1100/include/mach/assabet.h
3 * 3 *
4 * Created 2000/06/05 by Nicolas Pitre <nico@cam.org> 4 * Created 2000/06/05 by Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * This file contains the hardware specific definitions for Assabet 6 * This file contains the hardware specific definitions for Assabet
7 * Only include this file from SA1100-specific files. 7 * Only include this file from SA1100-specific files.
diff --git a/arch/arm/mach-sa1100/include/mach/hardware.h b/arch/arm/mach-sa1100/include/mach/hardware.h
index 60711822b125..99f5856d8de4 100644
--- a/arch/arm/mach-sa1100/include/mach/hardware.h
+++ b/arch/arm/mach-sa1100/include/mach/hardware.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/mach-sa1100/include/mach/hardware.h 2 * arch/arm/mach-sa1100/include/mach/hardware.h
3 * 3 *
4 * Copyright (C) 1998 Nicolas Pitre <nico@cam.org> 4 * Copyright (C) 1998 Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * This file contains the hardware definitions for SA1100 architecture 6 * This file contains the hardware definitions for SA1100 architecture
7 * 7 *
diff --git a/arch/arm/mach-sa1100/include/mach/memory.h b/arch/arm/mach-sa1100/include/mach/memory.h
index e9f8eed900f5..d5277f9bee77 100644
--- a/arch/arm/mach-sa1100/include/mach/memory.h
+++ b/arch/arm/mach-sa1100/include/mach/memory.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/mach-sa1100/include/mach/memory.h 2 * arch/arm/mach-sa1100/include/mach/memory.h
3 * 3 *
4 * Copyright (C) 1999-2000 Nicolas Pitre <nico@cam.org> 4 * Copyright (C) 1999-2000 Nicolas Pitre <nico@fluxnic.net>
5 */ 5 */
6 6
7#ifndef __ASM_ARCH_MEMORY_H 7#ifndef __ASM_ARCH_MEMORY_H
diff --git a/arch/arm/mach-sa1100/include/mach/neponset.h b/arch/arm/mach-sa1100/include/mach/neponset.h
index d3f044f92c00..ffe2bc45eed0 100644
--- a/arch/arm/mach-sa1100/include/mach/neponset.h
+++ b/arch/arm/mach-sa1100/include/mach/neponset.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/mach-sa1100/include/mach/neponset.h 2 * arch/arm/mach-sa1100/include/mach/neponset.h
3 * 3 *
4 * Created 2000/06/05 by Nicolas Pitre <nico@cam.org> 4 * Created 2000/06/05 by Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * This file contains the hardware specific definitions for Assabet 6 * This file contains the hardware specific definitions for Assabet
7 * Only include this file from SA1100-specific files. 7 * Only include this file from SA1100-specific files.
diff --git a/arch/arm/mach-sa1100/include/mach/system.h b/arch/arm/mach-sa1100/include/mach/system.h
index 942b153e251d..ba9da9f7f183 100644
--- a/arch/arm/mach-sa1100/include/mach/system.h
+++ b/arch/arm/mach-sa1100/include/mach/system.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/mach-sa1100/include/mach/system.h 2 * arch/arm/mach-sa1100/include/mach/system.h
3 * 3 *
4 * Copyright (c) 1999 Nicolas Pitre <nico@cam.org> 4 * Copyright (c) 1999 Nicolas Pitre <nico@fluxnic.net>
5 */ 5 */
6#include <mach/hardware.h> 6#include <mach/hardware.h>
7 7
diff --git a/arch/arm/mach-sa1100/include/mach/uncompress.h b/arch/arm/mach-sa1100/include/mach/uncompress.h
index 714160b03d7a..6cb39ddde656 100644
--- a/arch/arm/mach-sa1100/include/mach/uncompress.h
+++ b/arch/arm/mach-sa1100/include/mach/uncompress.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/mach-sa1100/include/mach/uncompress.h 2 * arch/arm/mach-sa1100/include/mach/uncompress.h
3 * 3 *
4 * (C) 1999 Nicolas Pitre <nico@cam.org> 4 * (C) 1999 Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * Reorganised to be machine independent. 6 * Reorganised to be machine independent.
7 */ 7 */
diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
index 111cce67ad2f..c83fdc80edfd 100644
--- a/arch/arm/mach-sa1100/pm.c
+++ b/arch/arm/mach-sa1100/pm.c
@@ -15,7 +15,7 @@
15 * Save more value for the resume function! Support 15 * Save more value for the resume function! Support
16 * Bitsy/Assabet/Freebird board 16 * Bitsy/Assabet/Freebird board
17 * 17 *
18 * 2001-08-29: Nicolas Pitre <nico@cam.org> 18 * 2001-08-29: Nicolas Pitre <nico@fluxnic.net>
19 * Cleaned up, pushed platform dependent stuff 19 * Cleaned up, pushed platform dependent stuff
20 * in the platform specific files. 20 * in the platform specific files.
21 * 21 *
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 711c0295c66f..95d92e8e56a8 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 1998 Deborah Wallach. 4 * Copyright (C) 1998 Deborah Wallach.
5 * Twiddles (C) 1999 Hugo Fiennes <hugo@empeg.com> 5 * Twiddles (C) 1999 Hugo Fiennes <hugo@empeg.com>
6 * 6 *
7 * 2000/03/29 (C) Nicolas Pitre <nico@cam.org> 7 * 2000/03/29 (C) Nicolas Pitre <nico@fluxnic.net>
8 * Rewritten: big cleanup, much simpler, better HZ accuracy. 8 * Rewritten: big cleanup, much simpler, better HZ accuracy.
9 * 9 *
10 */ 10 */
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 0cce37b93937..423394260bcb 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -17,7 +17,7 @@
17 * 17 *
18 * 2001 Sep 08: 18 * 2001 Sep 08:
19 * Completely revisited, many important fixes 19 * Completely revisited, many important fixes
20 * Nicolas Pitre <nico@cam.org> 20 * Nicolas Pitre <nico@fluxnic.net>
21 */ 21 */
22 22
23#include <linux/linkage.h> 23#include <linux/linkage.h>
diff --git a/arch/arm/plat-iop/setup.c b/arch/arm/plat-iop/setup.c
index 9e573e78176a..bade586fed0f 100644
--- a/arch/arm/plat-iop/setup.c
+++ b/arch/arm/plat-iop/setup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/arm/plat-iop/setup.c 2 * arch/arm/plat-iop/setup.c
3 * 3 *
4 * Author: Nicolas Pitre <nico@cam.org> 4 * Author: Nicolas Pitre <nico@fluxnic.net>
5 * Copyright (C) 2001 MontaVista Software, Inc. 5 * Copyright (C) 2001 MontaVista Software, Inc.
6 * Copyright (C) 2004 Intel Corporation. 6 * Copyright (C) 2004 Intel Corporation.
7 * 7 *
diff --git a/arch/arm/plat-omap/include/mach/system.h b/arch/arm/plat-omap/include/mach/system.h
index 1060e345423b..ed8ec7477261 100644
--- a/arch/arm/plat-omap/include/mach/system.h
+++ b/arch/arm/plat-omap/include/mach/system.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copied from arch/arm/mach-sa1100/include/mach/system.h 2 * Copied from arch/arm/mach-sa1100/include/mach/system.h
3 * Copyright (c) 1999 Nicolas Pitre <nico@cam.org> 3 * Copyright (c) 1999 Nicolas Pitre <nico@fluxnic.net>
4 */ 4 */
5#ifndef __ASM_ARCH_SYSTEM_H 5#ifndef __ASM_ARCH_SYSTEM_H
6#define __ASM_ARCH_SYSTEM_H 6#define __ASM_ARCH_SYSTEM_H
diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S
index 7910d41eb886..c4b56654349a 100644
--- a/arch/avr32/kernel/vmlinux.lds.S
+++ b/arch/avr32/kernel/vmlinux.lds.S
@@ -124,14 +124,11 @@ SECTIONS
124 _end = .; 124 _end = .;
125 } 125 }
126 126
127 DWARF_DEBUG
128
127 /* When something in the kernel is NOT compiled as a module, the module 129 /* When something in the kernel is NOT compiled as a module, the module
128 * cleanup code and data are put into these segments. Both can then be 130 * cleanup code and data are put into these segments. Both can then be
129 * thrown away, as cleanup code is never called unless it's a module. 131 * thrown away, as cleanup code is never called unless it's a module.
130 */ 132 */
131 /DISCARD/ : { 133 DISCARDS
132 EXIT_DATA
133 *(.exitcall.exit)
134 }
135
136 DWARF_DEBUG
137} 134}
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
index 6ac307ca0d80..d7ffe299b979 100644
--- a/arch/blackfin/kernel/vmlinux.lds.S
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -277,8 +277,5 @@ SECTIONS
277 277
278 DWARF_DEBUG 278 DWARF_DEBUG
279 279
280 /DISCARD/ : 280 DISCARDS
281 {
282 *(.exitcall.exit)
283 }
284} 281}
diff --git a/arch/blackfin/mm/sram-alloc.c b/arch/blackfin/mm/sram-alloc.c
index 0bc3c4ef0aad..99e4dbb1dfd1 100644
--- a/arch/blackfin/mm/sram-alloc.c
+++ b/arch/blackfin/mm/sram-alloc.c
@@ -42,9 +42,9 @@
42#include <asm/mem_map.h> 42#include <asm/mem_map.h>
43#include "blackfin_sram.h" 43#include "blackfin_sram.h"
44 44
45static DEFINE_PER_CPU(spinlock_t, l1sram_lock) ____cacheline_aligned_in_smp; 45static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1sram_lock);
46static DEFINE_PER_CPU(spinlock_t, l1_data_sram_lock) ____cacheline_aligned_in_smp; 46static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_data_sram_lock);
47static DEFINE_PER_CPU(spinlock_t, l1_inst_sram_lock) ____cacheline_aligned_in_smp; 47static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_inst_sram_lock);
48static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp; 48static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp;
49 49
50/* the data structure for L1 scratchpad and DATA SRAM */ 50/* the data structure for L1 scratchpad and DATA SRAM */
diff --git a/arch/cris/include/asm/mmu_context.h b/arch/cris/include/asm/mmu_context.h
index 72ba08dcfd18..1d45fd6365b7 100644
--- a/arch/cris/include/asm/mmu_context.h
+++ b/arch/cris/include/asm/mmu_context.h
@@ -17,7 +17,8 @@ extern void switch_mm(struct mm_struct *prev, struct mm_struct *next,
17 * registers like cr3 on the i386 17 * registers like cr3 on the i386
18 */ 18 */
19 19
20extern volatile DEFINE_PER_CPU(pgd_t *,current_pgd); /* defined in arch/cris/mm/fault.c */ 20/* defined in arch/cris/mm/fault.c */
21DECLARE_PER_CPU(pgd_t *, current_pgd);
21 22
22static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) 23static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
23{ 24{
diff --git a/arch/cris/kernel/vmlinux.lds.S b/arch/cris/kernel/vmlinux.lds.S
index 0d2adfc794d4..6c81836b9229 100644
--- a/arch/cris/kernel/vmlinux.lds.S
+++ b/arch/cris/kernel/vmlinux.lds.S
@@ -140,12 +140,7 @@ SECTIONS
140 _end = .; 140 _end = .;
141 __end = .; 141 __end = .;
142 142
143 /* Sections to be discarded */
144 /DISCARD/ : {
145 EXIT_TEXT
146 EXIT_DATA
147 *(.exitcall.exit)
148 }
149
150 dram_end = dram_start + (CONFIG_ETRAX_DRAM_SIZE - __CONFIG_ETRAX_VMEM_SIZE)*1024*1024; 143 dram_end = dram_start + (CONFIG_ETRAX_DRAM_SIZE - __CONFIG_ETRAX_VMEM_SIZE)*1024*1024;
144
145 DISCARDS
151} 146}
diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index f925115e3250..4a7cdd9ea1ee 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -29,7 +29,7 @@ extern void die_if_kernel(const char *, struct pt_regs *, long);
29 29
30/* current active page directory */ 30/* current active page directory */
31 31
32volatile DEFINE_PER_CPU(pgd_t *,current_pgd); 32DEFINE_PER_CPU(pgd_t *, current_pgd);
33unsigned long cris_signal_return_page; 33unsigned long cris_signal_return_page;
34 34
35/* 35/*
diff --git a/arch/frv/kernel/vmlinux.lds.S b/arch/frv/kernel/vmlinux.lds.S
index 22d9787406ed..7dbf41f68b52 100644
--- a/arch/frv/kernel/vmlinux.lds.S
+++ b/arch/frv/kernel/vmlinux.lds.S
@@ -177,6 +177,8 @@ SECTIONS
177 .debug_ranges 0 : { *(.debug_ranges) } 177 .debug_ranges 0 : { *(.debug_ranges) }
178 178
179 .comment 0 : { *(.comment) } 179 .comment 0 : { *(.comment) }
180
181 DISCARDS
180} 182}
181 183
182__kernel_image_size_no_bss = __bss_start - __kernel_image_start; 184__kernel_image_size_no_bss = __bss_start - __kernel_image_start;
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index 43d67534c712..566bdeb499d1 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -86,7 +86,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
86 struct pci_bus *bus; 86 struct pci_bus *bus;
87 struct pci_dev *dev; 87 struct pci_dev *dev;
88 int idx; 88 int idx;
89 struct resource *r, *pr; 89 struct resource *r;
90 90
91 /* Depth-First Search on bus tree */ 91 /* Depth-First Search on bus tree */
92 for (ln=bus_list->next; ln != bus_list; ln=ln->next) { 92 for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
@@ -96,8 +96,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
96 r = &dev->resource[idx]; 96 r = &dev->resource[idx];
97 if (!r->start) 97 if (!r->start)
98 continue; 98 continue;
99 pr = pci_find_parent_resource(dev, r); 99 if (pci_claim_resource(dev, idx) < 0)
100 if (!pr || request_resource(pr, r) < 0)
101 printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev)); 100 printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev));
102 } 101 }
103 } 102 }
@@ -110,7 +109,7 @@ static void __init pcibios_allocate_resources(int pass)
110 struct pci_dev *dev = NULL; 109 struct pci_dev *dev = NULL;
111 int idx, disabled; 110 int idx, disabled;
112 u16 command; 111 u16 command;
113 struct resource *r, *pr; 112 struct resource *r;
114 113
115 for_each_pci_dev(dev) { 114 for_each_pci_dev(dev) {
116 pci_read_config_word(dev, PCI_COMMAND, &command); 115 pci_read_config_word(dev, PCI_COMMAND, &command);
@@ -127,8 +126,7 @@ static void __init pcibios_allocate_resources(int pass)
127 if (pass == disabled) { 126 if (pass == disabled) {
128 DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n", 127 DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n",
129 r->start, r->end, r->flags, disabled, pass); 128 r->start, r->end, r->flags, disabled, pass);
130 pr = pci_find_parent_resource(dev, r); 129 if (pci_claim_resource(dev, idx) < 0) {
131 if (!pr || request_resource(pr, r) < 0) {
132 printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev)); 130 printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev));
133 /* We'll assign a new address later */ 131 /* We'll assign a new address later */
134 r->end -= r->start; 132 r->end -= r->start;
diff --git a/arch/h8300/include/asm/pci.h b/arch/h8300/include/asm/pci.h
index 97389b35aa35..cc9762091c0a 100644
--- a/arch/h8300/include/asm/pci.h
+++ b/arch/h8300/include/asm/pci.h
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#define pcibios_assign_all_busses() 0 10#define pcibios_assign_all_busses() 0
11#define pcibios_scan_all_fns(a, b) 0
12 11
13static inline void pcibios_set_master(struct pci_dev *dev) 12static inline void pcibios_set_master(struct pci_dev *dev)
14{ 13{
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
index 43a87b9085b6..662b02ecb86e 100644
--- a/arch/h8300/kernel/vmlinux.lds.S
+++ b/arch/h8300/kernel/vmlinux.lds.S
@@ -152,9 +152,6 @@ SECTIONS
152 __end = . ; 152 __end = . ;
153 __ramstart = .; 153 __ramstart = .;
154 } 154 }
155 /DISCARD/ : {
156 *(.exitcall.exit)
157 }
158 .romfs : 155 .romfs :
159 { 156 {
160 *(.romfs*) 157 *(.romfs*)
@@ -165,4 +162,6 @@ SECTIONS
165 COMMAND_START = . - 0x200 ; 162 COMMAND_START = . - 0x200 ;
166 __ramend = . ; 163 __ramend = . ;
167 } 164 }
165
166 DISCARDS
168} 167}
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 170042b420d4..011a1cdf0eb5 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -89,6 +89,9 @@ config GENERIC_TIME_VSYSCALL
89 bool 89 bool
90 default y 90 default y
91 91
92config HAVE_LEGACY_PER_CPU_AREA
93 def_bool y
94
92config HAVE_SETUP_PER_CPU_AREA 95config HAVE_SETUP_PER_CPU_AREA
93 def_bool y 96 def_bool y
94 97
@@ -112,6 +115,10 @@ config IA64_UNCACHED_ALLOCATOR
112 bool 115 bool
113 select GENERIC_ALLOCATOR 116 select GENERIC_ALLOCATOR
114 117
118config ARCH_USES_PG_UNCACHED
119 def_bool y
120 depends on IA64_UNCACHED_ALLOCATOR
121
115config AUDIT_ARCH 122config AUDIT_ARCH
116 bool 123 bool
117 default y 124 default y
diff --git a/arch/ia64/include/asm/agp.h b/arch/ia64/include/asm/agp.h
index c11fdd8ab4d7..01d09c401c5c 100644
--- a/arch/ia64/include/asm/agp.h
+++ b/arch/ia64/include/asm/agp.h
@@ -17,10 +17,6 @@
17#define unmap_page_from_agp(page) /* nothing */ 17#define unmap_page_from_agp(page) /* nothing */
18#define flush_agp_cache() mb() 18#define flush_agp_cache() mb()
19 19
20/* Convert a physical address to an address suitable for the GART. */
21#define phys_to_gart(x) (x)
22#define gart_to_phys(x) (x)
23
24/* GATT allocation. Returns/accepts GATT kernel virtual address. */ 20/* GATT allocation. Returns/accepts GATT kernel virtual address. */
25#define alloc_gatt_pages(order) \ 21#define alloc_gatt_pages(order) \
26 ((char *)__get_free_pages(GFP_KERNEL, (order))) 22 ((char *)__get_free_pages(GFP_KERNEL, (order)))
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index fcfca56bb850..55281aabe5f2 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -17,7 +17,6 @@
17 * loader. 17 * loader.
18 */ 18 */
19#define pcibios_assign_all_busses() 0 19#define pcibios_assign_all_busses() 0
20#define pcibios_scan_all_fns(a, b) 0
21 20
22#define PCIBIOS_MIN_IO 0x1000 21#define PCIBIOS_MIN_IO 0x1000
23#define PCIBIOS_MIN_MEM 0x10000000 22#define PCIBIOS_MIN_MEM 0x10000000
@@ -135,7 +134,18 @@ extern void pcibios_resource_to_bus(struct pci_dev *dev,
135extern void pcibios_bus_to_resource(struct pci_dev *dev, 134extern void pcibios_bus_to_resource(struct pci_dev *dev,
136 struct resource *res, struct pci_bus_region *region); 135 struct resource *res, struct pci_bus_region *region);
137 136
138#define pcibios_scan_all_fns(a, b) 0 137static inline struct resource *
138pcibios_select_root(struct pci_dev *pdev, struct resource *res)
139{
140 struct resource *root = NULL;
141
142 if (res->flags & IORESOURCE_IO)
143 root = &ioport_resource;
144 if (res->flags & IORESOURCE_MEM)
145 root = &iomem_resource;
146
147 return root;
148}
139 149
140#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ 150#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
141static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 151static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 1b23ec126b63..1de86c96801d 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -855,11 +855,17 @@ identify_cpu (struct cpuinfo_ia64 *c)
855 c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1)); 855 c->unimpl_pa_mask = ~((1L<<63) | ((1L << phys_addr_size) - 1));
856} 856}
857 857
858/*
859 * In UP configuration, setup_per_cpu_areas() is defined in
860 * include/linux/percpu.h
861 */
862#ifdef CONFIG_SMP
858void __init 863void __init
859setup_per_cpu_areas (void) 864setup_per_cpu_areas (void)
860{ 865{
861 /* start_kernel() requires this... */ 866 /* start_kernel() requires this... */
862} 867}
868#endif
863 869
864/* 870/*
865 * Do the following calculations: 871 * Do the following calculations:
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index f0c521b0ba4c..93ebfea43c6c 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -58,7 +58,8 @@ static struct local_tlb_flush_counts {
58 unsigned int count; 58 unsigned int count;
59} __attribute__((__aligned__(32))) local_tlb_flush_counts[NR_CPUS]; 59} __attribute__((__aligned__(32))) local_tlb_flush_counts[NR_CPUS];
60 60
61static DEFINE_PER_CPU(unsigned short, shadow_flush_counts[NR_CPUS]) ____cacheline_aligned; 61static DEFINE_PER_CPU_SHARED_ALIGNED(unsigned short [NR_CPUS],
62 shadow_flush_counts);
62 63
63#define IPI_CALL_FUNC 0 64#define IPI_CALL_FUNC 0
64#define IPI_CPU_STOP 1 65#define IPI_CPU_STOP 1
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 4a95e86b9ac2..eb4214d1c5af 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -24,14 +24,14 @@ PHDRS {
24} 24}
25SECTIONS 25SECTIONS
26{ 26{
27 /* Sections to be discarded */ 27 /* unwind exit sections must be discarded before the rest of the
28 sections get included. */
28 /DISCARD/ : { 29 /DISCARD/ : {
29 EXIT_TEXT
30 EXIT_DATA
31 *(.exitcall.exit)
32 *(.IA_64.unwind.exit.text) 30 *(.IA_64.unwind.exit.text)
33 *(.IA_64.unwind_info.exit.text) 31 *(.IA_64.unwind_info.exit.text)
34 } 32 *(.comment)
33 *(.note)
34 }
35 35
36 v = PAGE_OFFSET; /* this symbol is here to make debugging easier... */ 36 v = PAGE_OFFSET; /* this symbol is here to make debugging easier... */
37 phys_start = _start - LOAD_OFFSET; 37 phys_start = _start - LOAD_OFFSET;
@@ -316,7 +316,7 @@ SECTIONS
316 .debug_funcnames 0 : { *(.debug_funcnames) } 316 .debug_funcnames 0 : { *(.debug_funcnames) }
317 .debug_typenames 0 : { *(.debug_typenames) } 317 .debug_typenames 0 : { *(.debug_typenames) }
318 .debug_varnames 0 : { *(.debug_varnames) } 318 .debug_varnames 0 : { *(.debug_varnames) }
319 /* These must appear regardless of . */ 319
320 /DISCARD/ : { *(.comment) } 320 /* Default discards */
321 /DISCARD/ : { *(.note) } 321 DISCARDS
322} 322}
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index e456f062f241..ece1bf994499 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -71,7 +71,7 @@ EXPORT_SYMBOL(sn_rtc_cycles_per_second);
71DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info); 71DEFINE_PER_CPU(struct sn_hub_info_s, __sn_hub_info);
72EXPORT_PER_CPU_SYMBOL(__sn_hub_info); 72EXPORT_PER_CPU_SYMBOL(__sn_hub_info);
73 73
74DEFINE_PER_CPU(short, __sn_cnodeid_to_nasid[MAX_COMPACT_NODES]); 74DEFINE_PER_CPU(short [MAX_COMPACT_NODES], __sn_cnodeid_to_nasid);
75EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid); 75EXPORT_PER_CPU_SYMBOL(__sn_cnodeid_to_nasid);
76 76
77DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda); 77DEFINE_PER_CPU(struct nodepda_s *, __sn_nodepda);
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S
index 4179adf6c624..de5e21cca6a5 100644
--- a/arch/m32r/kernel/vmlinux.lds.S
+++ b/arch/m32r/kernel/vmlinux.lds.S
@@ -120,13 +120,6 @@ SECTIONS
120 120
121 _end = . ; 121 _end = . ;
122 122
123 /* Sections to be discarded */
124 /DISCARD/ : {
125 EXIT_TEXT
126 EXIT_DATA
127 *(.exitcall.exit)
128 }
129
130 /* Stabs debugging sections. */ 123 /* Stabs debugging sections. */
131 .stab 0 : { *(.stab) } 124 .stab 0 : { *(.stab) }
132 .stabstr 0 : { *(.stabstr) } 125 .stabstr 0 : { *(.stabstr) }
@@ -135,4 +128,7 @@ SECTIONS
135 .stab.index 0 : { *(.stab.index) } 128 .stab.index 0 : { *(.stab.index) }
136 .stab.indexstr 0 : { *(.stab.indexstr) } 129 .stab.indexstr 0 : { *(.stab.indexstr) }
137 .comment 0 : { *(.comment) } 130 .comment 0 : { *(.comment) }
131
132 /* Sections to be discarded */
133 DISCARDS
138} 134}
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 01d212bb05a6..47eac19e8f61 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -82,13 +82,6 @@ SECTIONS
82 82
83 _end = . ; 83 _end = . ;
84 84
85 /* Sections to be discarded */
86 /DISCARD/ : {
87 EXIT_TEXT
88 EXIT_DATA
89 *(.exitcall.exit)
90 }
91
92 /* Stabs debugging sections. */ 85 /* Stabs debugging sections. */
93 .stab 0 : { *(.stab) } 86 .stab 0 : { *(.stab) }
94 .stabstr 0 : { *(.stabstr) } 87 .stabstr 0 : { *(.stabstr) }
@@ -97,4 +90,7 @@ SECTIONS
97 .stab.index 0 : { *(.stab.index) } 90 .stab.index 0 : { *(.stab.index) }
98 .stab.indexstr 0 : { *(.stab.indexstr) } 91 .stab.indexstr 0 : { *(.stab.indexstr) }
99 .comment 0 : { *(.comment) } 92 .comment 0 : { *(.comment) }
93
94 /* Sections to be discarded */
95 DISCARDS
100} 96}
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index c192f773db96..03efaf04d7d7 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -77,13 +77,6 @@ __init_begin = .;
77 77
78 _end = . ; 78 _end = . ;
79 79
80 /* Sections to be discarded */
81 /DISCARD/ : {
82 EXIT_TEXT
83 EXIT_DATA
84 *(.exitcall.exit)
85 }
86
87 .crap : { 80 .crap : {
88 /* Stabs debugging sections. */ 81 /* Stabs debugging sections. */
89 *(.stab) 82 *(.stab)
@@ -96,4 +89,6 @@ __init_begin = .;
96 *(.note) 89 *(.note)
97 } 90 }
98 91
92 /* Sections to be discarded */
93 DISCARDS
99} 94}
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index b7fe505e358d..2736a5e309c0 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -184,12 +184,6 @@ SECTIONS {
184 __init_end = .; 184 __init_end = .;
185 } > INIT 185 } > INIT
186 186
187 /DISCARD/ : {
188 EXIT_TEXT
189 EXIT_DATA
190 *(.exitcall.exit)
191 }
192
193 .bss : { 187 .bss : {
194 . = ALIGN(4); 188 . = ALIGN(4);
195 _sbss = . ; 189 _sbss = . ;
@@ -200,5 +194,6 @@ SECTIONS {
200 _end = . ; 194 _end = . ;
201 } > BSS 195 } > BSS
202 196
197 DISCARDS
203} 198}
204 199
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index d34d38dcd12c..ec5fa91a48d8 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -23,8 +23,8 @@ SECTIONS {
23 _stext = . ; 23 _stext = . ;
24 *(.text .text.*) 24 *(.text .text.*)
25 *(.fixup) 25 *(.fixup)
26 26 EXIT_TEXT
27 *(.exitcall.exit) 27 EXIT_CALL
28 SCHED_TEXT 28 SCHED_TEXT
29 LOCK_TEXT 29 LOCK_TEXT
30 KPROBES_TEXT 30 KPROBES_TEXT
@@ -162,4 +162,6 @@ SECTIONS {
162 } 162 }
163 . = ALIGN(4096); 163 . = ALIGN(4096);
164 _end = .; 164 _end = .;
165
166 DISCARDS
165} 167}
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index a68d111e55e9..5ebf82572ec0 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -65,8 +65,6 @@ extern int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
65 65
66extern unsigned int pcibios_assign_all_busses(void); 66extern unsigned int pcibios_assign_all_busses(void);
67 67
68#define pcibios_scan_all_fns(a, b) 0
69
70extern unsigned long PCIBIOS_MIN_IO; 68extern unsigned long PCIBIOS_MIN_IO;
71extern unsigned long PCIBIOS_MIN_MEM; 69extern unsigned long PCIBIOS_MIN_MEM;
72 70
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 58738c8d754f..1474c18fb777 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -176,17 +176,6 @@ SECTIONS
176 176
177 _end = . ; 177 _end = . ;
178 178
179 /* Sections to be discarded */
180 /DISCARD/ : {
181 *(.exitcall.exit)
182
183 /* ABI crap starts here */
184 *(.MIPS.options)
185 *(.options)
186 *(.pdr)
187 *(.reginfo)
188 }
189
190 /* These mark the ABI of the kernel for debuggers. */ 179 /* These mark the ABI of the kernel for debuggers. */
191 .mdebug.abi32 : { 180 .mdebug.abi32 : {
192 KEEP(*(.mdebug.abi32)) 181 KEEP(*(.mdebug.abi32))
@@ -212,4 +201,14 @@ SECTIONS
212 *(.gptab.bss) 201 *(.gptab.bss)
213 *(.gptab.sbss) 202 *(.gptab.sbss)
214 } 203 }
204
205 /* Sections to be discarded */
206 DISCARDS
207 /DISCARD/ : {
208 /* ABI crap starts here */
209 *(.MIPS.options)
210 *(.options)
211 *(.pdr)
212 *(.reginfo)
213 }
215} 214}
diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h
index 19aecc90f7a4..6095a28561dd 100644
--- a/arch/mn10300/include/asm/pci.h
+++ b/arch/mn10300/include/asm/pci.h
@@ -101,7 +101,18 @@ extern void pcibios_bus_to_resource(struct pci_dev *dev,
101 struct resource *res, 101 struct resource *res,
102 struct pci_bus_region *region); 102 struct pci_bus_region *region);
103 103
104#define pcibios_scan_all_fns(a, b) 0 104static inline struct resource *
105pcibios_select_root(struct pci_dev *pdev, struct resource *res)
106{
107 struct resource *root = NULL;
108
109 if (res->flags & IORESOURCE_IO)
110 root = &ioport_resource;
111 if (res->flags & IORESOURCE_MEM)
112 root = &iomem_resource;
113
114 return root;
115}
105 116
106static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 117static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
107{ 118{
diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index f4aa07934654..76f41bdb79c4 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -115,12 +115,10 @@ SECTIONS
115 . = ALIGN(PAGE_SIZE); 115 . = ALIGN(PAGE_SIZE);
116 pg0 = .; 116 pg0 = .;
117 117
118 /* Sections to be discarded */
119 /DISCARD/ : {
120 EXIT_CALL
121 }
122
123 STABS_DEBUG 118 STABS_DEBUG
124 119
125 DWARF_DEBUG 120 DWARF_DEBUG
121
122 /* Sections to be discarded */
123 DISCARDS
126} 124}
diff --git a/arch/parisc/include/asm/agp.h b/arch/parisc/include/asm/agp.h
index 9651660da639..d226ffa8fc12 100644
--- a/arch/parisc/include/asm/agp.h
+++ b/arch/parisc/include/asm/agp.h
@@ -11,10 +11,6 @@
11#define unmap_page_from_agp(page) /* nothing */ 11#define unmap_page_from_agp(page) /* nothing */
12#define flush_agp_cache() mb() 12#define flush_agp_cache() mb()
13 13
14/* Convert a physical address to an address suitable for the GART. */
15#define phys_to_gart(x) (x)
16#define gart_to_phys(x) (x)
17
18/* GATT allocation. Returns/accepts GATT kernel virtual address. */ 14/* GATT allocation. Returns/accepts GATT kernel virtual address. */
19#define alloc_gatt_pages(order) \ 15#define alloc_gatt_pages(order) \
20 ((char *)__get_free_pages(GFP_KERNEL, (order))) 16 ((char *)__get_free_pages(GFP_KERNEL, (order)))
diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 7d842d699df2..64c7aa590ae5 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -233,7 +233,6 @@ static inline void pcibios_register_hba(struct pci_hba_data *x)
233 * rp7420/8420 boxes and then revisit this issue. 233 * rp7420/8420 boxes and then revisit this issue.
234 */ 234 */
235#define pcibios_assign_all_busses() (1) 235#define pcibios_assign_all_busses() (1)
236#define pcibios_scan_all_fns(a, b) (0)
237 236
238#define PCIBIOS_MIN_IO 0x10 237#define PCIBIOS_MIN_IO 0x10
239#define PCIBIOS_MIN_MEM 0x1000 /* NBPG - but pci/setup-res.c dies */ 238#define PCIBIOS_MIN_MEM 0x1000 /* NBPG - but pci/setup-res.c dies */
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index fd2cc4fd2b65..aea1784edbd1 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -237,9 +237,12 @@ SECTIONS
237 /* freed after init ends here */ 237 /* freed after init ends here */
238 _end = . ; 238 _end = . ;
239 239
240 STABS_DEBUG
241 .note 0 : { *(.note) }
242
240 /* Sections to be discarded */ 243 /* Sections to be discarded */
244 DISCARDS
241 /DISCARD/ : { 245 /DISCARD/ : {
242 *(.exitcall.exit)
243#ifdef CONFIG_64BIT 246#ifdef CONFIG_64BIT
244 /* temporary hack until binutils is fixed to not emit these 247 /* temporary hack until binutils is fixed to not emit these
245 * for static binaries 248 * for static binaries
@@ -252,7 +255,4 @@ SECTIONS
252 *(.gnu.hash) 255 *(.gnu.hash)
253#endif 256#endif
254 } 257 }
255
256 STABS_DEBUG
257 .note 0 : { *(.note) }
258} 258}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d00131ca0835..8250902265c6 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -49,6 +49,9 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
49config HAVE_SETUP_PER_CPU_AREA 49config HAVE_SETUP_PER_CPU_AREA
50 def_bool PPC64 50 def_bool PPC64
51 51
52config NEED_PER_CPU_EMBED_FIRST_CHUNK
53 def_bool PPC64
54
52config IRQ_PER_CPU 55config IRQ_PER_CPU
53 bool 56 bool
54 default y 57 default y
@@ -120,7 +123,8 @@ config PPC
120 select HAVE_KRETPROBES 123 select HAVE_KRETPROBES
121 select HAVE_ARCH_TRACEHOOK 124 select HAVE_ARCH_TRACEHOOK
122 select HAVE_LMB 125 select HAVE_LMB
123 select HAVE_DMA_ATTRS if PPC64 126 select HAVE_DMA_ATTRS
127 select HAVE_DMA_API_DEBUG
124 select USE_GENERIC_SMP_HELPERS if SMP 128 select USE_GENERIC_SMP_HELPERS if SMP
125 select HAVE_OPROFILE 129 select HAVE_OPROFILE
126 select HAVE_SYSCALL_WRAPPERS if PPC64 130 select HAVE_SYSCALL_WRAPPERS if PPC64
@@ -307,10 +311,6 @@ config SWIOTLB
307 platforms where the size of a physical address is larger 311 platforms where the size of a physical address is larger
308 than the bus address. Not all platforms support this. 312 than the bus address. Not all platforms support this.
309 313
310config PPC_NEED_DMA_SYNC_OPS
311 def_bool y
312 depends on (NOT_COHERENT_CACHE || SWIOTLB)
313
314config HOTPLUG_CPU 314config HOTPLUG_CPU
315 bool "Support for enabling/disabling CPUs" 315 bool "Support for enabling/disabling CPUs"
316 depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC) 316 depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC)
@@ -472,7 +472,7 @@ config PPC_16K_PAGES
472 bool "16k page size" if 44x 472 bool "16k page size" if 44x
473 473
474config PPC_64K_PAGES 474config PPC_64K_PAGES
475 bool "64k page size" if 44x || PPC_STD_MMU_64 475 bool "64k page size" if 44x || PPC_STD_MMU_64 || PPC_BOOK3E_64
476 select PPC_HAS_HASH_64K if PPC_STD_MMU_64 476 select PPC_HAS_HASH_64K if PPC_STD_MMU_64
477 477
478config PPC_256K_PAGES 478config PPC_256K_PAGES
@@ -492,16 +492,16 @@ endchoice
492 492
493config FORCE_MAX_ZONEORDER 493config FORCE_MAX_ZONEORDER
494 int "Maximum zone order" 494 int "Maximum zone order"
495 range 9 64 if PPC_STD_MMU_64 && PPC_64K_PAGES 495 range 9 64 if PPC64 && PPC_64K_PAGES
496 default "9" if PPC_STD_MMU_64 && PPC_64K_PAGES 496 default "9" if PPC64 && PPC_64K_PAGES
497 range 13 64 if PPC_STD_MMU_64 && !PPC_64K_PAGES 497 range 13 64 if PPC64 && !PPC_64K_PAGES
498 default "13" if PPC_STD_MMU_64 && !PPC_64K_PAGES 498 default "13" if PPC64 && !PPC_64K_PAGES
499 range 9 64 if PPC_STD_MMU_32 && PPC_16K_PAGES 499 range 9 64 if PPC32 && PPC_16K_PAGES
500 default "9" if PPC_STD_MMU_32 && PPC_16K_PAGES 500 default "9" if PPC32 && PPC_16K_PAGES
501 range 7 64 if PPC_STD_MMU_32 && PPC_64K_PAGES 501 range 7 64 if PPC32 && PPC_64K_PAGES
502 default "7" if PPC_STD_MMU_32 && PPC_64K_PAGES 502 default "7" if PPC32 && PPC_64K_PAGES
503 range 5 64 if PPC_STD_MMU_32 && PPC_256K_PAGES 503 range 5 64 if PPC32 && PPC_256K_PAGES
504 default "5" if PPC_STD_MMU_32 && PPC_256K_PAGES 504 default "5" if PPC32 && PPC_256K_PAGES
505 range 11 64 505 range 11 64
506 default "11" 506 default "11"
507 help 507 help
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index bc35f4e2b81c..952a3963e9e8 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -77,7 +77,7 @@ CPP = $(CC) -E $(KBUILD_CFLAGS)
77CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__ 77CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
78 78
79ifeq ($(CONFIG_PPC64),y) 79ifeq ($(CONFIG_PPC64),y)
80GCC_BROKEN_VEC := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi) 80GCC_BROKEN_VEC := $(call cc-ifversion, -lt, 0400, y)
81 81
82ifeq ($(CONFIG_POWER4_ONLY),y) 82ifeq ($(CONFIG_POWER4_ONLY),y)
83ifeq ($(CONFIG_ALTIVEC),y) 83ifeq ($(CONFIG_ALTIVEC),y)
diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c
index 325b310573b9..27db8938827a 100644
--- a/arch/powerpc/boot/4xx.c
+++ b/arch/powerpc/boot/4xx.c
@@ -8,6 +8,10 @@
8 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 8 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
9 * Copyright (c) 2003, 2004 Zultys Technologies 9 * Copyright (c) 2003, 2004 Zultys Technologies
10 * 10 *
11 * Copyright (C) 2009 Wind River Systems, Inc.
12 * Updated for supporting PPC405EX on Kilauea.
13 * Tiejun Chen <tiejun.chen@windriver.com>
14 *
11 * This program is free software; you can redistribute it and/or 15 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License 16 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 17 * as published by the Free Software Foundation; either version
@@ -659,3 +663,141 @@ void ibm405ep_fixup_clocks(unsigned int sys_clk)
659 dt_fixup_clock("/plb/opb/serial@ef600300", uart0); 663 dt_fixup_clock("/plb/opb/serial@ef600300", uart0);
660 dt_fixup_clock("/plb/opb/serial@ef600400", uart1); 664 dt_fixup_clock("/plb/opb/serial@ef600400", uart1);
661} 665}
666
667static u8 ibm405ex_fwdv_multi_bits[] = {
668 /* values for: 1 - 16 */
669 0x01, 0x02, 0x0e, 0x09, 0x04, 0x0b, 0x10, 0x0d, 0x0c, 0x05,
670 0x06, 0x0f, 0x0a, 0x07, 0x08, 0x03
671};
672
673u32 ibm405ex_get_fwdva(unsigned long cpr_fwdv)
674{
675 u32 index;
676
677 for (index = 0; index < ARRAY_SIZE(ibm405ex_fwdv_multi_bits); index++)
678 if (cpr_fwdv == (u32)ibm405ex_fwdv_multi_bits[index])
679 return index + 1;
680
681 return 0;
682}
683
684static u8 ibm405ex_fbdv_multi_bits[] = {
685 /* values for: 1 - 100 */
686 0x00, 0xff, 0x7e, 0xfd, 0x7a, 0xf5, 0x6a, 0xd5, 0x2a, 0xd4,
687 0x29, 0xd3, 0x26, 0xcc, 0x19, 0xb3, 0x67, 0xce, 0x1d, 0xbb,
688 0x77, 0xee, 0x5d, 0xba, 0x74, 0xe9, 0x52, 0xa5, 0x4b, 0x96,
689 0x2c, 0xd8, 0x31, 0xe3, 0x46, 0x8d, 0x1b, 0xb7, 0x6f, 0xde,
690 0x3d, 0xfb, 0x76, 0xed, 0x5a, 0xb5, 0x6b, 0xd6, 0x2d, 0xdb,
691 0x36, 0xec, 0x59, 0xb2, 0x64, 0xc9, 0x12, 0xa4, 0x48, 0x91,
692 0x23, 0xc7, 0x0e, 0x9c, 0x38, 0xf0, 0x61, 0xc2, 0x05, 0x8b,
693 0x17, 0xaf, 0x5f, 0xbe, 0x7c, 0xf9, 0x72, 0xe5, 0x4a, 0x95,
694 0x2b, 0xd7, 0x2e, 0xdc, 0x39, 0xf3, 0x66, 0xcd, 0x1a, 0xb4,
695 0x68, 0xd1, 0x22, 0xc4, 0x09, 0x93, 0x27, 0xcf, 0x1e, 0xbc,
696 /* values for: 101 - 200 */
697 0x78, 0xf1, 0x62, 0xc5, 0x0a, 0x94, 0x28, 0xd0, 0x21, 0xc3,
698 0x06, 0x8c, 0x18, 0xb0, 0x60, 0xc1, 0x02, 0x84, 0x08, 0x90,
699 0x20, 0xc0, 0x01, 0x83, 0x07, 0x8f, 0x1f, 0xbf, 0x7f, 0xfe,
700 0x7d, 0xfa, 0x75, 0xea, 0x55, 0xaa, 0x54, 0xa9, 0x53, 0xa6,
701 0x4c, 0x99, 0x33, 0xe7, 0x4e, 0x9d, 0x3b, 0xf7, 0x6e, 0xdd,
702 0x3a, 0xf4, 0x69, 0xd2, 0x25, 0xcb, 0x16, 0xac, 0x58, 0xb1,
703 0x63, 0xc6, 0x0d, 0x9b, 0x37, 0xef, 0x5e, 0xbd, 0x7b, 0xf6,
704 0x6d, 0xda, 0x35, 0xeb, 0x56, 0xad, 0x5b, 0xb6, 0x6c, 0xd9,
705 0x32, 0xe4, 0x49, 0x92, 0x24, 0xc8, 0x11, 0xa3, 0x47, 0x8e,
706 0x1c, 0xb8, 0x70, 0xe1, 0x42, 0x85, 0x0b, 0x97, 0x2f, 0xdf,
707 /* values for: 201 - 255 */
708 0x3e, 0xfc, 0x79, 0xf2, 0x65, 0xca, 0x15, 0xab, 0x57, 0xae,
709 0x5c, 0xb9, 0x73, 0xe6, 0x4d, 0x9a, 0x34, 0xe8, 0x51, 0xa2,
710 0x44, 0x89, 0x13, 0xa7, 0x4f, 0x9e, 0x3c, 0xf8, 0x71, 0xe2,
711 0x45, 0x8a, 0x14, 0xa8, 0x50, 0xa1, 0x43, 0x86, 0x0c, 0x98,
712 0x30, 0xe0, 0x41, 0x82, 0x04, 0x88, 0x10, 0xa0, 0x40, 0x81,
713 0x03, 0x87, 0x0f, 0x9f, 0x3f /* END */
714};
715
716u32 ibm405ex_get_fbdv(unsigned long cpr_fbdv)
717{
718 u32 index;
719
720 for (index = 0; index < ARRAY_SIZE(ibm405ex_fbdv_multi_bits); index++)
721 if (cpr_fbdv == (u32)ibm405ex_fbdv_multi_bits[index])
722 return index + 1;
723
724 return 0;
725}
726
727void ibm405ex_fixup_clocks(unsigned int sys_clk, unsigned int uart_clk)
728{
729 /* PLL config */
730 u32 pllc = CPR0_READ(DCRN_CPR0_PLLC);
731 u32 plld = CPR0_READ(DCRN_CPR0_PLLD);
732 u32 cpud = CPR0_READ(DCRN_CPR0_PRIMAD);
733 u32 plbd = CPR0_READ(DCRN_CPR0_PRIMBD);
734 u32 opbd = CPR0_READ(DCRN_CPR0_OPBD);
735 u32 perd = CPR0_READ(DCRN_CPR0_PERD);
736
737 /* Dividers */
738 u32 fbdv = ibm405ex_get_fbdv(__fix_zero((plld >> 24) & 0xff, 1));
739
740 u32 fwdva = ibm405ex_get_fwdva(__fix_zero((plld >> 16) & 0x0f, 1));
741
742 u32 cpudv0 = __fix_zero((cpud >> 24) & 7, 8);
743
744 /* PLBDV0 is hardwared to 010. */
745 u32 plbdv0 = 2;
746 u32 plb2xdv0 = __fix_zero((plbd >> 16) & 7, 8);
747
748 u32 opbdv0 = __fix_zero((opbd >> 24) & 3, 4);
749
750 u32 perdv0 = __fix_zero((perd >> 24) & 3, 4);
751
752 /* Resulting clocks */
753 u32 cpu, plb, opb, ebc, vco, tb, uart0, uart1;
754
755 /* PLL's VCO is the source for primary forward ? */
756 if (pllc & 0x40000000) {
757 u32 m;
758
759 /* Feedback path */
760 switch ((pllc >> 24) & 7) {
761 case 0:
762 /* PLLOUTx */
763 m = fbdv;
764 break;
765 case 1:
766 /* CPU */
767 m = fbdv * fwdva * cpudv0;
768 break;
769 case 5:
770 /* PERClk */
771 m = fbdv * fwdva * plb2xdv0 * plbdv0 * opbdv0 * perdv0;
772 break;
773 default:
774 printf("WARNING ! Invalid PLL feedback source !\n");
775 goto bypass;
776 }
777
778 vco = (unsigned int)(sys_clk * m);
779 } else {
780bypass:
781 /* Bypass system PLL */
782 vco = 0;
783 }
784
785 /* CPU = VCO / ( FWDVA x CPUDV0) */
786 cpu = vco / (fwdva * cpudv0);
787 /* PLB = VCO / ( FWDVA x PLB2XDV0 x PLBDV0) */
788 plb = vco / (fwdva * plb2xdv0 * plbdv0);
789 /* OPB = PLB / OPBDV0 */
790 opb = plb / opbdv0;
791 /* EBC = OPB / PERDV0 */
792 ebc = opb / perdv0;
793
794 tb = cpu;
795 uart0 = uart1 = uart_clk;
796
797 dt_fixup_cpu_clocks(cpu, tb, 0);
798 dt_fixup_clock("/plb", plb);
799 dt_fixup_clock("/plb/opb", opb);
800 dt_fixup_clock("/plb/opb/ebc", ebc);
801 dt_fixup_clock("/plb/opb/serial@ef600200", uart0);
802 dt_fixup_clock("/plb/opb/serial@ef600300", uart1);
803}
diff --git a/arch/powerpc/boot/4xx.h b/arch/powerpc/boot/4xx.h
index 2606e64f0c4b..7dc5d45361bc 100644
--- a/arch/powerpc/boot/4xx.h
+++ b/arch/powerpc/boot/4xx.h
@@ -21,6 +21,7 @@ void ibm4xx_fixup_ebc_ranges(const char *ebc);
21 21
22void ibm405gp_fixup_clocks(unsigned int sys_clk, unsigned int ser_clk); 22void ibm405gp_fixup_clocks(unsigned int sys_clk, unsigned int ser_clk);
23void ibm405ep_fixup_clocks(unsigned int sys_clk); 23void ibm405ep_fixup_clocks(unsigned int sys_clk);
24void ibm405ex_fixup_clocks(unsigned int sys_clk, unsigned int uart_clk);
24void ibm440gp_fixup_clocks(unsigned int sys_clk, unsigned int ser_clk); 25void ibm440gp_fixup_clocks(unsigned int sys_clk, unsigned int ser_clk);
25void ibm440ep_fixup_clocks(unsigned int sys_clk, unsigned int ser_clk, 26void ibm440ep_fixup_clocks(unsigned int sys_clk, unsigned int ser_clk,
26 unsigned int tmr_clk); 27 unsigned int tmr_clk);
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 9ae7b7e2ba71..7bfc8ad87798 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -39,6 +39,7 @@ DTS_FLAGS ?= -p 1024
39 39
40$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405 40$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
41$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405 41$(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
42$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
42$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405 43$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
43$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405 44$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=405
44$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405 45$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
@@ -67,7 +68,7 @@ src-wlib := string.S crt0.S crtsavres.S stdio.c main.c \
67 cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \ 68 cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \
68 fsl-soc.c mpc8xx.c pq2.c 69 fsl-soc.c mpc8xx.c pq2.c
69src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \ 70src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \
70 cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ 71 cuboot-ebony.c cuboot-hotfoot.c treeboot-ebony.c prpmc2800.c \
71 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ 72 ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
72 cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \ 73 cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \
73 cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \ 74 cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \
@@ -75,7 +76,7 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c
75 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \ 76 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
76 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \ 77 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
77 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \ 78 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
78 cuboot-acadia.c cuboot-amigaone.c 79 cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c
79src-boot := $(src-wlib) $(src-plat) empty.c 80src-boot := $(src-wlib) $(src-plat) empty.c
80 81
81src-boot := $(addprefix $(obj)/, $(src-boot)) 82src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -190,6 +191,7 @@ image-$(CONFIG_DEFAULT_UIMAGE) += uImage
190 191
191# Board ports in arch/powerpc/platform/40x/Kconfig 192# Board ports in arch/powerpc/platform/40x/Kconfig
192image-$(CONFIG_EP405) += dtbImage.ep405 193image-$(CONFIG_EP405) += dtbImage.ep405
194image-$(CONFIG_HOTFOOT) += cuImage.hotfoot
193image-$(CONFIG_WALNUT) += treeImage.walnut 195image-$(CONFIG_WALNUT) += treeImage.walnut
194image-$(CONFIG_ACADIA) += cuImage.acadia 196image-$(CONFIG_ACADIA) += cuImage.acadia
195 197
diff --git a/arch/powerpc/boot/cuboot-hotfoot.c b/arch/powerpc/boot/cuboot-hotfoot.c
new file mode 100644
index 000000000000..8f697b958e45
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-hotfoot.c
@@ -0,0 +1,142 @@
1/*
2 * Old U-boot compatibility for Esteem 195E Hotfoot CPU Board
3 *
4 * Author: Solomon Peachy <solomon@linux-wlan.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 version 2 as published
8 * by the Free Software Foundation.
9 */
10
11#include "ops.h"
12#include "stdio.h"
13#include "reg.h"
14#include "dcr.h"
15#include "4xx.h"
16#include "cuboot.h"
17
18#define TARGET_4xx
19#define TARGET_HOTFOOT
20
21#include "ppcboot-hotfoot.h"
22
23static bd_t bd;
24
25#define NUM_REGS 3
26
27static void hotfoot_fixups(void)
28{
29 u32 uart = mfdcr(DCRN_CPC0_UCR) & 0x7f;
30
31 dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
32
33 dt_fixup_cpu_clocks(bd.bi_procfreq, bd.bi_procfreq, 0);
34 dt_fixup_clock("/plb", bd.bi_plb_busfreq);
35 dt_fixup_clock("/plb/opb", bd.bi_opbfreq);
36 dt_fixup_clock("/plb/ebc", bd.bi_pci_busfreq);
37 dt_fixup_clock("/plb/opb/serial@ef600300", bd.bi_procfreq / uart);
38 dt_fixup_clock("/plb/opb/serial@ef600400", bd.bi_procfreq / uart);
39
40 dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr);
41 dt_fixup_mac_address_by_alias("ethernet1", bd.bi_enet1addr);
42
43 /* Is this a single eth/serial board? */
44 if ((bd.bi_enet1addr[0] == 0) &&
45 (bd.bi_enet1addr[1] == 0) &&
46 (bd.bi_enet1addr[2] == 0) &&
47 (bd.bi_enet1addr[3] == 0) &&
48 (bd.bi_enet1addr[4] == 0) &&
49 (bd.bi_enet1addr[5] == 0)) {
50 void *devp;
51
52 printf("Trimming devtree for single serial/eth board\n");
53
54 devp = finddevice("/plb/opb/serial@ef600300");
55 if (!devp)
56 fatal("Can't find node for /plb/opb/serial@ef600300");
57 del_node(devp);
58
59 devp = finddevice("/plb/opb/ethernet@ef600900");
60 if (!devp)
61 fatal("Can't find node for /plb/opb/ethernet@ef600900");
62 del_node(devp);
63 }
64
65 ibm4xx_quiesce_eth((u32 *)0xef600800, (u32 *)0xef600900);
66
67 /* Fix up flash size in fdt for 4M boards. */
68 if (bd.bi_flashsize < 0x800000) {
69 u32 regs[NUM_REGS];
70 void *devp = finddevice("/plb/ebc/nor_flash@0");
71 if (!devp)
72 fatal("Can't find FDT node for nor_flash!??");
73
74 printf("Fixing devtree for 4M Flash\n");
75
76 /* First fix up the base addresse */
77 getprop(devp, "reg", regs, sizeof(regs));
78 regs[0] = 0;
79 regs[1] = 0xffc00000;
80 regs[2] = 0x00400000;
81 setprop(devp, "reg", regs, sizeof(regs));
82
83 /* Then the offsets */
84 devp = finddevice("/plb/ebc/nor_flash@0/partition@0");
85 if (!devp)
86 fatal("Can't find FDT node for partition@0");
87 getprop(devp, "reg", regs, 2*sizeof(u32));
88 regs[0] -= 0x400000;
89 setprop(devp, "reg", regs, 2*sizeof(u32));
90
91 devp = finddevice("/plb/ebc/nor_flash@0/partition@1");
92 if (!devp)
93 fatal("Can't find FDT node for partition@1");
94 getprop(devp, "reg", regs, 2*sizeof(u32));
95 regs[0] -= 0x400000;
96 setprop(devp, "reg", regs, 2*sizeof(u32));
97
98 devp = finddevice("/plb/ebc/nor_flash@0/partition@2");
99 if (!devp)
100 fatal("Can't find FDT node for partition@2");
101 getprop(devp, "reg", regs, 2*sizeof(u32));
102 regs[0] -= 0x400000;
103 setprop(devp, "reg", regs, 2*sizeof(u32));
104
105 devp = finddevice("/plb/ebc/nor_flash@0/partition@3");
106 if (!devp)
107 fatal("Can't find FDT node for partition@3");
108 getprop(devp, "reg", regs, 2*sizeof(u32));
109 regs[0] -= 0x400000;
110 setprop(devp, "reg", regs, 2*sizeof(u32));
111
112 devp = finddevice("/plb/ebc/nor_flash@0/partition@4");
113 if (!devp)
114 fatal("Can't find FDT node for partition@4");
115 getprop(devp, "reg", regs, 2*sizeof(u32));
116 regs[0] -= 0x400000;
117 setprop(devp, "reg", regs, 2*sizeof(u32));
118
119 devp = finddevice("/plb/ebc/nor_flash@0/partition@6");
120 if (!devp)
121 fatal("Can't find FDT node for partition@6");
122 getprop(devp, "reg", regs, 2*sizeof(u32));
123 regs[0] -= 0x400000;
124 setprop(devp, "reg", regs, 2*sizeof(u32));
125
126 /* Delete the FeatFS node */
127 devp = finddevice("/plb/ebc/nor_flash@0/partition@5");
128 if (!devp)
129 fatal("Can't find FDT node for partition@5");
130 del_node(devp);
131 }
132}
133
134void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
135 unsigned long r6, unsigned long r7)
136{
137 CUBOOT_INIT();
138 platform_ops.fixups = hotfoot_fixups;
139 platform_ops.exit = ibm40x_dbcr_reset;
140 fdt_init(_dtb_start);
141 serial_console_init();
142}
diff --git a/arch/powerpc/boot/cuboot-kilauea.c b/arch/powerpc/boot/cuboot-kilauea.c
new file mode 100644
index 000000000000..80cdad6bbc3f
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-kilauea.c
@@ -0,0 +1,49 @@
1/*
2 * Old U-boot compatibility for PPC405EX. This image is already included
3 * a dtb.
4 *
5 * Author: Tiejun Chen <tiejun.chen@windriver.com>
6 *
7 * Copyright (C) 2009 Wind River Systems, Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
14#include "ops.h"
15#include "io.h"
16#include "dcr.h"
17#include "stdio.h"
18#include "4xx.h"
19#include "44x.h"
20#include "cuboot.h"
21
22#define TARGET_4xx
23#define TARGET_44x
24#include "ppcboot.h"
25
26#define KILAUEA_SYS_EXT_SERIAL_CLOCK 11059200 /* ext. 11.059MHz clk */
27
28static bd_t bd;
29
30static void kilauea_fixups(void)
31{
32 unsigned long sysclk = 33333333;
33
34 ibm405ex_fixup_clocks(sysclk, KILAUEA_SYS_EXT_SERIAL_CLOCK);
35 dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
36 ibm4xx_fixup_ebc_ranges("/plb/opb/ebc");
37 dt_fixup_mac_address_by_alias("ethernet0", bd.bi_enetaddr);
38 dt_fixup_mac_address_by_alias("ethernet1", bd.bi_enet1addr);
39}
40
41void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
42 unsigned long r6, unsigned long r7)
43{
44 CUBOOT_INIT();
45 platform_ops.fixups = kilauea_fixups;
46 platform_ops.exit = ibm40x_dbcr_reset;
47 fdt_init(_dtb_start);
48 serial_console_init();
49}
diff --git a/arch/powerpc/boot/dcr.h b/arch/powerpc/boot/dcr.h
index 95b9f5344016..645a7c964e5f 100644
--- a/arch/powerpc/boot/dcr.h
+++ b/arch/powerpc/boot/dcr.h
@@ -153,9 +153,7 @@ static const unsigned long sdram_bxcr[] = { SDRAM0_B0CR, SDRAM0_B1CR,
153#define DCRN_CPC0_PLLMR1 0xf4 153#define DCRN_CPC0_PLLMR1 0xf4
154#define DCRN_CPC0_UCR 0xf5 154#define DCRN_CPC0_UCR 0xf5
155 155
156/* 440GX Clock control etc */ 156/* 440GX/405EX Clock Control reg */
157
158
159#define DCRN_CPR0_CLKUPD 0x020 157#define DCRN_CPR0_CLKUPD 0x020
160#define DCRN_CPR0_PLLC 0x040 158#define DCRN_CPR0_PLLC 0x040
161#define DCRN_CPR0_PLLD 0x060 159#define DCRN_CPR0_PLLD 0x060
diff --git a/arch/powerpc/boot/dts/arches.dts b/arch/powerpc/boot/dts/arches.dts
index d9113b1e8c1d..414ef8b7e575 100644
--- a/arch/powerpc/boot/dts/arches.dts
+++ b/arch/powerpc/boot/dts/arches.dts
@@ -124,6 +124,16 @@
124 dcr-reg = <0x00c 0x002>; 124 dcr-reg = <0x00c 0x002>;
125 }; 125 };
126 126
127 L2C0: l2c {
128 compatible = "ibm,l2-cache-460gt", "ibm,l2-cache";
129 dcr-reg = <0x020 0x008 /* Internal SRAM DCR's */
130 0x030 0x008>; /* L2 cache DCR's */
131 cache-line-size = <32>; /* 32 bytes */
132 cache-size = <262144>; /* L2, 256K */
133 interrupt-parent = <&UIC1>;
134 interrupts = <11 1>;
135 };
136
127 plb { 137 plb {
128 compatible = "ibm,plb-460gt", "ibm,plb4"; 138 compatible = "ibm,plb-460gt", "ibm,plb4";
129 #address-cells = <2>; 139 #address-cells = <2>;
@@ -168,6 +178,38 @@
168 /* ranges property is supplied by U-Boot */ 178 /* ranges property is supplied by U-Boot */
169 interrupts = <0x6 0x4>; 179 interrupts = <0x6 0x4>;
170 interrupt-parent = <&UIC1>; 180 interrupt-parent = <&UIC1>;
181
182 nor_flash@0,0 {
183 compatible = "amd,s29gl256n", "cfi-flash";
184 bank-width = <2>;
185 reg = <0x00000000 0x00000000 0x02000000>;
186 #address-cells = <1>;
187 #size-cells = <1>;
188 partition@0 {
189 label = "kernel";
190 reg = <0x00000000 0x001e0000>;
191 };
192 partition@1e0000 {
193 label = "dtb";
194 reg = <0x001e0000 0x00020000>;
195 };
196 partition@200000 {
197 label = "root";
198 reg = <0x00200000 0x00200000>;
199 };
200 partition@400000 {
201 label = "user";
202 reg = <0x00400000 0x01b60000>;
203 };
204 partition@1f60000 {
205 label = "env";
206 reg = <0x01f60000 0x00040000>;
207 };
208 partition@1fa0000 {
209 label = "u-boot";
210 reg = <0x01fa0000 0x00060000>;
211 };
212 };
171 }; 213 };
172 214
173 UART0: serial@ef600300 { 215 UART0: serial@ef600300 {
@@ -186,6 +228,14 @@
186 reg = <0xef600700 0x00000014>; 228 reg = <0xef600700 0x00000014>;
187 interrupt-parent = <&UIC0>; 229 interrupt-parent = <&UIC0>;
188 interrupts = <0x2 0x4>; 230 interrupts = <0x2 0x4>;
231 #address-cells = <1>;
232 #size-cells = <0>;
233 sttm@4a {
234 compatible = "ad,ad7414";
235 reg = <0x4a>;
236 interrupt-parent = <&UIC1>;
237 interrupts = <0x0 0x8>;
238 };
189 }; 239 };
190 240
191 IIC1: i2c@ef600800 { 241 IIC1: i2c@ef600800 {
diff --git a/arch/powerpc/boot/dts/canyonlands.dts b/arch/powerpc/boot/dts/canyonlands.dts
index 5fd1ad09bdf2..c920170b7dfe 100644
--- a/arch/powerpc/boot/dts/canyonlands.dts
+++ b/arch/powerpc/boot/dts/canyonlands.dts
@@ -1,7 +1,7 @@
1/* 1/*
2 * Device Tree Source for AMCC Canyonlands (460EX) 2 * Device Tree Source for AMCC Canyonlands (460EX)
3 * 3 *
4 * Copyright 2008 DENX Software Engineering, Stefan Roese <sr@denx.de> 4 * Copyright 2008-2009 DENX Software Engineering, Stefan Roese <sr@denx.de>
5 * 5 *
6 * This file is licensed under the terms of the GNU General Public 6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without 7 * License version 2. This program is licensed "as is" without
@@ -149,19 +149,19 @@
149 /*RXDE*/ 0x5 0x4>; 149 /*RXDE*/ 0x5 0x4>;
150 }; 150 };
151 151
152 USB0: ehci@bffd0400 { 152 USB0: ehci@bffd0400 {
153 compatible = "ibm,usb-ehci-460ex", "usb-ehci"; 153 compatible = "ibm,usb-ehci-460ex", "usb-ehci";
154 interrupt-parent = <&UIC2>; 154 interrupt-parent = <&UIC2>;
155 interrupts = <0x1d 4>; 155 interrupts = <0x1d 4>;
156 reg = <4 0xbffd0400 0x90 4 0xbffd0490 0x70>; 156 reg = <4 0xbffd0400 0x90 4 0xbffd0490 0x70>;
157 }; 157 };
158 158
159 USB1: usb@bffd0000 { 159 USB1: usb@bffd0000 {
160 compatible = "ohci-le"; 160 compatible = "ohci-le";
161 reg = <4 0xbffd0000 0x60>; 161 reg = <4 0xbffd0000 0x60>;
162 interrupt-parent = <&UIC2>; 162 interrupt-parent = <&UIC2>;
163 interrupts = <0x1e 4>; 163 interrupts = <0x1e 4>;
164 }; 164 };
165 165
166 POB0: opb { 166 POB0: opb {
167 compatible = "ibm,opb-460ex", "ibm,opb"; 167 compatible = "ibm,opb-460ex", "ibm,opb";
@@ -215,6 +215,29 @@
215 reg = <0x03fa0000 0x00060000>; 215 reg = <0x03fa0000 0x00060000>;
216 }; 216 };
217 }; 217 };
218
219 ndfc@3,0 {
220 compatible = "ibm,ndfc";
221 reg = <0x00000003 0x00000000 0x00002000>;
222 ccr = <0x00001000>;
223 bank-settings = <0x80002222>;
224 #address-cells = <1>;
225 #size-cells = <1>;
226
227 nand {
228 #address-cells = <1>;
229 #size-cells = <1>;
230
231 partition@0 {
232 label = "u-boot";
233 reg = <0x00000000 0x00100000>;
234 };
235 partition@100000 {
236 label = "user";
237 reg = <0x00000000 0x03f00000>;
238 };
239 };
240 };
218 }; 241 };
219 242
220 UART0: serial@ef600300 { 243 UART0: serial@ef600300 {
diff --git a/arch/powerpc/boot/dts/eiger.dts b/arch/powerpc/boot/dts/eiger.dts
new file mode 100644
index 000000000000..c4a934f2e886
--- /dev/null
+++ b/arch/powerpc/boot/dts/eiger.dts
@@ -0,0 +1,421 @@
1/*
2 * Device Tree Source for AMCC (AppliedMicro) Eiger(460SX)
3 *
4 * Copyright 2009 AMCC (AppliedMicro) <ttnguyen@amcc.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without
8 * any warranty of any kind, whether express or implied.
9 */
10
11/dts-v1/;
12
13/ {
14 #address-cells = <2>;
15 #size-cells = <1>;
16 model = "amcc,eiger";
17 compatible = "amcc,eiger";
18 dcr-parent = <&{/cpus/cpu@0}>;
19
20 aliases {
21 ethernet0 = &EMAC0;
22 ethernet1 = &EMAC1;
23 ethernet2 = &EMAC2;
24 ethernet3 = &EMAC3;
25 serial0 = &UART0;
26 serial1 = &UART1;
27 };
28
29 cpus {
30 #address-cells = <1>;
31 #size-cells = <0>;
32
33 cpu@0 {
34 device_type = "cpu";
35 model = "PowerPC,460SX";
36 reg = <0x00000000>;
37 clock-frequency = <0>; /* Filled in by U-Boot */
38 timebase-frequency = <0>; /* Filled in by U-Boot */
39 i-cache-line-size = <32>;
40 d-cache-line-size = <32>;
41 i-cache-size = <32768>;
42 d-cache-size = <32768>;
43 dcr-controller;
44 dcr-access-method = "native";
45 };
46 };
47
48 memory {
49 device_type = "memory";
50 reg = <0x00000000 0x00000000 0x00000000>; /* Filled in by U-Boot */
51 };
52
53 UIC0: interrupt-controller0 {
54 compatible = "ibm,uic-460sx","ibm,uic";
55 interrupt-controller;
56 cell-index = <0>;
57 dcr-reg = <0x0c0 0x009>;
58 #address-cells = <0>;
59 #size-cells = <0>;
60 #interrupt-cells = <2>;
61 };
62
63 UIC1: interrupt-controller1 {
64 compatible = "ibm,uic-460sx","ibm,uic";
65 interrupt-controller;
66 cell-index = <1>;
67 dcr-reg = <0x0d0 0x009>;
68 #address-cells = <0>;
69 #size-cells = <0>;
70 #interrupt-cells = <2>;
71 interrupts = <0x1e 0x4 0x1f 0x4>; /* cascade */
72 interrupt-parent = <&UIC0>;
73 };
74
75 UIC2: interrupt-controller2 {
76 compatible = "ibm,uic-460sx","ibm,uic";
77 interrupt-controller;
78 cell-index = <2>;
79 dcr-reg = <0x0e0 0x009>;
80 #address-cells = <0>;
81 #size-cells = <0>;
82 #interrupt-cells = <2>;
83 interrupts = <0xa 0x4 0xb 0x4>; /* cascade */
84 interrupt-parent = <&UIC0>;
85 };
86
87 UIC3: interrupt-controller3 {
88 compatible = "ibm,uic-460sx","ibm,uic";
89 interrupt-controller;
90 cell-index = <3>;
91 dcr-reg = <0x0f0 0x009>;
92 #address-cells = <0>;
93 #size-cells = <0>;
94 #interrupt-cells = <2>;
95 interrupts = <0x10 0x4 0x11 0x4>; /* cascade */
96 interrupt-parent = <&UIC0>;
97 };
98
99 SDR0: sdr {
100 compatible = "ibm,sdr-460sx";
101 dcr-reg = <0x00e 0x002>;
102 };
103
104 CPR0: cpr {
105 compatible = "ibm,cpr-460sx";
106 dcr-reg = <0x00c 0x002>;
107 };
108
109 plb {
110 compatible = "ibm,plb-460sx", "ibm,plb4";
111 #address-cells = <2>;
112 #size-cells = <1>;
113 ranges;
114 clock-frequency = <0>; /* Filled in by U-Boot */
115
116 SDRAM0: sdram {
117 compatible = "ibm,sdram-460sx", "ibm,sdram-405gp";
118 dcr-reg = <0x010 0x002>;
119 };
120
121 MAL0: mcmal {
122 compatible = "ibm,mcmal-460sx", "ibm,mcmal2";
123 dcr-reg = <0x180 0x62>;
124 num-tx-chans = <4>;
125 num-rx-chans = <32>;
126 #address-cells = <1>;
127 #size-cells = <1>;
128 interrupt-parent = <&UIC1>;
129 interrupts = < /*TXEOB*/ 0x6 0x4
130 /*RXEOB*/ 0x7 0x4
131 /*SERR*/ 0x1 0x4
132 /*TXDE*/ 0x2 0x4
133 /*RXDE*/ 0x3 0x4
134 /*COAL TX0*/ 0x18 0x2
135 /*COAL TX1*/ 0x19 0x2
136 /*COAL TX2*/ 0x1a 0x2
137 /*COAL TX3*/ 0x1b 0x2
138 /*COAL RX0*/ 0x1c 0x2
139 /*COAL RX1*/ 0x1d 0x2
140 /*COAL RX2*/ 0x1e 0x2
141 /*COAL RX3*/ 0x1f 0x2>;
142 };
143
144 POB0: opb {
145 compatible = "ibm,opb-460sx", "ibm,opb";
146 #address-cells = <1>;
147 #size-cells = <1>;
148 ranges = <0xb0000000 0x00000004 0xb0000000 0x50000000>;
149 clock-frequency = <0>; /* Filled in by U-Boot */
150
151 EBC0: ebc {
152 compatible = "ibm,ebc-460sx", "ibm,ebc";
153 dcr-reg = <0x012 0x002>;
154 #address-cells = <2>;
155 #size-cells = <1>;
156 clock-frequency = <0>; /* Filled in by U-Boot */
157 /* ranges property is supplied by U-Boot */
158 interrupts = <0x6 0x4>;
159 interrupt-parent = <&UIC1>;
160
161 nor_flash@0,0 {
162 compatible = "amd,s29gl512n", "cfi-flash";
163 bank-width = <2>;
164 /* reg property is supplied in by U-Boot */
165 #address-cells = <1>;
166 #size-cells = <1>;
167 partition@0 {
168 label = "kernel";
169 reg = <0x00000000 0x001e0000>;
170 };
171 partition@1e0000 {
172 label = "dtb";
173 reg = <0x001e0000 0x00020000>;
174 };
175 partition@200000 {
176 label = "ramdisk";
177 reg = <0x00200000 0x01400000>;
178 };
179 partition@1600000 {
180 label = "jffs2";
181 reg = <0x01600000 0x00400000>;
182 };
183 partition@1a00000 {
184 label = "user";
185 reg = <0x01a00000 0x02560000>;
186 };
187 partition@3f60000 {
188 label = "env";
189 reg = <0x03f60000 0x00040000>;
190 };
191 partition@3fa0000 {
192 label = "u-boot";
193 reg = <0x03fa0000 0x00060000>;
194 };
195 };
196
197 ndfc@1,0 {
198 compatible = "ibm,ndfc";
199 /* reg property is supplied by U-boot */
200 ccr = <0x00003000>;
201 bank-settings = <0x80002222>;
202 #address-cells = <1>;
203 #size-cells = <1>;
204
205 nand {
206 #address-cells = <1>;
207 #size-cells = <1>;
208 partition@0 {
209 label = "uboot";
210 reg = <0x00000000 0x00200000>;
211 };
212 partition@200000 {
213 label = "uboot-environment";
214 reg = <0x00200000 0x00100000>;
215 };
216 partition@300000 {
217 label = "linux";
218 reg = <0x00300000 0x00300000>;
219 };
220 partition@600000 {
221 label = "root-file-system";
222 reg = <0x00600000 0x01900000>;
223 };
224 partition@1f00000 {
225 label = "device-tree";
226 reg = <0x01f00000 0x00020000>;
227 };
228 partition@1f20000 {
229 label = "data";
230 reg = <0x01f20000 0x060E0000>;
231 };
232 };
233 };
234 };
235
236 UART0: serial@ef600200 {
237 device_type = "serial";
238 compatible = "ns16550";
239 reg = <0xef600200 0x00000008>;
240 virtual-reg = <0xef600200>;
241 clock-frequency = <0>; /* Filled in by U-Boot */
242 current-speed = <0>; /* Filled in by U-Boot */
243 interrupt-parent = <&UIC0>;
244 interrupts = <0x0 0x4>;
245 };
246
247 UART1: serial@ef600300 {
248 device_type = "serial";
249 compatible = "ns16550";
250 reg = <0xef600300 0x00000008>;
251 virtual-reg = <0xef600300>;
252 clock-frequency = <0>; /* Filled in by U-Boot */
253 current-speed = <0>; /* Filled in by U-Boot */
254 interrupt-parent = <&UIC0>;
255 interrupts = <0x1 0x4>;
256 };
257
258 IIC0: i2c@ef600400 {
259 compatible = "ibm,iic-460sx", "ibm,iic";
260 reg = <0xef600400 0x00000014>;
261 interrupt-parent = <&UIC0>;
262 interrupts = <0x2 0x4>;
263 #address-cells = <1>;
264 #size-cells = <0>;
265 index = <0>;
266 };
267
268 IIC1: i2c@ef600500 {
269 compatible = "ibm,iic-460sx", "ibm,iic";
270 reg = <0xef600500 0x00000014>;
271 interrupt-parent = <&UIC0>;
272 interrupts = <0x3 0x4>;
273 #address-cells = <1>;
274 #size-cells = <0>;
275 index = <1>;
276 };
277
278 RGMII0: emac-rgmii@ef600900 {
279 compatible = "ibm,rgmii-460sx", "ibm,rgmii";
280 reg = <0xef600900 0x00000008>;
281 has-mdio;
282 };
283
284 RGMII1: emac-rgmii@ef600920 {
285 compatible = "ibm,rgmii-460sx", "ibm,rgmii";
286 reg = <0xef600920 0x00000008>;
287 has-mdio;
288 };
289
290 TAH0: emac-tah@ef600e50 {
291 compatible = "ibm,tah-460sx", "ibm,tah";
292 reg = <0xef600e50 0x00000030>;
293 };
294
295 TAH1: emac-tah@ef600f50 {
296 compatible = "ibm,tah-460sx", "ibm,tah";
297 reg = <0xef600f50 0x00000030>;
298 };
299
300 EMAC0: ethernet@ef600a00 {
301 device_type = "network";
302 compatible = "ibm,emac-460sx", "ibm,emac4";
303 interrupt-parent = <&EMAC0>;
304 interrupts = <0x0 0x1>;
305 #interrupt-cells = <1>;
306 #address-cells = <0>;
307 #size-cells = <0>;
308 interrupt-map = </*Status*/ 0x0 &UIC0 0x13 0x4
309 /*Wake*/ 0x1 &UIC2 0x1d 0x4>;
310 reg = <0xef600a00 0x00000070>;
311 local-mac-address = [000000000000]; /* Filled in by U-Boot */
312 mal-device = <&MAL0>;
313 mal-tx-channel = <0>;
314 mal-rx-channel = <0>;
315 cell-index = <0>;
316 max-frame-size = <9000>;
317 rx-fifo-size = <4096>;
318 tx-fifo-size = <2048>;
319 phy-mode = "rgmii";
320 phy-map = <0x00000000>;
321 rgmii-device = <&RGMII0>;
322 rgmii-channel = <0>;
323 tah-device = <&TAH0>;
324 tah-channel = <0>;
325 has-inverted-stacr-oc;
326 has-new-stacr-staopc;
327 };
328
329 EMAC1: ethernet@ef600b00 {
330 device_type = "network";
331 compatible = "ibm,emac-460sx", "ibm,emac4";
332 interrupt-parent = <&EMAC1>;
333 interrupts = <0x0 0x1>;
334 #interrupt-cells = <1>;
335 #address-cells = <0>;
336 #size-cells = <0>;
337 interrupt-map = </*Status*/ 0x0 &UIC0 0x14 0x4
338 /*Wake*/ 0x1 &UIC2 0x1d 0x4>;
339 reg = <0xef600b00 0x00000070>;
340 local-mac-address = [000000000000]; /* Filled in by U-Boot */
341 mal-device = <&MAL0>;
342 mal-tx-channel = <1>;
343 mal-rx-channel = <8>;
344 cell-index = <1>;
345 max-frame-size = <9000>;
346 rx-fifo-size = <4096>;
347 tx-fifo-size = <2048>;
348 phy-mode = "rgmii";
349 phy-map = <0x00000000>;
350 rgmii-device = <&RGMII0>;
351 rgmii-channel = <1>;
352 tah-device = <&TAH1>;
353 tah-channel = <1>;
354 has-inverted-stacr-oc;
355 has-new-stacr-staopc;
356 mdio-device = <&EMAC0>;
357 };
358
359 EMAC2: ethernet@ef600c00 {
360 device_type = "network";
361 compatible = "ibm,emac-460sx", "ibm,emac4";
362 interrupt-parent = <&EMAC2>;
363 interrupts = <0x0 0x1>;
364 #interrupt-cells = <1>;
365 #address-cells = <0>;
366 #size-cells = <0>;
367 interrupt-map = </*Status*/ 0x0 &UIC0 0x15 0x4
368 /*Wake*/ 0x1 &UIC2 0x1d 0x4>;
369 reg = <0xef600c00 0x00000070>;
370 local-mac-address = [000000000000]; /* Filled in by U-Boot */
371 mal-device = <&MAL0>;
372 mal-tx-channel = <2>;
373 mal-rx-channel = <16>;
374 cell-index = <2>;
375 max-frame-size = <9000>;
376 rx-fifo-size = <4096>;
377 tx-fifo-size = <2048>;
378 phy-mode = "rgmii";
379 phy-map = <0x00000000>;
380 rgmii-device = <&RGMII1>;
381 rgmii-channel = <0>;
382 has-inverted-stacr-oc;
383 has-new-stacr-staopc;
384 mdio-device = <&EMAC0>;
385 };
386
387 EMAC3: ethernet@ef600d00 {
388 device_type = "network";
389 compatible = "ibm,emac-460sx", "ibm,emac4";
390 interrupt-parent = <&EMAC3>;
391 interrupts = <0x0 0x1>;
392 #interrupt-cells = <1>;
393 #address-cells = <0>;
394 #size-cells = <0>;
395 interrupt-map = </*Status*/ 0x0 &UIC0 0x16 0x4
396 /*Wake*/ 0x1 &UIC2 0x1d 0x4>;
397 reg = <0xef600d00 0x00000070>;
398 local-mac-address = [000000000000]; /* Filled in by U-Boot */
399 mal-device = <&MAL0>;
400 mal-tx-channel = <3>;
401 mal-rx-channel = <24>;
402 cell-index = <3>;
403 max-frame-size = <9000>;
404 rx-fifo-size = <4096>;
405 tx-fifo-size = <2048>;
406 phy-mode = "rgmii";
407 phy-map = <0x00000000>;
408 rgmii-device = <&RGMII1>;
409 rgmii-channel = <1>;
410 has-inverted-stacr-oc;
411 has-new-stacr-staopc;
412 mdio-device = <&EMAC0>;
413 };
414 };
415
416 };
417 chosen {
418 linux,stdout-path = "/plb/opb/serial@ef600200";
419 };
420
421};
diff --git a/arch/powerpc/boot/dts/gef_sbc310.dts b/arch/powerpc/boot/dts/gef_sbc310.dts
index 0f4c9ec2c3a6..2107d3c7cfe1 100644
--- a/arch/powerpc/boot/dts/gef_sbc310.dts
+++ b/arch/powerpc/boot/dts/gef_sbc310.dts
@@ -83,34 +83,34 @@
83 83
84 /* flash@0,0 is a mirror of part of the memory in flash@1,0 84 /* flash@0,0 is a mirror of part of the memory in flash@1,0
85 flash@0,0 { 85 flash@0,0 {
86 compatible = "cfi-flash"; 86 compatible = "gef,sbc310-firmware-mirror", "cfi-flash";
87 reg = <0 0 0x01000000>; 87 reg = <0x0 0x0 0x01000000>;
88 bank-width = <2>; 88 bank-width = <2>;
89 device-width = <2>; 89 device-width = <2>;
90 #address-cells = <1>; 90 #address-cells = <1>;
91 #size-cells = <1>; 91 #size-cells = <1>;
92 partition@0 { 92 partition@0 {
93 label = "firmware"; 93 label = "firmware";
94 reg = <0x00000000 0x01000000>; 94 reg = <0x0 0x01000000>;
95 read-only; 95 read-only;
96 }; 96 };
97 }; 97 };
98 */ 98 */
99 99
100 flash@1,0 { 100 flash@1,0 {
101 compatible = "cfi-flash"; 101 compatible = "gef,sbc310-paged-flash", "cfi-flash";
102 reg = <1 0 0x8000000>; 102 reg = <0x1 0x0 0x8000000>;
103 bank-width = <2>; 103 bank-width = <2>;
104 device-width = <2>; 104 device-width = <2>;
105 #address-cells = <1>; 105 #address-cells = <1>;
106 #size-cells = <1>; 106 #size-cells = <1>;
107 partition@0 { 107 partition@0 {
108 label = "user"; 108 label = "user";
109 reg = <0x00000000 0x07800000>; 109 reg = <0x0 0x7800000>;
110 }; 110 };
111 partition@7800000 { 111 partition@7800000 {
112 label = "firmware"; 112 label = "firmware";
113 reg = <0x07800000 0x00800000>; 113 reg = <0x7800000 0x800000>;
114 read-only; 114 read-only;
115 }; 115 };
116 }; 116 };
@@ -121,18 +121,16 @@
121 }; 121 };
122 122
123 wdt@4,2000 { 123 wdt@4,2000 {
124 #interrupt-cells = <2>; 124 compatible = "gef,sbc310-fpga-wdt", "gef,fpga-wdt-1.00",
125 device_type = "watchdog"; 125 "gef,fpga-wdt";
126 compatible = "gef,fpga-wdt";
127 reg = <0x4 0x2000 0x8>; 126 reg = <0x4 0x2000 0x8>;
128 interrupts = <0x1a 0x4>; 127 interrupts = <0x1a 0x4>;
129 interrupt-parent = <&gef_pic>; 128 interrupt-parent = <&gef_pic>;
130 }; 129 };
131/* 130/*
132 wdt@4,2010 { 131 wdt@4,2010 {
133 #interrupt-cells = <2>; 132 compatible = "gef,sbc310-fpga-wdt", "gef,fpga-wdt-1.00",
134 device_type = "watchdog"; 133 "gef,fpga-wdt";
135 compatible = "gef,fpga-wdt";
136 reg = <0x4 0x2010 0x8>; 134 reg = <0x4 0x2010 0x8>;
137 interrupts = <0x1b 0x4>; 135 interrupts = <0x1b 0x4>;
138 interrupt-parent = <&gef_pic>; 136 interrupt-parent = <&gef_pic>;
@@ -141,7 +139,7 @@
141 gef_pic: pic@4,4000 { 139 gef_pic: pic@4,4000 {
142 #interrupt-cells = <1>; 140 #interrupt-cells = <1>;
143 interrupt-controller; 141 interrupt-controller;
144 compatible = "gef,fpga-pic"; 142 compatible = "gef,sbc310-fpga-pic", "gef,fpga-pic";
145 reg = <0x4 0x4000 0x20>; 143 reg = <0x4 0x4000 0x20>;
146 interrupts = <0x8 144 interrupts = <0x8
147 0x9>; 145 0x9>;
@@ -161,7 +159,7 @@
161 #size-cells = <1>; 159 #size-cells = <1>;
162 #interrupt-cells = <2>; 160 #interrupt-cells = <2>;
163 device_type = "soc"; 161 device_type = "soc";
164 compatible = "simple-bus"; 162 compatible = "fsl,mpc8641-soc", "simple-bus";
165 ranges = <0x0 0xfef00000 0x00100000>; 163 ranges = <0x0 0xfef00000 0x00100000>;
166 bus-frequency = <33333333>; 164 bus-frequency = <33333333>;
167 165
@@ -376,4 +374,40 @@
376 0x0 0x00400000>; 374 0x0 0x00400000>;
377 }; 375 };
378 }; 376 };
377
378 pci1: pcie@fef09000 {
379 compatible = "fsl,mpc8641-pcie";
380 device_type = "pci";
381 #interrupt-cells = <1>;
382 #size-cells = <2>;
383 #address-cells = <3>;
384 reg = <0xfef09000 0x1000>;
385 bus-range = <0x0 0xff>;
386 ranges = <0x02000000 0x0 0xc0000000 0xc0000000 0x0 0x20000000
387 0x01000000 0x0 0x00000000 0xfe400000 0x0 0x00400000>;
388 clock-frequency = <33333333>;
389 interrupt-parent = <&mpic>;
390 interrupts = <0x19 0x2>;
391 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
392 interrupt-map = <
393 0x0000 0x0 0x0 0x1 &mpic 0x4 0x2
394 0x0000 0x0 0x0 0x2 &mpic 0x5 0x2
395 0x0000 0x0 0x0 0x3 &mpic 0x6 0x2
396 0x0000 0x0 0x0 0x4 &mpic 0x7 0x2
397 >;
398
399 pcie@0 {
400 reg = <0 0 0 0 0>;
401 #size-cells = <2>;
402 #address-cells = <3>;
403 device_type = "pci";
404 ranges = <0x02000000 0x0 0xc0000000
405 0x02000000 0x0 0xc0000000
406 0x0 0x20000000
407
408 0x01000000 0x0 0x00000000
409 0x01000000 0x0 0x00000000
410 0x0 0x00400000>;
411 };
412 };
379}; 413};
diff --git a/arch/powerpc/boot/dts/hotfoot.dts b/arch/powerpc/boot/dts/hotfoot.dts
new file mode 100644
index 000000000000..cad9c3840afc
--- /dev/null
+++ b/arch/powerpc/boot/dts/hotfoot.dts
@@ -0,0 +1,294 @@
1/*
2 * Device Tree Source for ESTeem 195E Hotfoot
3 *
4 * Copyright 2009 AbsoluteValue Systems <solomon@linux-wlan.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without
8 * any warranty of any kind, whether express or implied.
9 */
10
11/dts-v1/;
12
13/ {
14 #address-cells = <1>;
15 #size-cells = <1>;
16 model = "est,hotfoot";
17 compatible = "est,hotfoot";
18 dcr-parent = <&{/cpus/cpu@0}>;
19
20 aliases {
21 ethernet0 = &EMAC0;
22 ethernet1 = &EMAC1;
23 serial0 = &UART0;
24 serial1 = &UART1;
25 };
26
27 cpus {
28 #address-cells = <1>;
29 #size-cells = <0>;
30
31 cpu@0 {
32 device_type = "cpu";
33 model = "PowerPC,405EP";
34 reg = <0x00000000>;
35 clock-frequency = <0>; /* Filled in by zImage */
36 timebase-frequency = <0>; /* Filled in by zImage */
37 i-cache-line-size = <0x20>;
38 d-cache-line-size = <0x20>;
39 i-cache-size = <0x4000>;
40 d-cache-size = <0x4000>;
41 dcr-controller;
42 dcr-access-method = "native";
43 };
44 };
45
46 memory {
47 device_type = "memory";
48 reg = <0x00000000 0x00000000>; /* Filled in by zImage */
49 };
50
51 UIC0: interrupt-controller {
52 compatible = "ibm,uic";
53 interrupt-controller;
54 cell-index = <0>;
55 dcr-reg = <0x0c0 0x009>;
56 #address-cells = <0>;
57 #size-cells = <0>;
58 #interrupt-cells = <2>;
59 };
60
61 plb {
62 compatible = "ibm,plb3";
63 #address-cells = <1>;
64 #size-cells = <1>;
65 ranges;
66 clock-frequency = <0>; /* Filled in by zImage */
67
68 SDRAM0: memory-controller {
69 compatible = "ibm,sdram-405ep";
70 dcr-reg = <0x010 0x002>;
71 };
72
73 MAL: mcmal {
74 compatible = "ibm,mcmal-405ep", "ibm,mcmal";
75 dcr-reg = <0x180 0x062>;
76 num-tx-chans = <4>;
77 num-rx-chans = <2>;
78 interrupt-parent = <&UIC0>;
79 interrupts = <
80 0xb 0x4 /* TXEOB */
81 0xc 0x4 /* RXEOB */
82 0xa 0x4 /* SERR */
83 0xd 0x4 /* TXDE */
84 0xe 0x4 /* RXDE */>;
85 };
86
87 POB0: opb {
88 compatible = "ibm,opb-405ep", "ibm,opb";
89 #address-cells = <1>;
90 #size-cells = <1>;
91 ranges = <0xef600000 0xef600000 0x00a00000>;
92 dcr-reg = <0x0a0 0x005>;
93 clock-frequency = <0>; /* Filled in by zImage */
94
95 /* Hotfoot has UART0/UART1 swapped */
96
97 UART0: serial@ef600400 {
98 device_type = "serial";
99 compatible = "ns16550";
100 reg = <0xef600400 0x00000008>;
101 virtual-reg = <0xef600400>;
102 clock-frequency = <0>; /* Filled in by zImage */
103 current-speed = <0x9600>;
104 interrupt-parent = <&UIC0>;
105 interrupts = <0x1 0x4>;
106 };
107
108 UART1: serial@ef600300 {
109 device_type = "serial";
110 compatible = "ns16550";
111 reg = <0xef600300 0x00000008>;
112 virtual-reg = <0xef600300>;
113 clock-frequency = <0>; /* Filled in by zImage */
114 current-speed = <0x9600>;
115 interrupt-parent = <&UIC0>;
116 interrupts = <0x0 0x4>;
117 };
118
119 IIC: i2c@ef600500 {
120 compatible = "ibm,iic-405ep", "ibm,iic";
121 reg = <0xef600500 0x00000011>;
122 interrupt-parent = <&UIC0>;
123 interrupts = <0x2 0x4>;
124
125 rtc@68 {
126 /* Actually a DS1339 */
127 compatible = "dallas,ds1307";
128 reg = <0x68>;
129 };
130
131 temp@4a {
132 /* Not present on all boards */
133 compatible = "national,lm75";
134 reg = <0x4a>;
135 };
136 };
137
138 GPIO: gpio@ef600700 {
139 #gpio-cells = <2>;
140 compatible = "ibm,ppc4xx-gpio";
141 reg = <0xef600700 0x00000020>;
142 gpio-controller;
143 };
144
145 gpio-leds {
146 compatible = "gpio-leds";
147 status {
148 label = "Status";
149 gpios = <&GPIO 1 0>;
150 };
151 radiorx {
152 label = "Rx";
153 gpios = <&GPIO 0xe 0>;
154 };
155 };
156
157 EMAC0: ethernet@ef600800 {
158 linux,network-index = <0x0>;
159 device_type = "network";
160 compatible = "ibm,emac-405ep", "ibm,emac";
161 interrupt-parent = <&UIC0>;
162 interrupts = <
163 0xf 0x4 /* Ethernet */
164 0x9 0x4 /* Ethernet Wake Up */>;
165 local-mac-address = [000000000000]; /* Filled in by zImage */
166 reg = <0xef600800 0x00000070>;
167 mal-device = <&MAL>;
168 mal-tx-channel = <0>;
169 mal-rx-channel = <0>;
170 cell-index = <0>;
171 max-frame-size = <0x5dc>;
172 rx-fifo-size = <0x1000>;
173 tx-fifo-size = <0x800>;
174 phy-mode = "mii";
175 phy-map = <0x00000000>;
176 };
177
178 EMAC1: ethernet@ef600900 {
179 linux,network-index = <0x1>;
180 device_type = "network";
181 compatible = "ibm,emac-405ep", "ibm,emac";
182 interrupt-parent = <&UIC0>;
183 interrupts = <
184 0x11 0x4 /* Ethernet */
185 0x9 0x4 /* Ethernet Wake Up */>;
186 local-mac-address = [000000000000]; /* Filled in by zImage */
187 reg = <0xef600900 0x00000070>;
188 mal-device = <&MAL>;
189 mal-tx-channel = <2>;
190 mal-rx-channel = <1>;
191 cell-index = <1>;
192 max-frame-size = <0x5dc>;
193 rx-fifo-size = <0x1000>;
194 tx-fifo-size = <0x800>;
195 mdio-device = <&EMAC0>;
196 phy-mode = "mii";
197 phy-map = <0x0000001>;
198 };
199 };
200
201 EBC0: ebc {
202 compatible = "ibm,ebc-405ep", "ibm,ebc";
203 dcr-reg = <0x012 0x002>;
204 #address-cells = <2>;
205 #size-cells = <1>;
206
207 /* The ranges property is supplied by the bootwrapper
208 * and is based on the firmware's configuration of the
209 * EBC bridge
210 */
211 clock-frequency = <0>; /* Filled in by zImage */
212
213 nor_flash@0 {
214 compatible = "cfi-flash";
215 bank-width = <2>;
216 reg = <0x0 0xff800000 0x00800000>;
217 #address-cells = <1>;
218 #size-cells = <1>;
219
220 /* This mapping is for the 8M flash
221 4M flash has all ofssets -= 4M,
222 and FeatFS partition is not present */
223 partition@0 {
224 label = "Bootloader";
225 reg = <0x7c0000 0x40000>;
226 /* read-only; */
227 };
228 partition@1 {
229 label = "Env_and_Config_Primary";
230 reg = <0x400000 0x10000>;
231 };
232 partition@2 {
233 label = "Kernel";
234 reg = <0x420000 0x100000>;
235 };
236 partition@3 {
237 label = "Filesystem";
238 reg = <0x520000 0x2a0000>;
239 };
240 partition@4 {
241 label = "Env_and_Config_Secondary";
242 reg = <0x410000 0x10000>;
243 };
244 partition@5 {
245 label = "FeatFS";
246 reg = <0x000000 0x400000>;
247 };
248 partition@6 {
249 label = "Bootloader_Env";
250 reg = <0x7d0000 0x10000>;
251 };
252 };
253 };
254
255 PCI0: pci@ec000000 {
256 device_type = "pci";
257 #interrupt-cells = <1>;
258 #size-cells = <2>;
259 #address-cells = <3>;
260 compatible = "ibm,plb405ep-pci", "ibm,plb-pci";
261 primary;
262 reg = <0xeec00000 0x00000008 /* Config space access */
263 0xeed80000 0x00000004 /* IACK */
264 0xeed80000 0x00000004 /* Special cycle */
265 0xef480000 0x00000040>; /* Internal registers */
266
267 /* Outbound ranges, one memory and one IO,
268 * later cannot be changed. Chip supports a second
269 * IO range but we don't use it for now
270 */
271 ranges = <0x02000000 0x00000000 0x80000000 0x80000000 0x00000000 0x20000000
272 0x01000000 0x00000000 0x00000000 0xe8000000 0x00000000 0x00010000>;
273
274 /* Inbound 2GB range starting at 0 */
275 dma-ranges = <0x42000000 0x0 0x0 0x0 0x0 0x80000000>;
276
277 interrupt-parent = <&UIC0>;
278 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
279 interrupt-map = <
280 /* IDSEL 3 -- slot1 (optional) 27/29 A/B IRQ2/4 */
281 0x1800 0x0 0x0 0x1 &UIC0 0x1b 0x8
282 0x1800 0x0 0x0 0x2 &UIC0 0x1d 0x8
283
284 /* IDSEL 4 -- slot0, 26/28 A/B IRQ1/3 */
285 0x2000 0x0 0x0 0x1 &UIC0 0x1a 0x8
286 0x2000 0x0 0x0 0x2 &UIC0 0x1c 0x8
287 >;
288 };
289 };
290
291 chosen {
292 linux,stdout-path = &UART0;
293 };
294};
diff --git a/arch/powerpc/boot/dts/kilauea.dts b/arch/powerpc/boot/dts/kilauea.dts
index 5e6b08ff6f67..c46561456ede 100644
--- a/arch/powerpc/boot/dts/kilauea.dts
+++ b/arch/powerpc/boot/dts/kilauea.dts
@@ -1,7 +1,7 @@
1/* 1/*
2 * Device Tree Source for AMCC Kilauea (405EX) 2 * Device Tree Source for AMCC Kilauea (405EX)
3 * 3 *
4 * Copyright 2007 DENX Software Engineering, Stefan Roese <sr@denx.de> 4 * Copyright 2007-2009 DENX Software Engineering, Stefan Roese <sr@denx.de>
5 * 5 *
6 * This file is licensed under the terms of the GNU General Public 6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without 7 * License version 2. This program is licensed "as is" without
@@ -150,7 +150,11 @@
150 #size-cells = <1>; 150 #size-cells = <1>;
151 partition@0 { 151 partition@0 {
152 label = "kernel"; 152 label = "kernel";
153 reg = <0x00000000 0x00200000>; 153 reg = <0x00000000 0x001e0000>;
154 };
155 partition@1e0000 {
156 label = "dtb";
157 reg = <0x001e0000 0x00020000>;
154 }; 158 };
155 partition@200000 { 159 partition@200000 {
156 label = "root"; 160 label = "root";
@@ -169,6 +173,29 @@
169 reg = <0x03fa0000 0x00060000>; 173 reg = <0x03fa0000 0x00060000>;
170 }; 174 };
171 }; 175 };
176
177 ndfc@1,0 {
178 compatible = "ibm,ndfc";
179 reg = <0x00000001 0x00000000 0x00002000>;
180 ccr = <0x00001000>;
181 bank-settings = <0x80002222>;
182 #address-cells = <1>;
183 #size-cells = <1>;
184
185 nand {
186 #address-cells = <1>;
187 #size-cells = <1>;
188
189 partition@0 {
190 label = "u-boot";
191 reg = <0x00000000 0x00100000>;
192 };
193 partition@100000 {
194 label = "user";
195 reg = <0x00000000 0x03f00000>;
196 };
197 };
198 };
172 }; 199 };
173 200
174 UART0: serial@ef600200 { 201 UART0: serial@ef600200 {
@@ -198,6 +225,18 @@
198 reg = <0xef600400 0x00000014>; 225 reg = <0xef600400 0x00000014>;
199 interrupt-parent = <&UIC0>; 226 interrupt-parent = <&UIC0>;
200 interrupts = <0x2 0x4>; 227 interrupts = <0x2 0x4>;
228 #address-cells = <1>;
229 #size-cells = <0>;
230
231 rtc@68 {
232 compatible = "dallas,ds1338";
233 reg = <0x68>;
234 };
235
236 dtt@48 {
237 compatible = "dallas,ds1775";
238 reg = <0x48>;
239 };
201 }; 240 };
202 241
203 IIC1: i2c@ef600500 { 242 IIC1: i2c@ef600500 {
@@ -207,7 +246,6 @@
207 interrupts = <0x7 0x4>; 246 interrupts = <0x7 0x4>;
208 }; 247 };
209 248
210
211 RGMII0: emac-rgmii@ef600b00 { 249 RGMII0: emac-rgmii@ef600b00 {
212 compatible = "ibm,rgmii-405ex", "ibm,rgmii"; 250 compatible = "ibm,rgmii-405ex", "ibm,rgmii";
213 reg = <0xef600b00 0x00000104>; 251 reg = <0xef600b00 0x00000104>;
diff --git a/arch/powerpc/boot/dts/mgcoge.dts b/arch/powerpc/boot/dts/mgcoge.dts
index 633255a97557..0ce96644176d 100644
--- a/arch/powerpc/boot/dts/mgcoge.dts
+++ b/arch/powerpc/boot/dts/mgcoge.dts
@@ -162,6 +162,59 @@
162 fixed-link = <0 0 10 0 0>; 162 fixed-link = <0 0 10 0 0>;
163 }; 163 };
164 164
165 i2c@11860 {
166 compatible = "fsl,mpc8272-i2c",
167 "fsl,cpm2-i2c";
168 reg = <0x11860 0x20 0x8afc 0x2>;
169 interrupts = <1 8>;
170 interrupt-parent = <&PIC>;
171 fsl,cpm-command = <0x29600000>;
172 #address-cells = <1>;
173 #size-cells = <0>;
174 };
175
176 mdio@10d40 {
177 compatible = "fsl,cpm2-mdio-bitbang";
178 reg = <0x10d00 0x14>;
179 #address-cells = <1>;
180 #size-cells = <0>;
181 fsl,mdio-pin = <12>;
182 fsl,mdc-pin = <13>;
183
184 phy0: ethernet-phy@0 {
185 reg = <0x0>;
186 };
187
188 phy1: ethernet-phy@1 {
189 reg = <0x1>;
190 };
191 };
192
193 /* FCC1 management to switch */
194 ethernet@11300 {
195 device_type = "network";
196 compatible = "fsl,cpm2-fcc-enet";
197 reg = <0x11300 0x20 0x8400 0x100 0x11390 0x1>;
198 local-mac-address = [ 00 01 02 03 04 07 ];
199 interrupts = <32 8>;
200 interrupt-parent = <&PIC>;
201 phy-handle = <&phy0>;
202 linux,network-index = <1>;
203 fsl,cpm-command = <0x12000300>;
204 };
205
206 /* FCC2 to redundant core unit over backplane */
207 ethernet@11320 {
208 device_type = "network";
209 compatible = "fsl,cpm2-fcc-enet";
210 reg = <0x11320 0x20 0x8500 0x100 0x113b0 0x1>;
211 local-mac-address = [ 00 01 02 03 04 08 ];
212 interrupts = <33 8>;
213 interrupt-parent = <&PIC>;
214 phy-handle = <&phy1>;
215 linux,network-index = <2>;
216 fsl,cpm-command = <0x16200300>;
217 };
165 }; 218 };
166 219
167 PIC: interrupt-controller@10c00 { 220 PIC: interrupt-controller@10c00 {
diff --git a/arch/powerpc/boot/dts/mpc8272ads.dts b/arch/powerpc/boot/dts/mpc8272ads.dts
index 60f332778e41..e802ebd88cb1 100644
--- a/arch/powerpc/boot/dts/mpc8272ads.dts
+++ b/arch/powerpc/boot/dts/mpc8272ads.dts
@@ -173,6 +173,14 @@
173 fsl,cpm-command = <0xce00000>; 173 fsl,cpm-command = <0xce00000>;
174 }; 174 };
175 175
176 usb@11b60 {
177 compatible = "fsl,mpc8272-cpm-usb";
178 reg = <0x11b60 0x40 0x8b00 0x100>;
179 interrupts = <11 8>;
180 interrupt-parent = <&PIC>;
181 mode = "peripheral";
182 };
183
176 mdio@10d40 { 184 mdio@10d40 {
177 device_type = "mdio"; 185 device_type = "mdio";
178 compatible = "fsl,mpc8272ads-mdio-bitbang", 186 compatible = "fsl,mpc8272ads-mdio-bitbang",
diff --git a/arch/powerpc/boot/dts/mpc8377_rdb.dts b/arch/powerpc/boot/dts/mpc8377_rdb.dts
index 4f06dbc0d27e..28e022ac4179 100644
--- a/arch/powerpc/boot/dts/mpc8377_rdb.dts
+++ b/arch/powerpc/boot/dts/mpc8377_rdb.dts
@@ -174,7 +174,7 @@
174 interrupts = <42 0x8>; 174 interrupts = <42 0x8>;
175 interrupt-parent = <&ipic>; 175 interrupt-parent = <&ipic>;
176 /* Filled in by U-Boot */ 176 /* Filled in by U-Boot */
177 clock-frequency = <0>; 177 clock-frequency = <111111111>;
178 }; 178 };
179 }; 179 };
180 180
diff --git a/arch/powerpc/boot/dts/mpc8377_wlan.dts b/arch/powerpc/boot/dts/mpc8377_wlan.dts
new file mode 100644
index 000000000000..3febc4e91b10
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc8377_wlan.dts
@@ -0,0 +1,464 @@
1/*
2 * MPC8377E WLAN Device Tree Source
3 *
4 * Copyright 2007-2009 Freescale Semiconductor Inc.
5 * Copyright 2009 MontaVista Software, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13/dts-v1/;
14
15/ {
16 compatible = "fsl,mpc8377wlan";
17 #address-cells = <1>;
18 #size-cells = <1>;
19
20 aliases {
21 ethernet0 = &enet0;
22 ethernet1 = &enet1;
23 serial0 = &serial0;
24 serial1 = &serial1;
25 pci0 = &pci0;
26 pci1 = &pci1;
27 pci2 = &pci2;
28 };
29
30 cpus {
31 #address-cells = <1>;
32 #size-cells = <0>;
33
34 PowerPC,8377@0 {
35 device_type = "cpu";
36 reg = <0x0>;
37 d-cache-line-size = <32>;
38 i-cache-line-size = <32>;
39 d-cache-size = <32768>;
40 i-cache-size = <32768>;
41 timebase-frequency = <0>;
42 bus-frequency = <0>;
43 clock-frequency = <0>;
44 };
45 };
46
47 memory {
48 device_type = "memory";
49 reg = <0x00000000 0x20000000>; // 512MB at 0
50 };
51
52 localbus@e0005000 {
53 #address-cells = <2>;
54 #size-cells = <1>;
55 compatible = "fsl,mpc8377-elbc", "fsl,elbc", "simple-bus";
56 reg = <0xe0005000 0x1000>;
57 interrupts = <77 0x8>;
58 interrupt-parent = <&ipic>;
59 ranges = <0x0 0x0 0xfc000000 0x04000000>;
60
61 flash@0,0 {
62 #address-cells = <1>;
63 #size-cells = <1>;
64 compatible = "cfi-flash";
65 reg = <0x0 0x0 0x4000000>;
66 bank-width = <2>;
67 device-width = <1>;
68
69 partition@0 {
70 reg = <0 0x8000>;
71 label = "u-boot";
72 read-only;
73 };
74
75 partition@a0000 {
76 reg = <0xa0000 0x300000>;
77 label = "kernel";
78 };
79
80 partition@3a0000 {
81 reg = <0x3a0000 0x3c60000>;
82 label = "rootfs";
83 };
84 };
85 };
86
87 immr@e0000000 {
88 #address-cells = <1>;
89 #size-cells = <1>;
90 device_type = "soc";
91 compatible = "simple-bus";
92 ranges = <0x0 0xe0000000 0x00100000>;
93 reg = <0xe0000000 0x00000200>;
94 bus-frequency = <0>;
95
96 wdt@200 {
97 device_type = "watchdog";
98 compatible = "mpc83xx_wdt";
99 reg = <0x200 0x100>;
100 };
101
102 gpio1: gpio-controller@c00 {
103 #gpio-cells = <2>;
104 compatible = "fsl,mpc8377-gpio", "fsl,mpc8349-gpio";
105 reg = <0xc00 0x100>;
106 interrupts = <74 0x8>;
107 interrupt-parent = <&ipic>;
108 gpio-controller;
109 };
110
111 gpio2: gpio-controller@d00 {
112 #gpio-cells = <2>;
113 compatible = "fsl,mpc8377-gpio", "fsl,mpc8349-gpio";
114 reg = <0xd00 0x100>;
115 interrupts = <75 0x8>;
116 interrupt-parent = <&ipic>;
117 gpio-controller;
118 };
119
120 sleep-nexus {
121 #address-cells = <1>;
122 #size-cells = <1>;
123 compatible = "simple-bus";
124 sleep = <&pmc 0x0c000000>;
125 ranges;
126
127 i2c@3000 {
128 #address-cells = <1>;
129 #size-cells = <0>;
130 cell-index = <0>;
131 compatible = "fsl-i2c";
132 reg = <0x3000 0x100>;
133 interrupts = <14 0x8>;
134 interrupt-parent = <&ipic>;
135 dfsrr;
136
137 at24@50 {
138 compatible = "at24,24c256";
139 reg = <0x50>;
140 };
141
142 rtc@68 {
143 compatible = "dallas,ds1339";
144 reg = <0x68>;
145 };
146 };
147
148 sdhci@2e000 {
149 compatible = "fsl,mpc8377-esdhc", "fsl,esdhc";
150 reg = <0x2e000 0x1000>;
151 interrupts = <42 0x8>;
152 interrupt-parent = <&ipic>;
153 clock-frequency = <133333333>;
154 };
155 };
156
157 i2c@3100 {
158 #address-cells = <1>;
159 #size-cells = <0>;
160 cell-index = <1>;
161 compatible = "fsl-i2c";
162 reg = <0x3100 0x100>;
163 interrupts = <15 0x8>;
164 interrupt-parent = <&ipic>;
165 dfsrr;
166 };
167
168 spi@7000 {
169 cell-index = <0>;
170 compatible = "fsl,spi";
171 reg = <0x7000 0x1000>;
172 interrupts = <16 0x8>;
173 interrupt-parent = <&ipic>;
174 mode = "cpu";
175 };
176
177 dma@82a8 {
178 #address-cells = <1>;
179 #size-cells = <1>;
180 compatible = "fsl,mpc8377-dma", "fsl,elo-dma";
181 reg = <0x82a8 4>;
182 ranges = <0 0x8100 0x1a8>;
183 interrupt-parent = <&ipic>;
184 interrupts = <71 8>;
185 cell-index = <0>;
186 dma-channel@0 {
187 compatible = "fsl,mpc8377-dma-channel", "fsl,elo-dma-channel";
188 reg = <0 0x80>;
189 cell-index = <0>;
190 interrupt-parent = <&ipic>;
191 interrupts = <71 8>;
192 };
193 dma-channel@80 {
194 compatible = "fsl,mpc8377-dma-channel", "fsl,elo-dma-channel";
195 reg = <0x80 0x80>;
196 cell-index = <1>;
197 interrupt-parent = <&ipic>;
198 interrupts = <71 8>;
199 };
200 dma-channel@100 {
201 compatible = "fsl,mpc8377-dma-channel", "fsl,elo-dma-channel";
202 reg = <0x100 0x80>;
203 cell-index = <2>;
204 interrupt-parent = <&ipic>;
205 interrupts = <71 8>;
206 };
207 dma-channel@180 {
208 compatible = "fsl,mpc8377-dma-channel", "fsl,elo-dma-channel";
209 reg = <0x180 0x28>;
210 cell-index = <3>;
211 interrupt-parent = <&ipic>;
212 interrupts = <71 8>;
213 };
214 };
215
216 usb@23000 {
217 compatible = "fsl-usb2-dr";
218 reg = <0x23000 0x1000>;
219 #address-cells = <1>;
220 #size-cells = <0>;
221 interrupt-parent = <&ipic>;
222 interrupts = <38 0x8>;
223 phy_type = "ulpi";
224 sleep = <&pmc 0x00c00000>;
225 };
226
227 enet0: ethernet@24000 {
228 #address-cells = <1>;
229 #size-cells = <1>;
230 cell-index = <0>;
231 device_type = "network";
232 model = "eTSEC";
233 compatible = "gianfar";
234 reg = <0x24000 0x1000>;
235 ranges = <0x0 0x24000 0x1000>;
236 local-mac-address = [ 00 00 00 00 00 00 ];
237 interrupts = <32 0x8 33 0x8 34 0x8>;
238 phy-connection-type = "mii";
239 interrupt-parent = <&ipic>;
240 tbi-handle = <&tbi0>;
241 phy-handle = <&phy2>;
242 sleep = <&pmc 0xc0000000>;
243 fsl,magic-packet;
244
245 mdio@520 {
246 #address-cells = <1>;
247 #size-cells = <0>;
248 compatible = "fsl,gianfar-mdio";
249 reg = <0x520 0x20>;
250
251 phy2: ethernet-phy@2 {
252 interrupt-parent = <&ipic>;
253 interrupts = <17 0x8>;
254 reg = <0x2>;
255 device_type = "ethernet-phy";
256 };
257
258 phy3: ethernet-phy@3 {
259 interrupt-parent = <&ipic>;
260 interrupts = <18 0x8>;
261 reg = <0x3>;
262 device_type = "ethernet-phy";
263 };
264
265 tbi0: tbi-phy@11 {
266 reg = <0x11>;
267 device_type = "tbi-phy";
268 };
269 };
270 };
271
272 enet1: ethernet@25000 {
273 #address-cells = <1>;
274 #size-cells = <1>;
275 cell-index = <1>;
276 device_type = "network";
277 model = "eTSEC";
278 compatible = "gianfar";
279 reg = <0x25000 0x1000>;
280 ranges = <0x0 0x25000 0x1000>;
281 local-mac-address = [ 00 00 00 00 00 00 ];
282 interrupts = <35 0x8 36 0x8 37 0x8>;
283 phy-connection-type = "mii";
284 interrupt-parent = <&ipic>;
285 phy-handle = <&phy3>;
286 tbi-handle = <&tbi1>;
287 sleep = <&pmc 0x30000000>;
288 fsl,magic-packet;
289
290 mdio@520 {
291 #address-cells = <1>;
292 #size-cells = <0>;
293 compatible = "fsl,gianfar-tbi";
294 reg = <0x520 0x20>;
295
296 tbi1: tbi-phy@11 {
297 reg = <0x11>;
298 device_type = "tbi-phy";
299 };
300 };
301 };
302
303 serial0: serial@4500 {
304 cell-index = <0>;
305 device_type = "serial";
306 compatible = "ns16550";
307 reg = <0x4500 0x100>;
308 clock-frequency = <0>;
309 interrupts = <9 0x8>;
310 interrupt-parent = <&ipic>;
311 };
312
313 serial1: serial@4600 {
314 cell-index = <1>;
315 device_type = "serial";
316 compatible = "ns16550";
317 reg = <0x4600 0x100>;
318 clock-frequency = <0>;
319 interrupts = <10 0x8>;
320 interrupt-parent = <&ipic>;
321 };
322
323 crypto@30000 {
324 compatible = "fsl,sec3.0", "fsl,sec2.4", "fsl,sec2.2",
325 "fsl,sec2.1", "fsl,sec2.0";
326 reg = <0x30000 0x10000>;
327 interrupts = <11 0x8>;
328 interrupt-parent = <&ipic>;
329 fsl,num-channels = <4>;
330 fsl,channel-fifo-len = <24>;
331 fsl,exec-units-mask = <0x9fe>;
332 fsl,descriptor-types-mask = <0x3ab0ebf>;
333 sleep = <&pmc 0x03000000>;
334 };
335
336 sata@18000 {
337 compatible = "fsl,mpc8377-sata", "fsl,pq-sata";
338 reg = <0x18000 0x1000>;
339 interrupts = <44 0x8>;
340 interrupt-parent = <&ipic>;
341 sleep = <&pmc 0x000000c0>;
342 };
343
344 sata@19000 {
345 compatible = "fsl,mpc8377-sata", "fsl,pq-sata";
346 reg = <0x19000 0x1000>;
347 interrupts = <45 0x8>;
348 interrupt-parent = <&ipic>;
349 sleep = <&pmc 0x00000030>;
350 };
351
352 /* IPIC
353 * interrupts cell = <intr #, sense>
354 * sense values match linux IORESOURCE_IRQ_* defines:
355 * sense == 8: Level, low assertion
356 * sense == 2: Edge, high-to-low change
357 */
358 ipic: interrupt-controller@700 {
359 compatible = "fsl,ipic";
360 interrupt-controller;
361 #address-cells = <0>;
362 #interrupt-cells = <2>;
363 reg = <0x700 0x100>;
364 };
365
366 pmc: power@b00 {
367 compatible = "fsl,mpc8377-pmc", "fsl,mpc8349-pmc";
368 reg = <0xb00 0x100 0xa00 0x100>;
369 interrupts = <80 0x8>;
370 interrupt-parent = <&ipic>;
371 };
372 };
373
374 pci0: pci@e0008500 {
375 interrupt-map-mask = <0xf800 0 0 7>;
376 interrupt-map = <
377 /* IRQ5 = 21 = 0x15, IRQ6 = 0x16, IRQ7 = 23 = 0x17 */
378
379 /* IDSEL AD14 IRQ6 inta */
380 0x7000 0x0 0x0 0x1 &ipic 22 0x8
381
382 /* IDSEL AD15 IRQ5 inta */
383 0x7800 0x0 0x0 0x1 &ipic 21 0x8>;
384 interrupt-parent = <&ipic>;
385 interrupts = <66 0x8>;
386 bus-range = <0 0>;
387 ranges = <0x02000000 0x0 0x90000000 0x90000000 0x0 0x10000000
388 0x42000000 0x0 0x80000000 0x80000000 0x0 0x10000000
389 0x01000000 0x0 0x00000000 0xe0300000 0x0 0x00100000>;
390 sleep = <&pmc 0x00010000>;
391 clock-frequency = <66666666>;
392 #interrupt-cells = <1>;
393 #size-cells = <2>;
394 #address-cells = <3>;
395 reg = <0xe0008500 0x100 /* internal registers */
396 0xe0008300 0x8>; /* config space access registers */
397 compatible = "fsl,mpc8349-pci";
398 device_type = "pci";
399 };
400
401 pci1: pcie@e0009000 {
402 #address-cells = <3>;
403 #size-cells = <2>;
404 #interrupt-cells = <1>;
405 device_type = "pci";
406 compatible = "fsl,mpc8377-pcie", "fsl,mpc8314-pcie";
407 reg = <0xe0009000 0x00001000>;
408 ranges = <0x02000000 0 0xa8000000 0xa8000000 0 0x10000000
409 0x01000000 0 0x00000000 0xb8000000 0 0x00800000>;
410 bus-range = <0 255>;
411 interrupt-map-mask = <0xf800 0 0 7>;
412 interrupt-map = <0 0 0 1 &ipic 1 8
413 0 0 0 2 &ipic 1 8
414 0 0 0 3 &ipic 1 8
415 0 0 0 4 &ipic 1 8>;
416 sleep = <&pmc 0x00300000>;
417 clock-frequency = <0>;
418
419 pcie@0 {
420 #address-cells = <3>;
421 #size-cells = <2>;
422 device_type = "pci";
423 reg = <0 0 0 0 0>;
424 ranges = <0x02000000 0 0xa8000000
425 0x02000000 0 0xa8000000
426 0 0x10000000
427 0x01000000 0 0x00000000
428 0x01000000 0 0x00000000
429 0 0x00800000>;
430 };
431 };
432
433 pci2: pcie@e000a000 {
434 #address-cells = <3>;
435 #size-cells = <2>;
436 #interrupt-cells = <1>;
437 device_type = "pci";
438 compatible = "fsl,mpc8377-pcie", "fsl,mpc8314-pcie";
439 reg = <0xe000a000 0x00001000>;
440 ranges = <0x02000000 0 0xc8000000 0xc8000000 0 0x10000000
441 0x01000000 0 0x00000000 0xd8000000 0 0x00800000>;
442 bus-range = <0 255>;
443 interrupt-map-mask = <0xf800 0 0 7>;
444 interrupt-map = <0 0 0 1 &ipic 2 8
445 0 0 0 2 &ipic 2 8
446 0 0 0 3 &ipic 2 8
447 0 0 0 4 &ipic 2 8>;
448 sleep = <&pmc 0x000c0000>;
449 clock-frequency = <0>;
450
451 pcie@0 {
452 #address-cells = <3>;
453 #size-cells = <2>;
454 device_type = "pci";
455 reg = <0 0 0 0 0>;
456 ranges = <0x02000000 0 0xc8000000
457 0x02000000 0 0xc8000000
458 0 0x10000000
459 0x01000000 0 0x00000000
460 0x01000000 0 0x00000000
461 0 0x00800000>;
462 };
463 };
464};
diff --git a/arch/powerpc/boot/dts/mpc8378_rdb.dts b/arch/powerpc/boot/dts/mpc8378_rdb.dts
index aabf3437cadf..a11ead8214b4 100644
--- a/arch/powerpc/boot/dts/mpc8378_rdb.dts
+++ b/arch/powerpc/boot/dts/mpc8378_rdb.dts
@@ -174,7 +174,7 @@
174 interrupts = <42 0x8>; 174 interrupts = <42 0x8>;
175 interrupt-parent = <&ipic>; 175 interrupt-parent = <&ipic>;
176 /* Filled in by U-Boot */ 176 /* Filled in by U-Boot */
177 clock-frequency = <0>; 177 clock-frequency = <111111111>;
178 }; 178 };
179 }; 179 };
180 180
diff --git a/arch/powerpc/boot/dts/mpc8379_rdb.dts b/arch/powerpc/boot/dts/mpc8379_rdb.dts
index 9b1da864d890..e35dfba587c8 100644
--- a/arch/powerpc/boot/dts/mpc8379_rdb.dts
+++ b/arch/powerpc/boot/dts/mpc8379_rdb.dts
@@ -172,7 +172,7 @@
172 interrupts = <42 0x8>; 172 interrupts = <42 0x8>;
173 interrupt-parent = <&ipic>; 173 interrupt-parent = <&ipic>;
174 /* Filled in by U-Boot */ 174 /* Filled in by U-Boot */
175 clock-frequency = <0>; 175 clock-frequency = <111111111>;
176 }; 176 };
177 }; 177 };
178 178
diff --git a/arch/powerpc/boot/dts/mpc8536ds.dts b/arch/powerpc/boot/dts/mpc8536ds.dts
index e781ad2f1f8a..815cebb2e3e5 100644
--- a/arch/powerpc/boot/dts/mpc8536ds.dts
+++ b/arch/powerpc/boot/dts/mpc8536ds.dts
@@ -14,8 +14,8 @@
14/ { 14/ {
15 model = "fsl,mpc8536ds"; 15 model = "fsl,mpc8536ds";
16 compatible = "fsl,mpc8536ds"; 16 compatible = "fsl,mpc8536ds";
17 #address-cells = <1>; 17 #address-cells = <2>;
18 #size-cells = <1>; 18 #size-cells = <2>;
19 19
20 aliases { 20 aliases {
21 ethernet0 = &enet0; 21 ethernet0 = &enet0;
@@ -42,7 +42,7 @@
42 42
43 memory { 43 memory {
44 device_type = "memory"; 44 device_type = "memory";
45 reg = <00000000 00000000>; // Filled by U-Boot 45 reg = <0 0 0 0>; // Filled by U-Boot
46 }; 46 };
47 47
48 soc@ffe00000 { 48 soc@ffe00000 {
@@ -50,7 +50,7 @@
50 #size-cells = <1>; 50 #size-cells = <1>;
51 device_type = "soc"; 51 device_type = "soc";
52 compatible = "simple-bus"; 52 compatible = "simple-bus";
53 ranges = <0x0 0xffe00000 0x100000>; 53 ranges = <0x0 0 0xffe00000 0x100000>;
54 bus-frequency = <0>; // Filled out by uboot. 54 bus-frequency = <0>; // Filled out by uboot.
55 55
56 ecm-law@0 { 56 ecm-law@0 {
@@ -250,6 +250,14 @@
250 phy_type = "ulpi"; 250 phy_type = "ulpi";
251 }; 251 };
252 252
253 sdhci@2e000 {
254 compatible = "fsl,mpc8536-esdhc", "fsl,esdhc";
255 reg = <0x2e000 0x1000>;
256 interrupts = <72 0x2>;
257 interrupt-parent = <&mpic>;
258 clock-frequency = <250000000>;
259 };
260
253 serial0: serial@4500 { 261 serial0: serial@4500 {
254 cell-index = <0>; 262 cell-index = <0>;
255 device_type = "serial"; 263 device_type = "serial";
@@ -347,13 +355,13 @@
347 interrupt-parent = <&mpic>; 355 interrupt-parent = <&mpic>;
348 interrupts = <24 0x2>; 356 interrupts = <24 0x2>;
349 bus-range = <0 0xff>; 357 bus-range = <0 0xff>;
350 ranges = <0x02000000 0 0x80000000 0x80000000 0 0x10000000 358 ranges = <0x02000000 0 0x80000000 0 0x80000000 0 0x10000000
351 0x01000000 0 0x00000000 0xffc00000 0 0x00010000>; 359 0x01000000 0 0x00000000 0 0xffc00000 0 0x00010000>;
352 clock-frequency = <66666666>; 360 clock-frequency = <66666666>;
353 #interrupt-cells = <1>; 361 #interrupt-cells = <1>;
354 #size-cells = <2>; 362 #size-cells = <2>;
355 #address-cells = <3>; 363 #address-cells = <3>;
356 reg = <0xffe08000 0x1000>; 364 reg = <0 0xffe08000 0 0x1000>;
357 }; 365 };
358 366
359 pci1: pcie@ffe09000 { 367 pci1: pcie@ffe09000 {
@@ -362,10 +370,10 @@
362 #interrupt-cells = <1>; 370 #interrupt-cells = <1>;
363 #size-cells = <2>; 371 #size-cells = <2>;
364 #address-cells = <3>; 372 #address-cells = <3>;
365 reg = <0xffe09000 0x1000>; 373 reg = <0 0xffe09000 0 0x1000>;
366 bus-range = <0 0xff>; 374 bus-range = <0 0xff>;
367 ranges = <0x02000000 0 0x98000000 0x98000000 0 0x08000000 375 ranges = <0x02000000 0 0x98000000 0 0x98000000 0 0x08000000
368 0x01000000 0 0x00000000 0xffc20000 0 0x00010000>; 376 0x01000000 0 0x00000000 0 0xffc20000 0 0x00010000>;
369 clock-frequency = <33333333>; 377 clock-frequency = <33333333>;
370 interrupt-parent = <&mpic>; 378 interrupt-parent = <&mpic>;
371 interrupts = <25 0x2>; 379 interrupts = <25 0x2>;
@@ -398,10 +406,10 @@
398 #interrupt-cells = <1>; 406 #interrupt-cells = <1>;
399 #size-cells = <2>; 407 #size-cells = <2>;
400 #address-cells = <3>; 408 #address-cells = <3>;
401 reg = <0xffe0a000 0x1000>; 409 reg = <0 0xffe0a000 0 0x1000>;
402 bus-range = <0 0xff>; 410 bus-range = <0 0xff>;
403 ranges = <0x02000000 0 0x90000000 0x90000000 0 0x08000000 411 ranges = <0x02000000 0 0x90000000 0 0x90000000 0 0x08000000
404 0x01000000 0 0x00000000 0xffc10000 0 0x00010000>; 412 0x01000000 0 0x00000000 0 0xffc10000 0 0x00010000>;
405 clock-frequency = <33333333>; 413 clock-frequency = <33333333>;
406 interrupt-parent = <&mpic>; 414 interrupt-parent = <&mpic>;
407 interrupts = <26 0x2>; 415 interrupts = <26 0x2>;
@@ -434,10 +442,10 @@
434 #interrupt-cells = <1>; 442 #interrupt-cells = <1>;
435 #size-cells = <2>; 443 #size-cells = <2>;
436 #address-cells = <3>; 444 #address-cells = <3>;
437 reg = <0xffe0b000 0x1000>; 445 reg = <0 0xffe0b000 0 0x1000>;
438 bus-range = <0 0xff>; 446 bus-range = <0 0xff>;
439 ranges = <0x02000000 0 0xa0000000 0xa0000000 0 0x20000000 447 ranges = <0x02000000 0 0xa0000000 0 0xa0000000 0 0x20000000
440 0x01000000 0 0x00000000 0xffc30000 0 0x00010000>; 448 0x01000000 0 0x00000000 0 0xffc30000 0 0x00010000>;
441 clock-frequency = <33333333>; 449 clock-frequency = <33333333>;
442 interrupt-parent = <&mpic>; 450 interrupt-parent = <&mpic>;
443 interrupts = <27 0x2>; 451 interrupts = <27 0x2>;
diff --git a/arch/powerpc/boot/dts/mpc8536ds_36b.dts b/arch/powerpc/boot/dts/mpc8536ds_36b.dts
new file mode 100644
index 000000000000..d95b26021e62
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc8536ds_36b.dts
@@ -0,0 +1,475 @@
1/*
2 * MPC8536 DS Device Tree Source
3 *
4 * Copyright 2008-2009 Freescale Semiconductor, Inc.
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
12/dts-v1/;
13
14/ {
15 model = "fsl,mpc8536ds";
16 compatible = "fsl,mpc8536ds";
17 #address-cells = <2>;
18 #size-cells = <2>;
19
20 aliases {
21 ethernet0 = &enet0;
22 ethernet1 = &enet1;
23 serial0 = &serial0;
24 serial1 = &serial1;
25 pci0 = &pci0;
26 pci1 = &pci1;
27 pci2 = &pci2;
28 pci3 = &pci3;
29 };
30
31 cpus {
32 #cpus = <1>;
33 #address-cells = <1>;
34 #size-cells = <0>;
35
36 PowerPC,8536@0 {
37 device_type = "cpu";
38 reg = <0>;
39 next-level-cache = <&L2>;
40 };
41 };
42
43 memory {
44 device_type = "memory";
45 reg = <0 0 0 0>; // Filled by U-Boot
46 };
47
48 soc@fffe00000 {
49 #address-cells = <1>;
50 #size-cells = <1>;
51 device_type = "soc";
52 compatible = "simple-bus";
53 ranges = <0x0 0xf 0xffe00000 0x100000>;
54 bus-frequency = <0>; // Filled out by uboot.
55
56 ecm-law@0 {
57 compatible = "fsl,ecm-law";
58 reg = <0x0 0x1000>;
59 fsl,num-laws = <12>;
60 };
61
62 ecm@1000 {
63 compatible = "fsl,mpc8536-ecm", "fsl,ecm";
64 reg = <0x1000 0x1000>;
65 interrupts = <17 2>;
66 interrupt-parent = <&mpic>;
67 };
68
69 memory-controller@2000 {
70 compatible = "fsl,mpc8536-memory-controller";
71 reg = <0x2000 0x1000>;
72 interrupt-parent = <&mpic>;
73 interrupts = <18 0x2>;
74 };
75
76 L2: l2-cache-controller@20000 {
77 compatible = "fsl,mpc8536-l2-cache-controller";
78 reg = <0x20000 0x1000>;
79 interrupt-parent = <&mpic>;
80 interrupts = <16 0x2>;
81 };
82
83 i2c@3000 {
84 #address-cells = <1>;
85 #size-cells = <0>;
86 cell-index = <0>;
87 compatible = "fsl-i2c";
88 reg = <0x3000 0x100>;
89 interrupts = <43 0x2>;
90 interrupt-parent = <&mpic>;
91 dfsrr;
92 };
93
94 i2c@3100 {
95 #address-cells = <1>;
96 #size-cells = <0>;
97 cell-index = <1>;
98 compatible = "fsl-i2c";
99 reg = <0x3100 0x100>;
100 interrupts = <43 0x2>;
101 interrupt-parent = <&mpic>;
102 dfsrr;
103 rtc@68 {
104 compatible = "dallas,ds3232";
105 reg = <0x68>;
106 interrupts = <0 0x1>;
107 interrupt-parent = <&mpic>;
108 };
109 };
110
111 dma@21300 {
112 #address-cells = <1>;
113 #size-cells = <1>;
114 compatible = "fsl,mpc8536-dma", "fsl,eloplus-dma";
115 reg = <0x21300 4>;
116 ranges = <0 0x21100 0x200>;
117 cell-index = <0>;
118 dma-channel@0 {
119 compatible = "fsl,mpc8536-dma-channel",
120 "fsl,eloplus-dma-channel";
121 reg = <0x0 0x80>;
122 cell-index = <0>;
123 interrupt-parent = <&mpic>;
124 interrupts = <20 2>;
125 };
126 dma-channel@80 {
127 compatible = "fsl,mpc8536-dma-channel",
128 "fsl,eloplus-dma-channel";
129 reg = <0x80 0x80>;
130 cell-index = <1>;
131 interrupt-parent = <&mpic>;
132 interrupts = <21 2>;
133 };
134 dma-channel@100 {
135 compatible = "fsl,mpc8536-dma-channel",
136 "fsl,eloplus-dma-channel";
137 reg = <0x100 0x80>;
138 cell-index = <2>;
139 interrupt-parent = <&mpic>;
140 interrupts = <22 2>;
141 };
142 dma-channel@180 {
143 compatible = "fsl,mpc8536-dma-channel",
144 "fsl,eloplus-dma-channel";
145 reg = <0x180 0x80>;
146 cell-index = <3>;
147 interrupt-parent = <&mpic>;
148 interrupts = <23 2>;
149 };
150 };
151
152 usb@22000 {
153 compatible = "fsl,mpc8536-usb2-mph", "fsl-usb2-mph";
154 reg = <0x22000 0x1000>;
155 #address-cells = <1>;
156 #size-cells = <0>;
157 interrupt-parent = <&mpic>;
158 interrupts = <28 0x2>;
159 phy_type = "ulpi";
160 };
161
162 usb@23000 {
163 compatible = "fsl,mpc8536-usb2-mph", "fsl-usb2-mph";
164 reg = <0x23000 0x1000>;
165 #address-cells = <1>;
166 #size-cells = <0>;
167 interrupt-parent = <&mpic>;
168 interrupts = <46 0x2>;
169 phy_type = "ulpi";
170 };
171
172 enet0: ethernet@24000 {
173 #address-cells = <1>;
174 #size-cells = <1>;
175 cell-index = <0>;
176 device_type = "network";
177 model = "eTSEC";
178 compatible = "gianfar";
179 reg = <0x24000 0x1000>;
180 ranges = <0x0 0x24000 0x1000>;
181 local-mac-address = [ 00 00 00 00 00 00 ];
182 interrupts = <29 2 30 2 34 2>;
183 interrupt-parent = <&mpic>;
184 tbi-handle = <&tbi0>;
185 phy-handle = <&phy1>;
186 phy-connection-type = "rgmii-id";
187
188 mdio@520 {
189 #address-cells = <1>;
190 #size-cells = <0>;
191 compatible = "fsl,gianfar-mdio";
192 reg = <0x520 0x20>;
193
194 phy0: ethernet-phy@0 {
195 interrupt-parent = <&mpic>;
196 interrupts = <10 0x1>;
197 reg = <0>;
198 device_type = "ethernet-phy";
199 };
200 phy1: ethernet-phy@1 {
201 interrupt-parent = <&mpic>;
202 interrupts = <10 0x1>;
203 reg = <1>;
204 device_type = "ethernet-phy";
205 };
206 tbi0: tbi-phy@11 {
207 reg = <0x11>;
208 device_type = "tbi-phy";
209 };
210 };
211 };
212
213 enet1: ethernet@26000 {
214 #address-cells = <1>;
215 #size-cells = <1>;
216 cell-index = <1>;
217 device_type = "network";
218 model = "eTSEC";
219 compatible = "gianfar";
220 reg = <0x26000 0x1000>;
221 ranges = <0x0 0x26000 0x1000>;
222 local-mac-address = [ 00 00 00 00 00 00 ];
223 interrupts = <31 2 32 2 33 2>;
224 interrupt-parent = <&mpic>;
225 tbi-handle = <&tbi1>;
226 phy-handle = <&phy0>;
227 phy-connection-type = "rgmii-id";
228
229 mdio@520 {
230 #address-cells = <1>;
231 #size-cells = <0>;
232 compatible = "fsl,gianfar-tbi";
233 reg = <0x520 0x20>;
234
235 tbi1: tbi-phy@11 {
236 reg = <0x11>;
237 device_type = "tbi-phy";
238 };
239 };
240 };
241
242 usb@2b000 {
243 compatible = "fsl,mpc8536-usb2-dr", "fsl-usb2-dr";
244 reg = <0x2b000 0x1000>;
245 #address-cells = <1>;
246 #size-cells = <0>;
247 interrupt-parent = <&mpic>;
248 interrupts = <60 0x2>;
249 dr_mode = "peripheral";
250 phy_type = "ulpi";
251 };
252
253 sdhci@2e000 {
254 compatible = "fsl,mpc8536-esdhc", "fsl,esdhc";
255 reg = <0x2e000 0x1000>;
256 interrupts = <72 0x2>;
257 interrupt-parent = <&mpic>;
258 clock-frequency = <250000000>;
259 };
260
261 serial0: serial@4500 {
262 cell-index = <0>;
263 device_type = "serial";
264 compatible = "ns16550";
265 reg = <0x4500 0x100>;
266 clock-frequency = <0>;
267 interrupts = <42 0x2>;
268 interrupt-parent = <&mpic>;
269 };
270
271 serial1: serial@4600 {
272 cell-index = <1>;
273 device_type = "serial";
274 compatible = "ns16550";
275 reg = <0x4600 0x100>;
276 clock-frequency = <0>;
277 interrupts = <42 0x2>;
278 interrupt-parent = <&mpic>;
279 };
280
281 crypto@30000 {
282 compatible = "fsl,sec3.0", "fsl,sec2.4", "fsl,sec2.2",
283 "fsl,sec2.1", "fsl,sec2.0";
284 reg = <0x30000 0x10000>;
285 interrupts = <45 2 58 2>;
286 interrupt-parent = <&mpic>;
287 fsl,num-channels = <4>;
288 fsl,channel-fifo-len = <24>;
289 fsl,exec-units-mask = <0x9fe>;
290 fsl,descriptor-types-mask = <0x3ab0ebf>;
291 };
292
293 sata@18000 {
294 compatible = "fsl,mpc8536-sata", "fsl,pq-sata";
295 reg = <0x18000 0x1000>;
296 cell-index = <1>;
297 interrupts = <74 0x2>;
298 interrupt-parent = <&mpic>;
299 };
300
301 sata@19000 {
302 compatible = "fsl,mpc8536-sata", "fsl,pq-sata";
303 reg = <0x19000 0x1000>;
304 cell-index = <2>;
305 interrupts = <41 0x2>;
306 interrupt-parent = <&mpic>;
307 };
308
309 global-utilities@e0000 { //global utilities block
310 compatible = "fsl,mpc8548-guts";
311 reg = <0xe0000 0x1000>;
312 fsl,has-rstcr;
313 };
314
315 mpic: pic@40000 {
316 clock-frequency = <0>;
317 interrupt-controller;
318 #address-cells = <0>;
319 #interrupt-cells = <2>;
320 reg = <0x40000 0x40000>;
321 compatible = "chrp,open-pic";
322 device_type = "open-pic";
323 big-endian;
324 };
325
326 msi@41600 {
327 compatible = "fsl,mpc8536-msi", "fsl,mpic-msi";
328 reg = <0x41600 0x80>;
329 msi-available-ranges = <0 0x100>;
330 interrupts = <
331 0xe0 0
332 0xe1 0
333 0xe2 0
334 0xe3 0
335 0xe4 0
336 0xe5 0
337 0xe6 0
338 0xe7 0>;
339 interrupt-parent = <&mpic>;
340 };
341 };
342
343 pci0: pci@fffe08000 {
344 compatible = "fsl,mpc8540-pci";
345 device_type = "pci";
346 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
347 interrupt-map = <
348
349 /* IDSEL 0x11 J17 Slot 1 */
350 0x8800 0 0 1 &mpic 1 1
351 0x8800 0 0 2 &mpic 2 1
352 0x8800 0 0 3 &mpic 3 1
353 0x8800 0 0 4 &mpic 4 1>;
354
355 interrupt-parent = <&mpic>;
356 interrupts = <24 0x2>;
357 bus-range = <0 0xff>;
358 ranges = <0x02000000 0 0xf0000000 0xc 0x00000000 0 0x10000000
359 0x01000000 0 0x00000000 0xf 0xffc00000 0 0x00010000>;
360 clock-frequency = <66666666>;
361 #interrupt-cells = <1>;
362 #size-cells = <2>;
363 #address-cells = <3>;
364 reg = <0xf 0xffe08000 0 0x1000>;
365 };
366
367 pci1: pcie@fffe09000 {
368 compatible = "fsl,mpc8548-pcie";
369 device_type = "pci";
370 #interrupt-cells = <1>;
371 #size-cells = <2>;
372 #address-cells = <3>;
373 reg = <0xf 0xffe09000 0 0x1000>;
374 bus-range = <0 0xff>;
375 ranges = <0x02000000 0 0xf8000000 0xc 0x18000000 0 0x08000000
376 0x01000000 0 0x00000000 0xf 0xffc20000 0 0x00010000>;
377 clock-frequency = <33333333>;
378 interrupt-parent = <&mpic>;
379 interrupts = <25 0x2>;
380 interrupt-map-mask = <0xf800 0 0 7>;
381 interrupt-map = <
382 /* IDSEL 0x0 */
383 0000 0 0 1 &mpic 4 1
384 0000 0 0 2 &mpic 5 1
385 0000 0 0 3 &mpic 6 1
386 0000 0 0 4 &mpic 7 1
387 >;
388 pcie@0 {
389 reg = <0 0 0 0 0>;
390 #size-cells = <2>;
391 #address-cells = <3>;
392 device_type = "pci";
393 ranges = <0x02000000 0 0xf8000000
394 0x02000000 0 0xf8000000
395 0 0x08000000
396
397 0x01000000 0 0x00000000
398 0x01000000 0 0x00000000
399 0 0x00010000>;
400 };
401 };
402
403 pci2: pcie@fffe0a000 {
404 compatible = "fsl,mpc8548-pcie";
405 device_type = "pci";
406 #interrupt-cells = <1>;
407 #size-cells = <2>;
408 #address-cells = <3>;
409 reg = <0xf 0xffe0a000 0 0x1000>;
410 bus-range = <0 0xff>;
411 ranges = <0x02000000 0 0xf8000000 0xc 0x10000000 0 0x08000000
412 0x01000000 0 0x00000000 0xf 0xffc10000 0 0x00010000>;
413 clock-frequency = <33333333>;
414 interrupt-parent = <&mpic>;
415 interrupts = <26 0x2>;
416 interrupt-map-mask = <0xf800 0 0 7>;
417 interrupt-map = <
418 /* IDSEL 0x0 */
419 0000 0 0 1 &mpic 0 1
420 0000 0 0 2 &mpic 1 1
421 0000 0 0 3 &mpic 2 1
422 0000 0 0 4 &mpic 3 1
423 >;
424 pcie@0 {
425 reg = <0 0 0 0 0>;
426 #size-cells = <2>;
427 #address-cells = <3>;
428 device_type = "pci";
429 ranges = <0x02000000 0 0xf8000000
430 0x02000000 0 0xf8000000
431 0 0x08000000
432
433 0x01000000 0 0x00000000
434 0x01000000 0 0x00000000
435 0 0x00010000>;
436 };
437 };
438
439 pci3: pcie@fffe0b000 {
440 compatible = "fsl,mpc8548-pcie";
441 device_type = "pci";
442 #interrupt-cells = <1>;
443 #size-cells = <2>;
444 #address-cells = <3>;
445 reg = <0xf 0xffe0b000 0 0x1000>;
446 bus-range = <0 0xff>;
447 ranges = <0x02000000 0 0xe0000000 0xc 0x20000000 0 0x20000000
448 0x01000000 0 0x00000000 0xf 0xffc30000 0 0x00010000>;
449 clock-frequency = <33333333>;
450 interrupt-parent = <&mpic>;
451 interrupts = <27 0x2>;
452 interrupt-map-mask = <0xf800 0 0 7>;
453 interrupt-map = <
454 /* IDSEL 0x0 */
455 0000 0 0 1 &mpic 8 1
456 0000 0 0 2 &mpic 9 1
457 0000 0 0 3 &mpic 10 1
458 0000 0 0 4 &mpic 11 1
459 >;
460
461 pcie@0 {
462 reg = <0 0 0 0 0>;
463 #size-cells = <2>;
464 #address-cells = <3>;
465 device_type = "pci";
466 ranges = <0x02000000 0 0xe0000000
467 0x02000000 0 0xe0000000
468 0 0x20000000
469
470 0x01000000 0 0x00000000
471 0x01000000 0 0x00000000
472 0 0x00100000>;
473 };
474 };
475};
diff --git a/arch/powerpc/boot/dts/mpc8548cds.dts b/arch/powerpc/boot/dts/mpc8548cds.dts
index 475be1433fe1..4173af387c63 100644
--- a/arch/powerpc/boot/dts/mpc8548cds.dts
+++ b/arch/powerpc/boot/dts/mpc8548cds.dts
@@ -100,6 +100,21 @@
100 interrupts = <43 2>; 100 interrupts = <43 2>;
101 interrupt-parent = <&mpic>; 101 interrupt-parent = <&mpic>;
102 dfsrr; 102 dfsrr;
103
104 eeprom@50 {
105 compatible = "atmel,24c64";
106 reg = <0x50>;
107 };
108
109 eeprom@56 {
110 compatible = "atmel,24c64";
111 reg = <0x56>;
112 };
113
114 eeprom@57 {
115 compatible = "atmel,24c64";
116 reg = <0x57>;
117 };
103 }; 118 };
104 119
105 i2c@3100 { 120 i2c@3100 {
@@ -111,6 +126,11 @@
111 interrupts = <43 2>; 126 interrupts = <43 2>;
112 interrupt-parent = <&mpic>; 127 interrupt-parent = <&mpic>;
113 dfsrr; 128 dfsrr;
129
130 eeprom@50 {
131 compatible = "atmel,24c64";
132 reg = <0x50>;
133 };
114 }; 134 };
115 135
116 dma@21300 { 136 dma@21300 {
diff --git a/arch/powerpc/boot/dts/mpc8569mds.dts b/arch/powerpc/boot/dts/mpc8569mds.dts
index 9e4ce99e1613..06332d61830a 100644
--- a/arch/powerpc/boot/dts/mpc8569mds.dts
+++ b/arch/powerpc/boot/dts/mpc8569mds.dts
@@ -99,8 +99,18 @@
99 }; 99 };
100 100
101 bcsr@1,0 { 101 bcsr@1,0 {
102 #address-cells = <1>;
103 #size-cells = <1>;
102 compatible = "fsl,mpc8569mds-bcsr"; 104 compatible = "fsl,mpc8569mds-bcsr";
103 reg = <1 0 0x8000>; 105 reg = <1 0 0x8000>;
106 ranges = <0 1 0 0x8000>;
107
108 bcsr17: gpio-controller@11 {
109 #gpio-cells = <2>;
110 compatible = "fsl,mpc8569mds-bcsr-gpio";
111 reg = <0x11 0x1>;
112 gpio-controller;
113 };
104 }; 114 };
105 115
106 nand@3,0 { 116 nand@3,0 {
@@ -315,6 +325,14 @@
315 gpio-controller; 325 gpio-controller;
316 }; 326 };
317 327
328 qe_pio_f: gpio-controller@a0 {
329 #gpio-cells = <2>;
330 compatible = "fsl,mpc8569-qe-pario-bank",
331 "fsl,mpc8323-qe-pario-bank";
332 reg = <0xa0 0x18>;
333 gpio-controller;
334 };
335
318 pio1: ucc_pin@01 { 336 pio1: ucc_pin@01 {
319 pio-map = < 337 pio-map = <
320 /* port pin dir open_drain assignment has_irq */ 338 /* port pin dir open_drain assignment has_irq */
@@ -419,6 +437,16 @@
419 interrupt-parent = <&mpic>; 437 interrupt-parent = <&mpic>;
420 }; 438 };
421 439
440 timer@440 {
441 compatible = "fsl,mpc8569-qe-gtm",
442 "fsl,qe-gtm", "fsl,gtm";
443 reg = <0x440 0x40>;
444 interrupts = <12 13 14 15>;
445 interrupt-parent = <&qeic>;
446 /* Filled in by U-Boot */
447 clock-frequency = <0>;
448 };
449
422 spi@4c0 { 450 spi@4c0 {
423 #address-cells = <1>; 451 #address-cells = <1>;
424 #size-cells = <0>; 452 #size-cells = <0>;
@@ -446,6 +474,23 @@
446 mode = "cpu"; 474 mode = "cpu";
447 }; 475 };
448 476
477 usb@6c0 {
478 compatible = "fsl,mpc8569-qe-usb",
479 "fsl,mpc8323-qe-usb";
480 reg = <0x6c0 0x40 0x8b00 0x100>;
481 interrupts = <11>;
482 interrupt-parent = <&qeic>;
483 fsl,fullspeed-clock = "clk5";
484 fsl,lowspeed-clock = "brg10";
485 gpios = <&qe_pio_f 3 0 /* USBOE */
486 &qe_pio_f 4 0 /* USBTP */
487 &qe_pio_f 5 0 /* USBTN */
488 &qe_pio_f 6 0 /* USBRP */
489 &qe_pio_f 8 0 /* USBRN */
490 &bcsr17 6 0 /* SPEED */
491 &bcsr17 5 1>; /* POWER */
492 };
493
449 enet0: ucc@2000 { 494 enet0: ucc@2000 {
450 device_type = "network"; 495 device_type = "network";
451 compatible = "ucc_geth"; 496 compatible = "ucc_geth";
diff --git a/arch/powerpc/boot/dts/p2020rdb.dts b/arch/powerpc/boot/dts/p2020rdb.dts
new file mode 100644
index 000000000000..da4cb0d8d215
--- /dev/null
+++ b/arch/powerpc/boot/dts/p2020rdb.dts
@@ -0,0 +1,586 @@
1/*
2 * P2020 RDB Device Tree Source
3 *
4 * Copyright 2009 Freescale Semiconductor Inc.
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
12/dts-v1/;
13/ {
14 model = "fsl,P2020";
15 compatible = "fsl,P2020RDB";
16 #address-cells = <2>;
17 #size-cells = <2>;
18
19 aliases {
20 ethernet0 = &enet0;
21 ethernet1 = &enet1;
22 ethernet2 = &enet2;
23 serial0 = &serial0;
24 serial1 = &serial1;
25 pci0 = &pci0;
26 pci1 = &pci1;
27 };
28
29 cpus {
30 #address-cells = <1>;
31 #size-cells = <0>;
32
33 PowerPC,P2020@0 {
34 device_type = "cpu";
35 reg = <0x0>;
36 next-level-cache = <&L2>;
37 };
38
39 PowerPC,P2020@1 {
40 device_type = "cpu";
41 reg = <0x1>;
42 next-level-cache = <&L2>;
43 };
44 };
45
46 memory {
47 device_type = "memory";
48 };
49
50 localbus@ffe05000 {
51 #address-cells = <2>;
52 #size-cells = <1>;
53 compatible = "fsl,p2020-elbc", "fsl,elbc", "simple-bus";
54 reg = <0 0xffe05000 0 0x1000>;
55 interrupts = <19 2>;
56 interrupt-parent = <&mpic>;
57
58 /* NOR and NAND Flashes */
59 ranges = <0x0 0x0 0x0 0xef000000 0x01000000
60 0x1 0x0 0x0 0xffa00000 0x00040000
61 0x2 0x0 0x0 0xffb00000 0x00020000>;
62
63 nor@0,0 {
64 #address-cells = <1>;
65 #size-cells = <1>;
66 compatible = "cfi-flash";
67 reg = <0x0 0x0 0x1000000>;
68 bank-width = <2>;
69 device-width = <1>;
70
71 partition@0 {
72 /* This location must not be altered */
73 /* 256KB for Vitesse 7385 Switch firmware */
74 reg = <0x0 0x00040000>;
75 label = "NOR (RO) Vitesse-7385 Firmware";
76 read-only;
77 };
78
79 partition@40000 {
80 /* 256KB for DTB Image */
81 reg = <0x00040000 0x00040000>;
82 label = "NOR (RO) DTB Image";
83 read-only;
84 };
85
86 partition@80000 {
87 /* 3.5 MB for Linux Kernel Image */
88 reg = <0x00080000 0x00380000>;
89 label = "NOR (RO) Linux Kernel Image";
90 read-only;
91 };
92
93 partition@400000 {
94 /* 11MB for JFFS2 based Root file System */
95 reg = <0x00400000 0x00b00000>;
96 label = "NOR (RW) JFFS2 Root File System";
97 };
98
99 partition@f00000 {
100 /* This location must not be altered */
101 /* 512KB for u-boot Bootloader Image */
102 /* 512KB for u-boot Environment Variables */
103 reg = <0x00f00000 0x00100000>;
104 label = "NOR (RO) U-Boot Image";
105 read-only;
106 };
107 };
108
109 nand@1,0 {
110 #address-cells = <1>;
111 #size-cells = <1>;
112 compatible = "fsl,p2020-fcm-nand",
113 "fsl,elbc-fcm-nand";
114 reg = <0x1 0x0 0x40000>;
115
116 partition@0 {
117 /* This location must not be altered */
118 /* 1MB for u-boot Bootloader Image */
119 reg = <0x0 0x00100000>;
120 label = "NAND (RO) U-Boot Image";
121 read-only;
122 };
123
124 partition@100000 {
125 /* 1MB for DTB Image */
126 reg = <0x00100000 0x00100000>;
127 label = "NAND (RO) DTB Image";
128 read-only;
129 };
130
131 partition@200000 {
132 /* 4MB for Linux Kernel Image */
133 reg = <0x00200000 0x00400000>;
134 label = "NAND (RO) Linux Kernel Image";
135 read-only;
136 };
137
138 partition@600000 {
139 /* 4MB for Compressed Root file System Image */
140 reg = <0x00600000 0x00400000>;
141 label = "NAND (RO) Compressed RFS Image";
142 read-only;
143 };
144
145 partition@a00000 {
146 /* 7MB for JFFS2 based Root file System */
147 reg = <0x00a00000 0x00700000>;
148 label = "NAND (RW) JFFS2 Root File System";
149 };
150
151 partition@1100000 {
152 /* 15MB for JFFS2 based Root file System */
153 reg = <0x01100000 0x00f00000>;
154 label = "NAND (RW) Writable User area";
155 };
156 };
157
158 L2switch@2,0 {
159 #address-cells = <1>;
160 #size-cells = <1>;
161 compatible = "vitesse-7385";
162 reg = <0x2 0x0 0x20000>;
163 };
164
165 };
166
167 soc@ffe00000 {
168 #address-cells = <1>;
169 #size-cells = <1>;
170 device_type = "soc";
171 compatible = "fsl,p2020-immr", "simple-bus";
172 ranges = <0x0 0x0 0xffe00000 0x100000>;
173 bus-frequency = <0>; // Filled out by uboot.
174
175 ecm-law@0 {
176 compatible = "fsl,ecm-law";
177 reg = <0x0 0x1000>;
178 fsl,num-laws = <12>;
179 };
180
181 ecm@1000 {
182 compatible = "fsl,p2020-ecm", "fsl,ecm";
183 reg = <0x1000 0x1000>;
184 interrupts = <17 2>;
185 interrupt-parent = <&mpic>;
186 };
187
188 memory-controller@2000 {
189 compatible = "fsl,p2020-memory-controller";
190 reg = <0x2000 0x1000>;
191 interrupt-parent = <&mpic>;
192 interrupts = <18 2>;
193 };
194
195 i2c@3000 {
196 #address-cells = <1>;
197 #size-cells = <0>;
198 cell-index = <0>;
199 compatible = "fsl-i2c";
200 reg = <0x3000 0x100>;
201 interrupts = <43 2>;
202 interrupt-parent = <&mpic>;
203 dfsrr;
204 rtc@68 {
205 compatible = "dallas,ds1339";
206 reg = <0x68>;
207 };
208 };
209
210 i2c@3100 {
211 #address-cells = <1>;
212 #size-cells = <0>;
213 cell-index = <1>;
214 compatible = "fsl-i2c";
215 reg = <0x3100 0x100>;
216 interrupts = <43 2>;
217 interrupt-parent = <&mpic>;
218 dfsrr;
219 };
220
221 serial0: serial@4500 {
222 cell-index = <0>;
223 device_type = "serial";
224 compatible = "ns16550";
225 reg = <0x4500 0x100>;
226 clock-frequency = <0>;
227 interrupts = <42 2>;
228 interrupt-parent = <&mpic>;
229 };
230
231 serial1: serial@4600 {
232 cell-index = <1>;
233 device_type = "serial";
234 compatible = "ns16550";
235 reg = <0x4600 0x100>;
236 clock-frequency = <0>;
237 interrupts = <42 2>;
238 interrupt-parent = <&mpic>;
239 };
240
241 spi@7000 {
242 cell-index = <0>;
243 #address-cells = <1>;
244 #size-cells = <0>;
245 compatible = "fsl,espi";
246 reg = <0x7000 0x1000>;
247 interrupts = <59 0x2>;
248 interrupt-parent = <&mpic>;
249 mode = "cpu";
250
251 fsl_m25p80@0 {
252 #address-cells = <1>;
253 #size-cells = <1>;
254 compatible = "fsl,espi-flash";
255 reg = <0>;
256 linux,modalias = "fsl_m25p80";
257 modal = "s25sl128b";
258 spi-max-frequency = <50000000>;
259 mode = <0>;
260
261 partition@0 {
262 /* 512KB for u-boot Bootloader Image */
263 reg = <0x0 0x00080000>;
264 label = "SPI (RO) U-Boot Image";
265 read-only;
266 };
267
268 partition@80000 {
269 /* 512KB for DTB Image */
270 reg = <0x00080000 0x00080000>;
271 label = "SPI (RO) DTB Image";
272 read-only;
273 };
274
275 partition@100000 {
276 /* 4MB for Linux Kernel Image */
277 reg = <0x00100000 0x00400000>;
278 label = "SPI (RO) Linux Kernel Image";
279 read-only;
280 };
281
282 partition@500000 {
283 /* 4MB for Compressed RFS Image */
284 reg = <0x00500000 0x00400000>;
285 label = "SPI (RO) Compressed RFS Image";
286 read-only;
287 };
288
289 partition@900000 {
290 /* 7MB for JFFS2 based RFS */
291 reg = <0x00900000 0x00700000>;
292 label = "SPI (RW) JFFS2 RFS";
293 };
294 };
295 };
296
297 dma@c300 {
298 #address-cells = <1>;
299 #size-cells = <1>;
300 compatible = "fsl,eloplus-dma";
301 reg = <0xc300 0x4>;
302 ranges = <0x0 0xc100 0x200>;
303 cell-index = <1>;
304 dma-channel@0 {
305 compatible = "fsl,eloplus-dma-channel";
306 reg = <0x0 0x80>;
307 cell-index = <0>;
308 interrupt-parent = <&mpic>;
309 interrupts = <76 2>;
310 };
311 dma-channel@80 {
312 compatible = "fsl,eloplus-dma-channel";
313 reg = <0x80 0x80>;
314 cell-index = <1>;
315 interrupt-parent = <&mpic>;
316 interrupts = <77 2>;
317 };
318 dma-channel@100 {
319 compatible = "fsl,eloplus-dma-channel";
320 reg = <0x100 0x80>;
321 cell-index = <2>;
322 interrupt-parent = <&mpic>;
323 interrupts = <78 2>;
324 };
325 dma-channel@180 {
326 compatible = "fsl,eloplus-dma-channel";
327 reg = <0x180 0x80>;
328 cell-index = <3>;
329 interrupt-parent = <&mpic>;
330 interrupts = <79 2>;
331 };
332 };
333
334 gpio: gpio-controller@f000 {
335 #gpio-cells = <2>;
336 compatible = "fsl,mpc8572-gpio";
337 reg = <0xf000 0x100>;
338 interrupts = <47 0x2>;
339 interrupt-parent = <&mpic>;
340 gpio-controller;
341 };
342
343 L2: l2-cache-controller@20000 {
344 compatible = "fsl,p2020-l2-cache-controller";
345 reg = <0x20000 0x1000>;
346 cache-line-size = <32>; // 32 bytes
347 cache-size = <0x80000>; // L2,512K
348 interrupt-parent = <&mpic>;
349 interrupts = <16 2>;
350 };
351
352 dma@21300 {
353 #address-cells = <1>;
354 #size-cells = <1>;
355 compatible = "fsl,eloplus-dma";
356 reg = <0x21300 0x4>;
357 ranges = <0x0 0x21100 0x200>;
358 cell-index = <0>;
359 dma-channel@0 {
360 compatible = "fsl,eloplus-dma-channel";
361 reg = <0x0 0x80>;
362 cell-index = <0>;
363 interrupt-parent = <&mpic>;
364 interrupts = <20 2>;
365 };
366 dma-channel@80 {
367 compatible = "fsl,eloplus-dma-channel";
368 reg = <0x80 0x80>;
369 cell-index = <1>;
370 interrupt-parent = <&mpic>;
371 interrupts = <21 2>;
372 };
373 dma-channel@100 {
374 compatible = "fsl,eloplus-dma-channel";
375 reg = <0x100 0x80>;
376 cell-index = <2>;
377 interrupt-parent = <&mpic>;
378 interrupts = <22 2>;
379 };
380 dma-channel@180 {
381 compatible = "fsl,eloplus-dma-channel";
382 reg = <0x180 0x80>;
383 cell-index = <3>;
384 interrupt-parent = <&mpic>;
385 interrupts = <23 2>;
386 };
387 };
388
389 usb@22000 {
390 #address-cells = <1>;
391 #size-cells = <0>;
392 compatible = "fsl-usb2-dr";
393 reg = <0x22000 0x1000>;
394 interrupt-parent = <&mpic>;
395 interrupts = <28 0x2>;
396 phy_type = "ulpi";
397 };
398
399 enet0: ethernet@24000 {
400 #address-cells = <1>;
401 #size-cells = <1>;
402 cell-index = <0>;
403 device_type = "network";
404 model = "eTSEC";
405 compatible = "gianfar";
406 reg = <0x24000 0x1000>;
407 ranges = <0x0 0x24000 0x1000>;
408 local-mac-address = [ 00 00 00 00 00 00 ];
409 interrupts = <29 2 30 2 34 2>;
410 interrupt-parent = <&mpic>;
411 fixed-link = <1 1 1000 0 0>;
412 phy-connection-type = "rgmii-id";
413
414 mdio@520 {
415 #address-cells = <1>;
416 #size-cells = <0>;
417 compatible = "fsl,gianfar-mdio";
418 reg = <0x520 0x20>;
419
420 phy0: ethernet-phy@0 {
421 interrupt-parent = <&mpic>;
422 interrupts = <3 1>;
423 reg = <0x0>;
424 };
425 phy1: ethernet-phy@1 {
426 interrupt-parent = <&mpic>;
427 interrupts = <3 1>;
428 reg = <0x1>;
429 };
430 };
431 };
432
433 enet1: ethernet@25000 {
434 #address-cells = <1>;
435 #size-cells = <1>;
436 cell-index = <1>;
437 device_type = "network";
438 model = "eTSEC";
439 compatible = "gianfar";
440 reg = <0x25000 0x1000>;
441 ranges = <0x0 0x25000 0x1000>;
442 local-mac-address = [ 00 00 00 00 00 00 ];
443 interrupts = <35 2 36 2 40 2>;
444 interrupt-parent = <&mpic>;
445 tbi-handle = <&tbi0>;
446 phy-handle = <&phy0>;
447 phy-connection-type = "sgmii";
448
449 mdio@520 {
450 #address-cells = <1>;
451 #size-cells = <0>;
452 compatible = "fsl,gianfar-tbi";
453 reg = <0x520 0x20>;
454
455 tbi0: tbi-phy@11 {
456 reg = <0x11>;
457 device_type = "tbi-phy";
458 };
459 };
460 };
461
462 enet2: ethernet@26000 {
463 #address-cells = <1>;
464 #size-cells = <1>;
465 cell-index = <2>;
466 device_type = "network";
467 model = "eTSEC";
468 compatible = "gianfar";
469 reg = <0x26000 0x1000>;
470 ranges = <0x0 0x26000 0x1000>;
471 local-mac-address = [ 00 00 00 00 00 00 ];
472 interrupts = <31 2 32 2 33 2>;
473 interrupt-parent = <&mpic>;
474 phy-handle = <&phy1>;
475 phy-connection-type = "rgmii-id";
476 };
477
478 sdhci@2e000 {
479 compatible = "fsl,p2020-esdhc", "fsl,esdhc";
480 reg = <0x2e000 0x1000>;
481 interrupts = <72 0x2>;
482 interrupt-parent = <&mpic>;
483 /* Filled in by U-Boot */
484 clock-frequency = <0>;
485 };
486
487 crypto@30000 {
488 compatible = "fsl,sec3.1", "fsl,sec3.0", "fsl,sec2.4",
489 "fsl,sec2.2", "fsl,sec2.1", "fsl,sec2.0";
490 reg = <0x30000 0x10000>;
491 interrupts = <45 2 58 2>;
492 interrupt-parent = <&mpic>;
493 fsl,num-channels = <4>;
494 fsl,channel-fifo-len = <24>;
495 fsl,exec-units-mask = <0xbfe>;
496 fsl,descriptor-types-mask = <0x3ab0ebf>;
497 };
498
499 mpic: pic@40000 {
500 interrupt-controller;
501 #address-cells = <0>;
502 #interrupt-cells = <2>;
503 reg = <0x40000 0x40000>;
504 compatible = "chrp,open-pic";
505 device_type = "open-pic";
506 };
507
508 msi@41600 {
509 compatible = "fsl,p2020-msi", "fsl,mpic-msi";
510 reg = <0x41600 0x80>;
511 msi-available-ranges = <0 0x100>;
512 interrupts = <
513 0xe0 0
514 0xe1 0
515 0xe2 0
516 0xe3 0
517 0xe4 0
518 0xe5 0
519 0xe6 0
520 0xe7 0>;
521 interrupt-parent = <&mpic>;
522 };
523
524 global-utilities@e0000 { //global utilities block
525 compatible = "fsl,p2020-guts";
526 reg = <0xe0000 0x1000>;
527 fsl,has-rstcr;
528 };
529 };
530
531 pci0: pcie@ffe09000 {
532 compatible = "fsl,mpc8548-pcie";
533 device_type = "pci";
534 #interrupt-cells = <1>;
535 #size-cells = <2>;
536 #address-cells = <3>;
537 reg = <0 0xffe09000 0 0x1000>;
538 bus-range = <0 255>;
539 ranges = <0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x20000000
540 0x1000000 0x0 0x00000000 0 0xffc30000 0x0 0x10000>;
541 clock-frequency = <33333333>;
542 interrupt-parent = <&mpic>;
543 interrupts = <25 2>;
544 pcie@0 {
545 reg = <0x0 0x0 0x0 0x0 0x0>;
546 #size-cells = <2>;
547 #address-cells = <3>;
548 device_type = "pci";
549 ranges = <0x2000000 0x0 0xa0000000
550 0x2000000 0x0 0xa0000000
551 0x0 0x20000000
552
553 0x1000000 0x0 0x0
554 0x1000000 0x0 0x0
555 0x0 0x100000>;
556 };
557 };
558
559 pci1: pcie@ffe0a000 {
560 compatible = "fsl,mpc8548-pcie";
561 device_type = "pci";
562 #interrupt-cells = <1>;
563 #size-cells = <2>;
564 #address-cells = <3>;
565 reg = <0 0xffe0a000 0 0x1000>;
566 bus-range = <0 255>;
567 ranges = <0x2000000 0x0 0xc0000000 0 0xc0000000 0x0 0x20000000
568 0x1000000 0x0 0x00000000 0 0xffc20000 0x0 0x10000>;
569 clock-frequency = <33333333>;
570 interrupt-parent = <&mpic>;
571 interrupts = <26 2>;
572 pcie@0 {
573 reg = <0x0 0x0 0x0 0x0 0x0>;
574 #size-cells = <2>;
575 #address-cells = <3>;
576 device_type = "pci";
577 ranges = <0x2000000 0x0 0xc0000000
578 0x2000000 0x0 0xc0000000
579 0x0 0x20000000
580
581 0x1000000 0x0 0x0
582 0x1000000 0x0 0x0
583 0x0 0x100000>;
584 };
585 };
586};
diff --git a/arch/powerpc/boot/dts/sbc8349.dts b/arch/powerpc/boot/dts/sbc8349.dts
index 2d9fa68f641c..0dc90f9bd814 100644
--- a/arch/powerpc/boot/dts/sbc8349.dts
+++ b/arch/powerpc/boot/dts/sbc8349.dts
@@ -146,18 +146,6 @@
146 phy_type = "ulpi"; 146 phy_type = "ulpi";
147 port0; 147 port0;
148 }; 148 };
149 /* phy type (ULPI, UTMI, UTMI_WIDE, SERIAL) */
150 usb@23000 {
151 device_type = "usb";
152 compatible = "fsl-usb2-dr";
153 reg = <0x23000 0x1000>;
154 #address-cells = <1>;
155 #size-cells = <0>;
156 interrupt-parent = <&ipic>;
157 interrupts = <38 0x8>;
158 dr_mode = "otg";
159 phy_type = "ulpi";
160 };
161 149
162 enet0: ethernet@24000 { 150 enet0: ethernet@24000 {
163 #address-cells = <1>; 151 #address-cells = <1>;
@@ -277,15 +265,55 @@
277 }; 265 };
278 }; 266 };
279 267
268 localbus@e0005000 {
269 #address-cells = <2>;
270 #size-cells = <1>;
271 compatible = "fsl,mpc8349-localbus", "simple-bus";
272 reg = <0xe0005000 0x1000>;
273 interrupts = <77 0x8>;
274 interrupt-parent = <&ipic>;
275 ranges = <0x0 0x0 0xff800000 0x00800000 /* 8MB Flash */
276 0x1 0x0 0xf8000000 0x00002000 /* 8KB EEPROM */
277 0x2 0x0 0x10000000 0x04000000 /* 64MB SDRAM */
278 0x3 0x0 0x10000000 0x04000000>; /* 64MB SDRAM */
279
280 flash@0,0 {
281 #address-cells = <1>;
282 #size-cells = <1>;
283 compatible = "intel,28F640J3A", "cfi-flash";
284 reg = <0x0 0x0 0x800000>;
285 bank-width = <2>;
286 device-width = <1>;
287
288 partition@0 {
289 label = "u-boot";
290 reg = <0x00000000 0x00040000>;
291 read-only;
292 };
293
294 partition@40000 {
295 label = "user";
296 reg = <0x00040000 0x006c0000>;
297 };
298
299 partition@700000 {
300 label = "legacy u-boot";
301 reg = <0x00700000 0x00100000>;
302 read-only;
303 };
304
305 };
306 };
307
280 pci0: pci@e0008500 { 308 pci0: pci@e0008500 {
281 interrupt-map-mask = <0xf800 0x0 0x0 0x7>; 309 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
282 interrupt-map = < 310 interrupt-map = <
283 311
284 /* IDSEL 0x11 */ 312 /* IDSEL 0x11 */
285 0x8800 0x0 0x0 0x1 &ipic 20 0x8 313 0x8800 0x0 0x0 0x1 &ipic 48 0x8
286 0x8800 0x0 0x0 0x2 &ipic 21 0x8 314 0x8800 0x0 0x0 0x2 &ipic 17 0x8
287 0x8800 0x0 0x0 0x3 &ipic 22 0x8 315 0x8800 0x0 0x0 0x3 &ipic 18 0x8
288 0x8800 0x0 0x0 0x4 &ipic 23 0x8>; 316 0x8800 0x0 0x0 0x4 &ipic 19 0x8>;
289 317
290 interrupt-parent = <&ipic>; 318 interrupt-parent = <&ipic>;
291 interrupts = <0x42 0x8>; 319 interrupts = <0x42 0x8>;
diff --git a/arch/powerpc/boot/dts/sbc8560.dts b/arch/powerpc/boot/dts/sbc8560.dts
index 239d57a55cf4..9e13ed8a1193 100644
--- a/arch/powerpc/boot/dts/sbc8560.dts
+++ b/arch/powerpc/boot/dts/sbc8560.dts
@@ -303,7 +303,6 @@
303 global-utilities@e0000 { 303 global-utilities@e0000 {
304 compatible = "fsl,mpc8560-guts"; 304 compatible = "fsl,mpc8560-guts";
305 reg = <0xe0000 0x1000>; 305 reg = <0xe0000 0x1000>;
306 fsl,has-rstcr;
307 }; 306 };
308 }; 307 };
309 308
diff --git a/arch/powerpc/boot/mktree.c b/arch/powerpc/boot/mktree.c
index c2baae0a3d89..e2ae24340fc8 100644
--- a/arch/powerpc/boot/mktree.c
+++ b/arch/powerpc/boot/mktree.c
@@ -36,7 +36,7 @@ typedef struct boot_block {
36} boot_block_t; 36} boot_block_t;
37 37
38#define IMGBLK 512 38#define IMGBLK 512
39char tmpbuf[IMGBLK]; 39unsigned int tmpbuf[IMGBLK / sizeof(unsigned int)];
40 40
41int main(int argc, char *argv[]) 41int main(int argc, char *argv[])
42{ 42{
@@ -95,13 +95,13 @@ int main(int argc, char *argv[])
95 95
96 /* Assume zImage is an ELF file, and skip the 64K header. 96 /* Assume zImage is an ELF file, and skip the 64K header.
97 */ 97 */
98 if (read(in_fd, tmpbuf, IMGBLK) != IMGBLK) { 98 if (read(in_fd, tmpbuf, sizeof(tmpbuf)) != sizeof(tmpbuf)) {
99 fprintf(stderr, "%s is too small to be an ELF image\n", 99 fprintf(stderr, "%s is too small to be an ELF image\n",
100 argv[1]); 100 argv[1]);
101 exit(4); 101 exit(4);
102 } 102 }
103 103
104 if ((*(unsigned int *)tmpbuf) != htonl(0x7f454c46)) { 104 if (tmpbuf[0] != htonl(0x7f454c46)) {
105 fprintf(stderr, "%s is not an ELF image\n", argv[1]); 105 fprintf(stderr, "%s is not an ELF image\n", argv[1]);
106 exit(4); 106 exit(4);
107 } 107 }
@@ -121,11 +121,11 @@ int main(int argc, char *argv[])
121 } 121 }
122 122
123 while (nblks-- > 0) { 123 while (nblks-- > 0) {
124 if (read(in_fd, tmpbuf, IMGBLK) < 0) { 124 if (read(in_fd, tmpbuf, sizeof(tmpbuf)) < 0) {
125 perror("zImage read"); 125 perror("zImage read");
126 exit(5); 126 exit(5);
127 } 127 }
128 cp = (unsigned int *)tmpbuf; 128 cp = tmpbuf;
129 for (i = 0; i < sizeof(tmpbuf) / sizeof(unsigned int); i++) 129 for (i = 0; i < sizeof(tmpbuf) / sizeof(unsigned int); i++)
130 cksum += *cp++; 130 cksum += *cp++;
131 if (write(out_fd, tmpbuf, sizeof(tmpbuf)) != sizeof(tmpbuf)) { 131 if (write(out_fd, tmpbuf, sizeof(tmpbuf)) != sizeof(tmpbuf)) {
diff --git a/arch/powerpc/boot/ppcboot-hotfoot.h b/arch/powerpc/boot/ppcboot-hotfoot.h
new file mode 100644
index 000000000000..1a3e80b533da
--- /dev/null
+++ b/arch/powerpc/boot/ppcboot-hotfoot.h
@@ -0,0 +1,133 @@
1/*
2 * This interface is used for compatibility with old U-boots *ONLY*.
3 * Please do not imitate or extend this.
4 */
5
6/*
7 * Unfortunately, the ESTeem Hotfoot board uses a mangled version of
8 * ppcboot.h for historical reasons, and in the interest of having a
9 * mainline kernel boot on the production board+bootloader, this was the
10 * least-offensive solution. Please direct all flames to:
11 *
12 * Solomon Peachy <solomon@linux-wlan.com>
13 *
14 * (This header is identical to ppcboot.h except for the
15 * TARGET_HOTFOOT bits)
16 */
17
18/*
19 * (C) Copyright 2000, 2001
20 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
21 *
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License as
24 * published by the Free Software Foundation; either version 2 of
25 * the License, or (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
35 * MA 02111-1307 USA
36 */
37
38#ifndef __PPCBOOT_H__
39#define __PPCBOOT_H__
40
41/*
42 * Board information passed to kernel from PPCBoot
43 *
44 * include/asm-ppc/ppcboot.h
45 */
46
47#include "types.h"
48
49typedef struct bd_info {
50 unsigned long bi_memstart; /* start of DRAM memory */
51 unsigned long bi_memsize; /* size of DRAM memory in bytes */
52 unsigned long bi_flashstart; /* start of FLASH memory */
53 unsigned long bi_flashsize; /* size of FLASH memory */
54 unsigned long bi_flashoffset; /* reserved area for startup monitor */
55 unsigned long bi_sramstart; /* start of SRAM memory */
56 unsigned long bi_sramsize; /* size of SRAM memory */
57#if defined(TARGET_8xx) || defined(TARGET_CPM2) || defined(TARGET_85xx) ||\
58 defined(TARGET_83xx)
59 unsigned long bi_immr_base; /* base of IMMR register */
60#endif
61#if defined(TARGET_PPC_MPC52xx)
62 unsigned long bi_mbar_base; /* base of internal registers */
63#endif
64 unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
65 unsigned long bi_ip_addr; /* IP Address */
66 unsigned char bi_enetaddr[6]; /* Ethernet address */
67#if defined(TARGET_HOTFOOT)
68 /* second onboard ethernet port */
69 unsigned char bi_enet1addr[6];
70#define HAVE_ENET1ADDR
71#endif /* TARGET_HOOTFOOT */
72 unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
73 unsigned long bi_intfreq; /* Internal Freq, in MHz */
74 unsigned long bi_busfreq; /* Bus Freq, in MHz */
75#if defined(TARGET_CPM2)
76 unsigned long bi_cpmfreq; /* CPM_CLK Freq, in MHz */
77 unsigned long bi_brgfreq; /* BRG_CLK Freq, in MHz */
78 unsigned long bi_sccfreq; /* SCC_CLK Freq, in MHz */
79 unsigned long bi_vco; /* VCO Out from PLL, in MHz */
80#endif
81#if defined(TARGET_PPC_MPC52xx)
82 unsigned long bi_ipbfreq; /* IPB Bus Freq, in MHz */
83 unsigned long bi_pcifreq; /* PCI Bus Freq, in MHz */
84#endif
85 unsigned long bi_baudrate; /* Console Baudrate */
86#if defined(TARGET_4xx)
87 unsigned char bi_s_version[4]; /* Version of this structure */
88 unsigned char bi_r_version[32]; /* Version of the ROM (IBM) */
89 unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */
90 unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */
91 unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
92 unsigned char bi_pci_enetaddr[6]; /* PCI Ethernet MAC address */
93#endif
94#if defined(TARGET_HOTFOOT)
95 unsigned int bi_pllouta_freq; /* PLL OUTA speed, in Hz */
96#endif
97#if defined(TARGET_HYMOD)
98 hymod_conf_t bi_hymod_conf; /* hymod configuration information */
99#endif
100#if defined(TARGET_EVB64260) || defined(TARGET_405EP) || defined(TARGET_44x) || \
101 defined(TARGET_85xx) || defined(TARGET_83xx) || defined(TARGET_HAS_ETH1)
102 /* second onboard ethernet port */
103 unsigned char bi_enet1addr[6];
104#define HAVE_ENET1ADDR
105#endif
106#if defined(TARGET_EVB64260) || defined(TARGET_440GX) || \
107 defined(TARGET_85xx) || defined(TARGET_HAS_ETH2)
108 /* third onboard ethernet ports */
109 unsigned char bi_enet2addr[6];
110#define HAVE_ENET2ADDR
111#endif
112#if defined(TARGET_440GX) || defined(TARGET_HAS_ETH3)
113 /* fourth onboard ethernet ports */
114 unsigned char bi_enet3addr[6];
115#define HAVE_ENET3ADDR
116#endif
117#if defined(TARGET_HOTFOOT)
118 int bi_phynum[2]; /* Determines phy mapping */
119 int bi_phymode[2]; /* Determines phy mode */
120#endif
121#if defined(TARGET_4xx)
122 unsigned int bi_opbfreq; /* OB clock in Hz */
123 int bi_iic_fast[2]; /* Use fast i2c mode */
124#endif
125#if defined(TARGET_440GX)
126 int bi_phynum[4]; /* phy mapping */
127 int bi_phymode[4]; /* phy mode */
128#endif
129} bd_t;
130
131#define bi_tbfreq bi_intfreq
132
133#endif /* __PPCBOOT_H__ */
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 4db487d1d2a8..ac9e9a58b2b0 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -46,6 +46,7 @@ CROSS=
46# directory for object and other files used by this script 46# directory for object and other files used by this script
47object=arch/powerpc/boot 47object=arch/powerpc/boot
48objbin=$object 48objbin=$object
49dtc=scripts/dtc/dtc
49 50
50# directory for working files 51# directory for working files
51tmpdir=. 52tmpdir=.
@@ -124,7 +125,7 @@ if [ -n "$dts" ]; then
124 if [ -z "$dtb" ]; then 125 if [ -z "$dtb" ]; then
125 dtb="$platform.dtb" 126 dtb="$platform.dtb"
126 fi 127 fi
127 $object/dtc -O dtb -o "$dtb" -b 0 "$dts" 128 $dtc -O dtb -o "$dtb" -b 0 "$dts"
128fi 129fi
129 130
130if [ -z "$kernel" ]; then 131if [ -z "$kernel" ]; then
diff --git a/arch/powerpc/configs/40x/kilauea_defconfig b/arch/powerpc/configs/40x/kilauea_defconfig
index 865725effe93..9a05ec0ec312 100644
--- a/arch/powerpc/configs/40x/kilauea_defconfig
+++ b/arch/powerpc/configs/40x/kilauea_defconfig
@@ -1,14 +1,14 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc7 3# Linux kernel version: 2.6.31-rc4
4# Wed Jun 3 10:18:16 2009 4# Wed Jul 29 13:28:37 2009
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7 7
8# 8#
9# Processor support 9# Processor support
10# 10#
11# CONFIG_6xx is not set 11# CONFIG_PPC_BOOK3S_32 is not set
12# CONFIG_PPC_85xx is not set 12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set 13# CONFIG_PPC_8xx is not set
14CONFIG_40x=y 14CONFIG_40x=y
@@ -32,11 +32,11 @@ CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
32CONFIG_IRQ_PER_CPU=y 32CONFIG_IRQ_PER_CPU=y
33CONFIG_STACKTRACE_SUPPORT=y 33CONFIG_STACKTRACE_SUPPORT=y
34CONFIG_HAVE_LATENCYTOP_SUPPORT=y 34CONFIG_HAVE_LATENCYTOP_SUPPORT=y
35CONFIG_TRACE_IRQFLAGS_SUPPORT=y
35CONFIG_LOCKDEP_SUPPORT=y 36CONFIG_LOCKDEP_SUPPORT=y
36CONFIG_RWSEM_XCHGADD_ALGORITHM=y 37CONFIG_RWSEM_XCHGADD_ALGORITHM=y
37CONFIG_ARCH_HAS_ILOG2_U32=y 38CONFIG_ARCH_HAS_ILOG2_U32=y
38CONFIG_GENERIC_HWEIGHT=y 39CONFIG_GENERIC_HWEIGHT=y
39CONFIG_GENERIC_CALIBRATE_DELAY=y
40CONFIG_GENERIC_FIND_NEXT_BIT=y 40CONFIG_GENERIC_FIND_NEXT_BIT=y
41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set 41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
42CONFIG_PPC=y 42CONFIG_PPC=y
@@ -57,6 +57,7 @@ CONFIG_PPC_DCR_NATIVE=y
57CONFIG_PPC_DCR=y 57CONFIG_PPC_DCR=y
58CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y 58CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
59CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 59CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
60CONFIG_CONSTRUCTORS=y
60 61
61# 62#
62# General setup 63# General setup
@@ -108,7 +109,6 @@ CONFIG_SYSCTL_SYSCALL=y
108CONFIG_KALLSYMS=y 109CONFIG_KALLSYMS=y
109CONFIG_KALLSYMS_ALL=y 110CONFIG_KALLSYMS_ALL=y
110CONFIG_KALLSYMS_EXTRA_PASS=y 111CONFIG_KALLSYMS_EXTRA_PASS=y
111# CONFIG_STRIP_ASM_SYMS is not set
112CONFIG_HOTPLUG=y 112CONFIG_HOTPLUG=y
113CONFIG_PRINTK=y 113CONFIG_PRINTK=y
114CONFIG_BUG=y 114CONFIG_BUG=y
@@ -121,9 +121,16 @@ CONFIG_TIMERFD=y
121CONFIG_EVENTFD=y 121CONFIG_EVENTFD=y
122CONFIG_SHMEM=y 122CONFIG_SHMEM=y
123CONFIG_AIO=y 123CONFIG_AIO=y
124CONFIG_HAVE_PERF_COUNTERS=y
125
126#
127# Performance Counters
128#
129# CONFIG_PERF_COUNTERS is not set
124CONFIG_VM_EVENT_COUNTERS=y 130CONFIG_VM_EVENT_COUNTERS=y
125CONFIG_PCI_QUIRKS=y 131CONFIG_PCI_QUIRKS=y
126CONFIG_SLUB_DEBUG=y 132CONFIG_SLUB_DEBUG=y
133# CONFIG_STRIP_ASM_SYMS is not set
127CONFIG_COMPAT_BRK=y 134CONFIG_COMPAT_BRK=y
128# CONFIG_SLAB is not set 135# CONFIG_SLAB is not set
129CONFIG_SLUB=y 136CONFIG_SLUB=y
@@ -137,6 +144,11 @@ CONFIG_HAVE_IOREMAP_PROT=y
137CONFIG_HAVE_KPROBES=y 144CONFIG_HAVE_KPROBES=y
138CONFIG_HAVE_KRETPROBES=y 145CONFIG_HAVE_KRETPROBES=y
139CONFIG_HAVE_ARCH_TRACEHOOK=y 146CONFIG_HAVE_ARCH_TRACEHOOK=y
147
148#
149# GCOV-based kernel profiling
150#
151# CONFIG_GCOV_KERNEL is not set
140# CONFIG_SLOW_WORK is not set 152# CONFIG_SLOW_WORK is not set
141# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 153# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
142CONFIG_SLABINFO=y 154CONFIG_SLABINFO=y
@@ -149,7 +161,7 @@ CONFIG_MODULE_UNLOAD=y
149# CONFIG_MODVERSIONS is not set 161# CONFIG_MODVERSIONS is not set
150# CONFIG_MODULE_SRCVERSION_ALL is not set 162# CONFIG_MODULE_SRCVERSION_ALL is not set
151CONFIG_BLOCK=y 163CONFIG_BLOCK=y
152CONFIG_LBD=y 164CONFIG_LBDAF=y
153# CONFIG_BLK_DEV_BSG is not set 165# CONFIG_BLK_DEV_BSG is not set
154# CONFIG_BLK_DEV_INTEGRITY is not set 166# CONFIG_BLK_DEV_INTEGRITY is not set
155 167
@@ -220,6 +232,7 @@ CONFIG_BINFMT_ELF=y
220# CONFIG_BINFMT_MISC is not set 232# CONFIG_BINFMT_MISC is not set
221# CONFIG_MATH_EMULATION is not set 233# CONFIG_MATH_EMULATION is not set
222# CONFIG_IOMMU_HELPER is not set 234# CONFIG_IOMMU_HELPER is not set
235# CONFIG_SWIOTLB is not set
223CONFIG_PPC_NEED_DMA_SYNC_OPS=y 236CONFIG_PPC_NEED_DMA_SYNC_OPS=y
224CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 237CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
225CONFIG_ARCH_HAS_WALK_MEMORY=y 238CONFIG_ARCH_HAS_WALK_MEMORY=y
@@ -239,9 +252,9 @@ CONFIG_MIGRATION=y
239CONFIG_ZONE_DMA_FLAG=1 252CONFIG_ZONE_DMA_FLAG=1
240CONFIG_BOUNCE=y 253CONFIG_BOUNCE=y
241CONFIG_VIRT_TO_BUS=y 254CONFIG_VIRT_TO_BUS=y
242CONFIG_UNEVICTABLE_LRU=y
243CONFIG_HAVE_MLOCK=y 255CONFIG_HAVE_MLOCK=y
244CONFIG_HAVE_MLOCKED_PAGE_BIT=y 256CONFIG_HAVE_MLOCKED_PAGE_BIT=y
257CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
245CONFIG_PPC_4K_PAGES=y 258CONFIG_PPC_4K_PAGES=y
246# CONFIG_PPC_16K_PAGES is not set 259# CONFIG_PPC_16K_PAGES is not set
247# CONFIG_PPC_64K_PAGES is not set 260# CONFIG_PPC_64K_PAGES is not set
@@ -344,6 +357,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
344# CONFIG_ECONET is not set 357# CONFIG_ECONET is not set
345# CONFIG_WAN_ROUTER is not set 358# CONFIG_WAN_ROUTER is not set
346# CONFIG_PHONET is not set 359# CONFIG_PHONET is not set
360# CONFIG_IEEE802154 is not set
347# CONFIG_NET_SCHED is not set 361# CONFIG_NET_SCHED is not set
348# CONFIG_DCB is not set 362# CONFIG_DCB is not set
349 363
@@ -393,9 +407,8 @@ CONFIG_MTD_OF_PARTS=y
393# User Modules And Translation Layers 407# User Modules And Translation Layers
394# 408#
395CONFIG_MTD_CHAR=y 409CONFIG_MTD_CHAR=y
396CONFIG_MTD_BLKDEVS=m 410CONFIG_MTD_BLKDEVS=y
397CONFIG_MTD_BLOCK=m 411CONFIG_MTD_BLOCK=y
398# CONFIG_MTD_BLOCK_RO is not set
399# CONFIG_FTL is not set 412# CONFIG_FTL is not set
400# CONFIG_NFTL is not set 413# CONFIG_NFTL is not set
401# CONFIG_INFTL is not set 414# CONFIG_INFTL is not set
@@ -452,7 +465,17 @@ CONFIG_MTD_PHYSMAP_OF=y
452# CONFIG_MTD_DOC2000 is not set 465# CONFIG_MTD_DOC2000 is not set
453# CONFIG_MTD_DOC2001 is not set 466# CONFIG_MTD_DOC2001 is not set
454# CONFIG_MTD_DOC2001PLUS is not set 467# CONFIG_MTD_DOC2001PLUS is not set
455# CONFIG_MTD_NAND is not set 468CONFIG_MTD_NAND=y
469# CONFIG_MTD_NAND_VERIFY_WRITE is not set
470CONFIG_MTD_NAND_ECC_SMC=y
471# CONFIG_MTD_NAND_MUSEUM_IDS is not set
472CONFIG_MTD_NAND_IDS=y
473CONFIG_MTD_NAND_NDFC=y
474# CONFIG_MTD_NAND_DISKONCHIP is not set
475# CONFIG_MTD_NAND_CAFE is not set
476# CONFIG_MTD_NAND_NANDSIM is not set
477# CONFIG_MTD_NAND_PLATFORM is not set
478# CONFIG_MTD_NAND_FSL_ELBC is not set
456# CONFIG_MTD_ONENAND is not set 479# CONFIG_MTD_ONENAND is not set
457 480
458# 481#
@@ -465,6 +488,7 @@ CONFIG_MTD_PHYSMAP_OF=y
465# 488#
466# CONFIG_MTD_UBI is not set 489# CONFIG_MTD_UBI is not set
467CONFIG_OF_DEVICE=y 490CONFIG_OF_DEVICE=y
491CONFIG_OF_I2C=y
468# CONFIG_PARPORT is not set 492# CONFIG_PARPORT is not set
469CONFIG_BLK_DEV=y 493CONFIG_BLK_DEV=y
470# CONFIG_BLK_DEV_FD is not set 494# CONFIG_BLK_DEV_FD is not set
@@ -504,14 +528,17 @@ CONFIG_HAVE_IDE=y
504# 528#
505 529
506# 530#
507# Enable only one of the two stacks, unless you know what you are doing 531# You can enable one or both FireWire driver stacks.
532#
533
534#
535# See the help texts for more information.
508# 536#
509# CONFIG_FIREWIRE is not set 537# CONFIG_FIREWIRE is not set
510# CONFIG_IEEE1394 is not set 538# CONFIG_IEEE1394 is not set
511# CONFIG_I2O is not set 539# CONFIG_I2O is not set
512# CONFIG_MACINTOSH_DRIVERS is not set 540# CONFIG_MACINTOSH_DRIVERS is not set
513CONFIG_NETDEVICES=y 541CONFIG_NETDEVICES=y
514CONFIG_COMPAT_NET_DEV_OPS=y
515# CONFIG_DUMMY is not set 542# CONFIG_DUMMY is not set
516# CONFIG_BONDING is not set 543# CONFIG_BONDING is not set
517# CONFIG_MACVLAN is not set 544# CONFIG_MACVLAN is not set
@@ -546,6 +573,7 @@ CONFIG_IBM_NEW_EMAC_EMAC4=y
546# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 573# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
547# CONFIG_NET_PCI is not set 574# CONFIG_NET_PCI is not set
548# CONFIG_B44 is not set 575# CONFIG_B44 is not set
576# CONFIG_KS8842 is not set
549# CONFIG_ATL2 is not set 577# CONFIG_ATL2 is not set
550# CONFIG_NETDEV_1000 is not set 578# CONFIG_NETDEV_1000 is not set
551# CONFIG_NETDEV_10000 is not set 579# CONFIG_NETDEV_10000 is not set
@@ -621,20 +649,150 @@ CONFIG_LEGACY_PTY_COUNT=256
621# CONFIG_IPMI_HANDLER is not set 649# CONFIG_IPMI_HANDLER is not set
622# CONFIG_HW_RANDOM is not set 650# CONFIG_HW_RANDOM is not set
623# CONFIG_NVRAM is not set 651# CONFIG_NVRAM is not set
624# CONFIG_GEN_RTC is not set
625# CONFIG_R3964 is not set 652# CONFIG_R3964 is not set
626# CONFIG_APPLICOM is not set 653# CONFIG_APPLICOM is not set
627# CONFIG_RAW_DRIVER is not set 654# CONFIG_RAW_DRIVER is not set
628# CONFIG_TCG_TPM is not set 655# CONFIG_TCG_TPM is not set
629CONFIG_DEVPORT=y 656CONFIG_DEVPORT=y
630# CONFIG_I2C is not set 657CONFIG_I2C=y
658CONFIG_I2C_BOARDINFO=y
659CONFIG_I2C_CHARDEV=y
660CONFIG_I2C_HELPER_AUTO=y
661
662#
663# I2C Hardware Bus support
664#
665
666#
667# PC SMBus host controller drivers
668#
669# CONFIG_I2C_ALI1535 is not set
670# CONFIG_I2C_ALI1563 is not set
671# CONFIG_I2C_ALI15X3 is not set
672# CONFIG_I2C_AMD756 is not set
673# CONFIG_I2C_AMD8111 is not set
674# CONFIG_I2C_I801 is not set
675# CONFIG_I2C_ISCH is not set
676# CONFIG_I2C_PIIX4 is not set
677# CONFIG_I2C_NFORCE2 is not set
678# CONFIG_I2C_SIS5595 is not set
679# CONFIG_I2C_SIS630 is not set
680# CONFIG_I2C_SIS96X is not set
681# CONFIG_I2C_VIA is not set
682# CONFIG_I2C_VIAPRO is not set
683
684#
685# I2C system bus drivers (mostly embedded / system-on-chip)
686#
687CONFIG_I2C_IBM_IIC=y
688# CONFIG_I2C_MPC is not set
689# CONFIG_I2C_OCORES is not set
690# CONFIG_I2C_SIMTEC is not set
691
692#
693# External I2C/SMBus adapter drivers
694#
695# CONFIG_I2C_PARPORT_LIGHT is not set
696# CONFIG_I2C_TAOS_EVM is not set
697
698#
699# Graphics adapter I2C/DDC channel drivers
700#
701# CONFIG_I2C_VOODOO3 is not set
702
703#
704# Other I2C/SMBus bus drivers
705#
706# CONFIG_I2C_PCA_PLATFORM is not set
707# CONFIG_I2C_STUB is not set
708
709#
710# Miscellaneous I2C Chip support
711#
712# CONFIG_DS1682 is not set
713# CONFIG_SENSORS_PCF8574 is not set
714# CONFIG_PCF8575 is not set
715# CONFIG_SENSORS_PCA9539 is not set
716# CONFIG_SENSORS_TSL2550 is not set
717# CONFIG_I2C_DEBUG_CORE is not set
718# CONFIG_I2C_DEBUG_ALGO is not set
719# CONFIG_I2C_DEBUG_BUS is not set
720# CONFIG_I2C_DEBUG_CHIP is not set
631# CONFIG_SPI is not set 721# CONFIG_SPI is not set
722
723#
724# PPS support
725#
726# CONFIG_PPS is not set
632CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 727CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
633# CONFIG_GPIOLIB is not set 728# CONFIG_GPIOLIB is not set
634# CONFIG_W1 is not set 729# CONFIG_W1 is not set
635# CONFIG_POWER_SUPPLY is not set 730# CONFIG_POWER_SUPPLY is not set
636# CONFIG_HWMON is not set 731CONFIG_HWMON=y
732# CONFIG_HWMON_VID is not set
733# CONFIG_SENSORS_AD7414 is not set
734# CONFIG_SENSORS_AD7418 is not set
735# CONFIG_SENSORS_ADM1021 is not set
736# CONFIG_SENSORS_ADM1025 is not set
737# CONFIG_SENSORS_ADM1026 is not set
738# CONFIG_SENSORS_ADM1029 is not set
739# CONFIG_SENSORS_ADM1031 is not set
740# CONFIG_SENSORS_ADM9240 is not set
741# CONFIG_SENSORS_ADT7462 is not set
742# CONFIG_SENSORS_ADT7470 is not set
743# CONFIG_SENSORS_ADT7473 is not set
744# CONFIG_SENSORS_ADT7475 is not set
745# CONFIG_SENSORS_ATXP1 is not set
746# CONFIG_SENSORS_DS1621 is not set
747# CONFIG_SENSORS_I5K_AMB is not set
748# CONFIG_SENSORS_F71805F is not set
749# CONFIG_SENSORS_F71882FG is not set
750# CONFIG_SENSORS_F75375S is not set
751# CONFIG_SENSORS_G760A is not set
752# CONFIG_SENSORS_GL518SM is not set
753# CONFIG_SENSORS_GL520SM is not set
754# CONFIG_SENSORS_IT87 is not set
755# CONFIG_SENSORS_LM63 is not set
756CONFIG_SENSORS_LM75=y
757# CONFIG_SENSORS_LM77 is not set
758# CONFIG_SENSORS_LM78 is not set
759# CONFIG_SENSORS_LM80 is not set
760# CONFIG_SENSORS_LM83 is not set
761# CONFIG_SENSORS_LM85 is not set
762# CONFIG_SENSORS_LM87 is not set
763# CONFIG_SENSORS_LM90 is not set
764# CONFIG_SENSORS_LM92 is not set
765# CONFIG_SENSORS_LM93 is not set
766# CONFIG_SENSORS_LTC4215 is not set
767# CONFIG_SENSORS_LTC4245 is not set
768# CONFIG_SENSORS_LM95241 is not set
769# CONFIG_SENSORS_MAX1619 is not set
770# CONFIG_SENSORS_MAX6650 is not set
771# CONFIG_SENSORS_PC87360 is not set
772# CONFIG_SENSORS_PC87427 is not set
773# CONFIG_SENSORS_PCF8591 is not set
774# CONFIG_SENSORS_SIS5595 is not set
775# CONFIG_SENSORS_DME1737 is not set
776# CONFIG_SENSORS_SMSC47M1 is not set
777# CONFIG_SENSORS_SMSC47M192 is not set
778# CONFIG_SENSORS_SMSC47B397 is not set
779# CONFIG_SENSORS_ADS7828 is not set
780# CONFIG_SENSORS_THMC50 is not set
781# CONFIG_SENSORS_TMP401 is not set
782# CONFIG_SENSORS_VIA686A is not set
783# CONFIG_SENSORS_VT1211 is not set
784# CONFIG_SENSORS_VT8231 is not set
785# CONFIG_SENSORS_W83781D is not set
786# CONFIG_SENSORS_W83791D is not set
787# CONFIG_SENSORS_W83792D is not set
788# CONFIG_SENSORS_W83793 is not set
789# CONFIG_SENSORS_W83L785TS is not set
790# CONFIG_SENSORS_W83L786NG is not set
791# CONFIG_SENSORS_W83627HF is not set
792# CONFIG_SENSORS_W83627EHF is not set
793# CONFIG_HWMON_DEBUG_CHIP is not set
637CONFIG_THERMAL=y 794CONFIG_THERMAL=y
795# CONFIG_THERMAL_HWMON is not set
638# CONFIG_WATCHDOG is not set 796# CONFIG_WATCHDOG is not set
639CONFIG_SSB_POSSIBLE=y 797CONFIG_SSB_POSSIBLE=y
640 798
@@ -649,24 +807,15 @@ CONFIG_SSB_POSSIBLE=y
649# CONFIG_MFD_CORE is not set 807# CONFIG_MFD_CORE is not set
650# CONFIG_MFD_SM501 is not set 808# CONFIG_MFD_SM501 is not set
651# CONFIG_HTC_PASIC3 is not set 809# CONFIG_HTC_PASIC3 is not set
810# CONFIG_TWL4030_CORE is not set
652# CONFIG_MFD_TMIO is not set 811# CONFIG_MFD_TMIO is not set
812# CONFIG_PMIC_DA903X is not set
813# CONFIG_MFD_WM8400 is not set
814# CONFIG_MFD_WM8350_I2C is not set
815# CONFIG_MFD_PCF50633 is not set
816# CONFIG_AB3100_CORE is not set
653# CONFIG_REGULATOR is not set 817# CONFIG_REGULATOR is not set
654 818# CONFIG_MEDIA_SUPPORT is not set
655#
656# Multimedia devices
657#
658
659#
660# Multimedia core support
661#
662# CONFIG_VIDEO_DEV is not set
663# CONFIG_DVB_CORE is not set
664# CONFIG_VIDEO_MEDIA is not set
665
666#
667# Multimedia drivers
668#
669# CONFIG_DAB is not set
670 819
671# 820#
672# Graphics support 821# Graphics support
@@ -691,10 +840,69 @@ CONFIG_SSB_POSSIBLE=y
691# CONFIG_ACCESSIBILITY is not set 840# CONFIG_ACCESSIBILITY is not set
692# CONFIG_INFINIBAND is not set 841# CONFIG_INFINIBAND is not set
693# CONFIG_EDAC is not set 842# CONFIG_EDAC is not set
694# CONFIG_RTC_CLASS is not set 843CONFIG_RTC_LIB=y
844CONFIG_RTC_CLASS=y
845CONFIG_RTC_HCTOSYS=y
846CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
847# CONFIG_RTC_DEBUG is not set
848
849#
850# RTC interfaces
851#
852CONFIG_RTC_INTF_SYSFS=y
853CONFIG_RTC_INTF_PROC=y
854CONFIG_RTC_INTF_DEV=y
855# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
856# CONFIG_RTC_DRV_TEST is not set
857
858#
859# I2C RTC drivers
860#
861CONFIG_RTC_DRV_DS1307=y
862# CONFIG_RTC_DRV_DS1374 is not set
863# CONFIG_RTC_DRV_DS1672 is not set
864# CONFIG_RTC_DRV_MAX6900 is not set
865# CONFIG_RTC_DRV_RS5C372 is not set
866# CONFIG_RTC_DRV_ISL1208 is not set
867# CONFIG_RTC_DRV_X1205 is not set
868# CONFIG_RTC_DRV_PCF8563 is not set
869# CONFIG_RTC_DRV_PCF8583 is not set
870# CONFIG_RTC_DRV_M41T80 is not set
871# CONFIG_RTC_DRV_S35390A is not set
872# CONFIG_RTC_DRV_FM3130 is not set
873# CONFIG_RTC_DRV_RX8581 is not set
874# CONFIG_RTC_DRV_RX8025 is not set
875
876#
877# SPI RTC drivers
878#
879
880#
881# Platform RTC drivers
882#
883# CONFIG_RTC_DRV_CMOS is not set
884# CONFIG_RTC_DRV_DS1286 is not set
885# CONFIG_RTC_DRV_DS1511 is not set
886# CONFIG_RTC_DRV_DS1553 is not set
887# CONFIG_RTC_DRV_DS1742 is not set
888# CONFIG_RTC_DRV_STK17TA8 is not set
889# CONFIG_RTC_DRV_M48T86 is not set
890# CONFIG_RTC_DRV_M48T35 is not set
891# CONFIG_RTC_DRV_M48T59 is not set
892# CONFIG_RTC_DRV_BQ4802 is not set
893# CONFIG_RTC_DRV_V3020 is not set
894
895#
896# on-CPU RTC drivers
897#
898# CONFIG_RTC_DRV_GENERIC is not set
695# CONFIG_DMADEVICES is not set 899# CONFIG_DMADEVICES is not set
696# CONFIG_AUXDISPLAY is not set 900# CONFIG_AUXDISPLAY is not set
697# CONFIG_UIO is not set 901# CONFIG_UIO is not set
902
903#
904# TI VLYNQ
905#
698# CONFIG_STAGING is not set 906# CONFIG_STAGING is not set
699 907
700# 908#
@@ -708,11 +916,12 @@ CONFIG_EXT2_FS=y
708# CONFIG_REISERFS_FS is not set 916# CONFIG_REISERFS_FS is not set
709# CONFIG_JFS_FS is not set 917# CONFIG_JFS_FS is not set
710# CONFIG_FS_POSIX_ACL is not set 918# CONFIG_FS_POSIX_ACL is not set
711CONFIG_FILE_LOCKING=y
712# CONFIG_XFS_FS is not set 919# CONFIG_XFS_FS is not set
713# CONFIG_GFS2_FS is not set 920# CONFIG_GFS2_FS is not set
714# CONFIG_OCFS2_FS is not set 921# CONFIG_OCFS2_FS is not set
715# CONFIG_BTRFS_FS is not set 922# CONFIG_BTRFS_FS is not set
923CONFIG_FILE_LOCKING=y
924CONFIG_FSNOTIFY=y
716CONFIG_DNOTIFY=y 925CONFIG_DNOTIFY=y
717CONFIG_INOTIFY=y 926CONFIG_INOTIFY=y
718CONFIG_INOTIFY_USER=y 927CONFIG_INOTIFY_USER=y
@@ -818,6 +1027,7 @@ CONFIG_HAS_IOPORT=y
818CONFIG_HAS_DMA=y 1027CONFIG_HAS_DMA=y
819CONFIG_HAVE_LMB=y 1028CONFIG_HAVE_LMB=y
820CONFIG_NLATTR=y 1029CONFIG_NLATTR=y
1030CONFIG_GENERIC_ATOMIC64=y
821 1031
822# 1032#
823# Kernel hacking 1033# Kernel hacking
@@ -848,6 +1058,9 @@ CONFIG_SCHED_DEBUG=y
848# CONFIG_RT_MUTEX_TESTER is not set 1058# CONFIG_RT_MUTEX_TESTER is not set
849# CONFIG_DEBUG_SPINLOCK is not set 1059# CONFIG_DEBUG_SPINLOCK is not set
850# CONFIG_DEBUG_MUTEXES is not set 1060# CONFIG_DEBUG_MUTEXES is not set
1061# CONFIG_DEBUG_LOCK_ALLOC is not set
1062# CONFIG_PROVE_LOCKING is not set
1063# CONFIG_LOCK_STAT is not set
851# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1064# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
852# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1065# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
853# CONFIG_DEBUG_KOBJECT is not set 1066# CONFIG_DEBUG_KOBJECT is not set
@@ -859,7 +1072,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
859# CONFIG_DEBUG_LIST is not set 1072# CONFIG_DEBUG_LIST is not set
860# CONFIG_DEBUG_SG is not set 1073# CONFIG_DEBUG_SG is not set
861# CONFIG_DEBUG_NOTIFIERS is not set 1074# CONFIG_DEBUG_NOTIFIERS is not set
862# CONFIG_BOOT_PRINTK_DELAY is not set
863# CONFIG_RCU_TORTURE_TEST is not set 1075# CONFIG_RCU_TORTURE_TEST is not set
864# CONFIG_RCU_CPU_STALL_DETECTOR is not set 1076# CONFIG_RCU_CPU_STALL_DETECTOR is not set
865# CONFIG_BACKTRACE_SELF_TEST is not set 1077# CONFIG_BACKTRACE_SELF_TEST is not set
@@ -873,16 +1085,15 @@ CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
873CONFIG_HAVE_DYNAMIC_FTRACE=y 1085CONFIG_HAVE_DYNAMIC_FTRACE=y
874CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y 1086CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
875CONFIG_TRACING_SUPPORT=y 1087CONFIG_TRACING_SUPPORT=y
876 1088CONFIG_FTRACE=y
877#
878# Tracers
879#
880# CONFIG_FUNCTION_TRACER is not set 1089# CONFIG_FUNCTION_TRACER is not set
1090# CONFIG_IRQSOFF_TRACER is not set
881# CONFIG_SCHED_TRACER is not set 1091# CONFIG_SCHED_TRACER is not set
882# CONFIG_CONTEXT_SWITCH_TRACER is not set 1092# CONFIG_ENABLE_DEFAULT_TRACERS is not set
883# CONFIG_EVENT_TRACER is not set
884# CONFIG_BOOT_TRACER is not set 1093# CONFIG_BOOT_TRACER is not set
885# CONFIG_TRACE_BRANCH_PROFILING is not set 1094CONFIG_BRANCH_PROFILE_NONE=y
1095# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1096# CONFIG_PROFILE_ALL_BRANCHES is not set
886# CONFIG_STACK_TRACER is not set 1097# CONFIG_STACK_TRACER is not set
887# CONFIG_KMEMTRACE is not set 1098# CONFIG_KMEMTRACE is not set
888# CONFIG_WORKQUEUE_TRACER is not set 1099# CONFIG_WORKQUEUE_TRACER is not set
@@ -891,6 +1102,9 @@ CONFIG_TRACING_SUPPORT=y
891# CONFIG_SAMPLES is not set 1102# CONFIG_SAMPLES is not set
892CONFIG_HAVE_ARCH_KGDB=y 1103CONFIG_HAVE_ARCH_KGDB=y
893# CONFIG_KGDB is not set 1104# CONFIG_KGDB is not set
1105# CONFIG_KMEMCHECK is not set
1106# CONFIG_PPC_DISABLE_WERROR is not set
1107CONFIG_PPC_WERROR=y
894CONFIG_PRINT_STACK_DEPTH=64 1108CONFIG_PRINT_STACK_DEPTH=64
895# CONFIG_DEBUG_STACKOVERFLOW is not set 1109# CONFIG_DEBUG_STACKOVERFLOW is not set
896# CONFIG_DEBUG_STACK_USAGE is not set 1110# CONFIG_DEBUG_STACK_USAGE is not set
diff --git a/arch/powerpc/configs/44x/arches_defconfig b/arch/powerpc/configs/44x/arches_defconfig
index f7fd32c09424..6f976b51cdd0 100644
--- a/arch/powerpc/configs/44x/arches_defconfig
+++ b/arch/powerpc/configs/44x/arches_defconfig
@@ -1,14 +1,14 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.29-rc2 3# Linux kernel version: 2.6.31-rc5
4# Tue Jan 20 08:22:31 2009 4# Thu Aug 13 14:14:07 2009
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7 7
8# 8#
9# Processor support 9# Processor support
10# 10#
11# CONFIG_6xx is not set 11# CONFIG_PPC_BOOK3S_32 is not set
12# CONFIG_PPC_85xx is not set 12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set 13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set 14# CONFIG_40x is not set
@@ -31,15 +31,16 @@ CONFIG_GENERIC_TIME=y
31CONFIG_GENERIC_TIME_VSYSCALL=y 31CONFIG_GENERIC_TIME_VSYSCALL=y
32CONFIG_GENERIC_CLOCKEVENTS=y 32CONFIG_GENERIC_CLOCKEVENTS=y
33CONFIG_GENERIC_HARDIRQS=y 33CONFIG_GENERIC_HARDIRQS=y
34CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
34# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set 35# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
35CONFIG_IRQ_PER_CPU=y 36CONFIG_IRQ_PER_CPU=y
36CONFIG_STACKTRACE_SUPPORT=y 37CONFIG_STACKTRACE_SUPPORT=y
37CONFIG_HAVE_LATENCYTOP_SUPPORT=y 38CONFIG_HAVE_LATENCYTOP_SUPPORT=y
39CONFIG_TRACE_IRQFLAGS_SUPPORT=y
38CONFIG_LOCKDEP_SUPPORT=y 40CONFIG_LOCKDEP_SUPPORT=y
39CONFIG_RWSEM_XCHGADD_ALGORITHM=y 41CONFIG_RWSEM_XCHGADD_ALGORITHM=y
40CONFIG_ARCH_HAS_ILOG2_U32=y 42CONFIG_ARCH_HAS_ILOG2_U32=y
41CONFIG_GENERIC_HWEIGHT=y 43CONFIG_GENERIC_HWEIGHT=y
42CONFIG_GENERIC_CALIBRATE_DELAY=y
43CONFIG_GENERIC_FIND_NEXT_BIT=y 44CONFIG_GENERIC_FIND_NEXT_BIT=y
44# CONFIG_ARCH_NO_VIRT_TO_BUS is not set 45# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
45CONFIG_PPC=y 46CONFIG_PPC=y
@@ -53,11 +54,14 @@ CONFIG_PPC_UDBG_16550=y
53# CONFIG_GENERIC_TBSYNC is not set 54# CONFIG_GENERIC_TBSYNC is not set
54CONFIG_AUDIT_ARCH=y 55CONFIG_AUDIT_ARCH=y
55CONFIG_GENERIC_BUG=y 56CONFIG_GENERIC_BUG=y
57CONFIG_DTC=y
56# CONFIG_DEFAULT_UIMAGE is not set 58# CONFIG_DEFAULT_UIMAGE is not set
57CONFIG_PPC_DCR_NATIVE=y 59CONFIG_PPC_DCR_NATIVE=y
58# CONFIG_PPC_DCR_MMIO is not set 60# CONFIG_PPC_DCR_MMIO is not set
59CONFIG_PPC_DCR=y 61CONFIG_PPC_DCR=y
62CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
60CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 63CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
64CONFIG_CONSTRUCTORS=y
61 65
62# 66#
63# General setup 67# General setup
@@ -71,9 +75,19 @@ CONFIG_SWAP=y
71CONFIG_SYSVIPC=y 75CONFIG_SYSVIPC=y
72CONFIG_SYSVIPC_SYSCTL=y 76CONFIG_SYSVIPC_SYSCTL=y
73CONFIG_POSIX_MQUEUE=y 77CONFIG_POSIX_MQUEUE=y
78CONFIG_POSIX_MQUEUE_SYSCTL=y
74# CONFIG_BSD_PROCESS_ACCT is not set 79# CONFIG_BSD_PROCESS_ACCT is not set
75# CONFIG_TASKSTATS is not set 80# CONFIG_TASKSTATS is not set
76# CONFIG_AUDIT is not set 81# CONFIG_AUDIT is not set
82
83#
84# RCU Subsystem
85#
86CONFIG_CLASSIC_RCU=y
87# CONFIG_TREE_RCU is not set
88# CONFIG_PREEMPT_RCU is not set
89# CONFIG_TREE_RCU_TRACE is not set
90# CONFIG_PREEMPT_RCU_TRACE is not set
77# CONFIG_IKCONFIG is not set 91# CONFIG_IKCONFIG is not set
78CONFIG_LOG_BUF_SHIFT=14 92CONFIG_LOG_BUF_SHIFT=14
79# CONFIG_GROUP_SCHED is not set 93# CONFIG_GROUP_SCHED is not set
@@ -84,8 +98,12 @@ CONFIG_SYSFS_DEPRECATED_V2=y
84# CONFIG_NAMESPACES is not set 98# CONFIG_NAMESPACES is not set
85CONFIG_BLK_DEV_INITRD=y 99CONFIG_BLK_DEV_INITRD=y
86CONFIG_INITRAMFS_SOURCE="" 100CONFIG_INITRAMFS_SOURCE=""
101CONFIG_RD_GZIP=y
102# CONFIG_RD_BZIP2 is not set
103# CONFIG_RD_LZMA is not set
87# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 104# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
88CONFIG_SYSCTL=y 105CONFIG_SYSCTL=y
106CONFIG_ANON_INODES=y
89CONFIG_EMBEDDED=y 107CONFIG_EMBEDDED=y
90CONFIG_SYSCTL_SYSCALL=y 108CONFIG_SYSCTL_SYSCALL=y
91CONFIG_KALLSYMS=y 109CONFIG_KALLSYMS=y
@@ -95,23 +113,30 @@ CONFIG_HOTPLUG=y
95CONFIG_PRINTK=y 113CONFIG_PRINTK=y
96CONFIG_BUG=y 114CONFIG_BUG=y
97CONFIG_ELF_CORE=y 115CONFIG_ELF_CORE=y
98CONFIG_COMPAT_BRK=y
99CONFIG_BASE_FULL=y 116CONFIG_BASE_FULL=y
100CONFIG_FUTEX=y 117CONFIG_FUTEX=y
101CONFIG_ANON_INODES=y
102CONFIG_EPOLL=y 118CONFIG_EPOLL=y
103CONFIG_SIGNALFD=y 119CONFIG_SIGNALFD=y
104CONFIG_TIMERFD=y 120CONFIG_TIMERFD=y
105CONFIG_EVENTFD=y 121CONFIG_EVENTFD=y
106CONFIG_SHMEM=y 122CONFIG_SHMEM=y
107CONFIG_AIO=y 123CONFIG_AIO=y
124CONFIG_HAVE_PERF_COUNTERS=y
125
126#
127# Performance Counters
128#
129# CONFIG_PERF_COUNTERS is not set
108CONFIG_VM_EVENT_COUNTERS=y 130CONFIG_VM_EVENT_COUNTERS=y
109CONFIG_PCI_QUIRKS=y 131CONFIG_PCI_QUIRKS=y
110CONFIG_SLUB_DEBUG=y 132CONFIG_SLUB_DEBUG=y
133# CONFIG_STRIP_ASM_SYMS is not set
134CONFIG_COMPAT_BRK=y
111# CONFIG_SLAB is not set 135# CONFIG_SLAB is not set
112CONFIG_SLUB=y 136CONFIG_SLUB=y
113# CONFIG_SLOB is not set 137# CONFIG_SLOB is not set
114# CONFIG_PROFILING is not set 138# CONFIG_PROFILING is not set
139# CONFIG_MARKERS is not set
115CONFIG_HAVE_OPROFILE=y 140CONFIG_HAVE_OPROFILE=y
116# CONFIG_KPROBES is not set 141# CONFIG_KPROBES is not set
117CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y 142CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
@@ -119,6 +144,12 @@ CONFIG_HAVE_IOREMAP_PROT=y
119CONFIG_HAVE_KPROBES=y 144CONFIG_HAVE_KPROBES=y
120CONFIG_HAVE_KRETPROBES=y 145CONFIG_HAVE_KRETPROBES=y
121CONFIG_HAVE_ARCH_TRACEHOOK=y 146CONFIG_HAVE_ARCH_TRACEHOOK=y
147
148#
149# GCOV-based kernel profiling
150#
151# CONFIG_GCOV_KERNEL is not set
152# CONFIG_SLOW_WORK is not set
122# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 153# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
123CONFIG_SLABINFO=y 154CONFIG_SLABINFO=y
124CONFIG_RT_MUTEXES=y 155CONFIG_RT_MUTEXES=y
@@ -130,8 +161,7 @@ CONFIG_MODULE_UNLOAD=y
130# CONFIG_MODVERSIONS is not set 161# CONFIG_MODVERSIONS is not set
131# CONFIG_MODULE_SRCVERSION_ALL is not set 162# CONFIG_MODULE_SRCVERSION_ALL is not set
132CONFIG_BLOCK=y 163CONFIG_BLOCK=y
133CONFIG_LBD=y 164CONFIG_LBDAF=y
134# CONFIG_BLK_DEV_IO_TRACE is not set
135# CONFIG_BLK_DEV_BSG is not set 165# CONFIG_BLK_DEV_BSG is not set
136# CONFIG_BLK_DEV_INTEGRITY is not set 166# CONFIG_BLK_DEV_INTEGRITY is not set
137 167
@@ -147,11 +177,6 @@ CONFIG_DEFAULT_AS=y
147# CONFIG_DEFAULT_CFQ is not set 177# CONFIG_DEFAULT_CFQ is not set
148# CONFIG_DEFAULT_NOOP is not set 178# CONFIG_DEFAULT_NOOP is not set
149CONFIG_DEFAULT_IOSCHED="anticipatory" 179CONFIG_DEFAULT_IOSCHED="anticipatory"
150CONFIG_CLASSIC_RCU=y
151# CONFIG_TREE_RCU is not set
152# CONFIG_PREEMPT_RCU is not set
153# CONFIG_TREE_RCU_TRACE is not set
154# CONFIG_PREEMPT_RCU_TRACE is not set
155# CONFIG_FREEZER is not set 180# CONFIG_FREEZER is not set
156CONFIG_PPC4xx_PCI_EXPRESS=y 181CONFIG_PPC4xx_PCI_EXPRESS=y
157 182
@@ -172,6 +197,7 @@ CONFIG_PPC4xx_PCI_EXPRESS=y
172CONFIG_ARCHES=y 197CONFIG_ARCHES=y
173# CONFIG_CANYONLANDS is not set 198# CONFIG_CANYONLANDS is not set
174# CONFIG_GLACIER is not set 199# CONFIG_GLACIER is not set
200# CONFIG_REDWOOD is not set
175# CONFIG_YOSEMITE is not set 201# CONFIG_YOSEMITE is not set
176# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set 202# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set
177CONFIG_PPC44x_SIMPLE=y 203CONFIG_PPC44x_SIMPLE=y
@@ -214,6 +240,7 @@ CONFIG_BINFMT_ELF=y
214# CONFIG_BINFMT_MISC is not set 240# CONFIG_BINFMT_MISC is not set
215# CONFIG_MATH_EMULATION is not set 241# CONFIG_MATH_EMULATION is not set
216# CONFIG_IOMMU_HELPER is not set 242# CONFIG_IOMMU_HELPER is not set
243# CONFIG_SWIOTLB is not set
217CONFIG_PPC_NEED_DMA_SYNC_OPS=y 244CONFIG_PPC_NEED_DMA_SYNC_OPS=y
218CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 245CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
219CONFIG_ARCH_HAS_WALK_MEMORY=y 246CONFIG_ARCH_HAS_WALK_MEMORY=y
@@ -233,10 +260,14 @@ CONFIG_PHYS_ADDR_T_64BIT=y
233CONFIG_ZONE_DMA_FLAG=1 260CONFIG_ZONE_DMA_FLAG=1
234CONFIG_BOUNCE=y 261CONFIG_BOUNCE=y
235CONFIG_VIRT_TO_BUS=y 262CONFIG_VIRT_TO_BUS=y
236CONFIG_UNEVICTABLE_LRU=y 263CONFIG_HAVE_MLOCK=y
264CONFIG_HAVE_MLOCKED_PAGE_BIT=y
265CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
266CONFIG_STDBINUTILS=y
237CONFIG_PPC_4K_PAGES=y 267CONFIG_PPC_4K_PAGES=y
238# CONFIG_PPC_16K_PAGES is not set 268# CONFIG_PPC_16K_PAGES is not set
239# CONFIG_PPC_64K_PAGES is not set 269# CONFIG_PPC_64K_PAGES is not set
270# CONFIG_PPC_256K_PAGES is not set
240CONFIG_FORCE_MAX_ZONEORDER=11 271CONFIG_FORCE_MAX_ZONEORDER=11
241CONFIG_PROC_DEVICETREE=y 272CONFIG_PROC_DEVICETREE=y
242CONFIG_CMDLINE_BOOL=y 273CONFIG_CMDLINE_BOOL=y
@@ -261,6 +292,7 @@ CONFIG_ARCH_SUPPORTS_MSI=y
261# CONFIG_PCI_LEGACY is not set 292# CONFIG_PCI_LEGACY is not set
262# CONFIG_PCI_DEBUG is not set 293# CONFIG_PCI_DEBUG is not set
263# CONFIG_PCI_STUB is not set 294# CONFIG_PCI_STUB is not set
295# CONFIG_PCI_IOV is not set
264# CONFIG_PCCARD is not set 296# CONFIG_PCCARD is not set
265# CONFIG_HOTPLUG_PCI is not set 297# CONFIG_HOTPLUG_PCI is not set
266# CONFIG_HAS_RAPIDIO is not set 298# CONFIG_HAS_RAPIDIO is not set
@@ -278,14 +310,12 @@ CONFIG_PAGE_OFFSET=0xc0000000
278CONFIG_KERNEL_START=0xc0000000 310CONFIG_KERNEL_START=0xc0000000
279CONFIG_PHYSICAL_START=0x00000000 311CONFIG_PHYSICAL_START=0x00000000
280CONFIG_TASK_SIZE=0xc0000000 312CONFIG_TASK_SIZE=0xc0000000
281CONFIG_CONSISTENT_START=0xff100000
282CONFIG_CONSISTENT_SIZE=0x00200000 313CONFIG_CONSISTENT_SIZE=0x00200000
283CONFIG_NET=y 314CONFIG_NET=y
284 315
285# 316#
286# Networking options 317# Networking options
287# 318#
288CONFIG_COMPAT_NET_DEV_OPS=y
289CONFIG_PACKET=y 319CONFIG_PACKET=y
290# CONFIG_PACKET_MMAP is not set 320# CONFIG_PACKET_MMAP is not set
291CONFIG_UNIX=y 321CONFIG_UNIX=y
@@ -335,6 +365,8 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
335# CONFIG_LAPB is not set 365# CONFIG_LAPB is not set
336# CONFIG_ECONET is not set 366# CONFIG_ECONET is not set
337# CONFIG_WAN_ROUTER is not set 367# CONFIG_WAN_ROUTER is not set
368# CONFIG_PHONET is not set
369# CONFIG_IEEE802154 is not set
338# CONFIG_NET_SCHED is not set 370# CONFIG_NET_SCHED is not set
339# CONFIG_DCB is not set 371# CONFIG_DCB is not set
340 372
@@ -347,7 +379,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
347# CONFIG_IRDA is not set 379# CONFIG_IRDA is not set
348# CONFIG_BT is not set 380# CONFIG_BT is not set
349# CONFIG_AF_RXRPC is not set 381# CONFIG_AF_RXRPC is not set
350# CONFIG_PHONET is not set
351# CONFIG_WIRELESS is not set 382# CONFIG_WIRELESS is not set
352# CONFIG_WIMAX is not set 383# CONFIG_WIMAX is not set
353# CONFIG_RFKILL is not set 384# CONFIG_RFKILL is not set
@@ -371,8 +402,92 @@ CONFIG_EXTRA_FIRMWARE=""
371# CONFIG_SYS_HYPERVISOR is not set 402# CONFIG_SYS_HYPERVISOR is not set
372CONFIG_CONNECTOR=y 403CONFIG_CONNECTOR=y
373CONFIG_PROC_EVENTS=y 404CONFIG_PROC_EVENTS=y
374# CONFIG_MTD is not set 405CONFIG_MTD=y
406# CONFIG_MTD_DEBUG is not set
407# CONFIG_MTD_CONCAT is not set
408CONFIG_MTD_PARTITIONS=y
409# CONFIG_MTD_TESTS is not set
410# CONFIG_MTD_REDBOOT_PARTS is not set
411CONFIG_MTD_CMDLINE_PARTS=y
412CONFIG_MTD_OF_PARTS=y
413# CONFIG_MTD_AR7_PARTS is not set
414
415#
416# User Modules And Translation Layers
417#
418CONFIG_MTD_CHAR=y
419CONFIG_MTD_BLKDEVS=y
420CONFIG_MTD_BLOCK=y
421# CONFIG_FTL is not set
422# CONFIG_NFTL is not set
423# CONFIG_INFTL is not set
424# CONFIG_RFD_FTL is not set
425# CONFIG_SSFDC is not set
426# CONFIG_MTD_OOPS is not set
427
428#
429# RAM/ROM/Flash chip drivers
430#
431CONFIG_MTD_CFI=y
432# CONFIG_MTD_JEDECPROBE is not set
433CONFIG_MTD_GEN_PROBE=y
434# CONFIG_MTD_CFI_ADV_OPTIONS is not set
435CONFIG_MTD_MAP_BANK_WIDTH_1=y
436CONFIG_MTD_MAP_BANK_WIDTH_2=y
437CONFIG_MTD_MAP_BANK_WIDTH_4=y
438# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
439# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
440# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
441CONFIG_MTD_CFI_I1=y
442CONFIG_MTD_CFI_I2=y
443# CONFIG_MTD_CFI_I4 is not set
444# CONFIG_MTD_CFI_I8 is not set
445# CONFIG_MTD_CFI_INTELEXT is not set
446CONFIG_MTD_CFI_AMDSTD=y
447# CONFIG_MTD_CFI_STAA is not set
448CONFIG_MTD_CFI_UTIL=y
449# CONFIG_MTD_RAM is not set
450# CONFIG_MTD_ROM is not set
451# CONFIG_MTD_ABSENT is not set
452
453#
454# Mapping drivers for chip access
455#
456# CONFIG_MTD_COMPLEX_MAPPINGS is not set
457# CONFIG_MTD_PHYSMAP is not set
458CONFIG_MTD_PHYSMAP_OF=y
459# CONFIG_MTD_INTEL_VR_NOR is not set
460# CONFIG_MTD_PLATRAM is not set
461
462#
463# Self-contained MTD device drivers
464#
465# CONFIG_MTD_PMC551 is not set
466# CONFIG_MTD_SLRAM is not set
467# CONFIG_MTD_PHRAM is not set
468# CONFIG_MTD_MTDRAM is not set
469# CONFIG_MTD_BLOCK2MTD is not set
470
471#
472# Disk-On-Chip Device Drivers
473#
474# CONFIG_MTD_DOC2000 is not set
475# CONFIG_MTD_DOC2001 is not set
476# CONFIG_MTD_DOC2001PLUS is not set
477# CONFIG_MTD_NAND is not set
478# CONFIG_MTD_ONENAND is not set
479
480#
481# LPDDR flash memory drivers
482#
483# CONFIG_MTD_LPDDR is not set
484
485#
486# UBI - Unsorted block images
487#
488# CONFIG_MTD_UBI is not set
375CONFIG_OF_DEVICE=y 489CONFIG_OF_DEVICE=y
490CONFIG_OF_I2C=y
376# CONFIG_PARPORT is not set 491# CONFIG_PARPORT is not set
377CONFIG_BLK_DEV=y 492CONFIG_BLK_DEV=y
378# CONFIG_BLK_DEV_FD is not set 493# CONFIG_BLK_DEV_FD is not set
@@ -412,7 +527,11 @@ CONFIG_HAVE_IDE=y
412# 527#
413 528
414# 529#
415# Enable only one of the two stacks, unless you know what you are doing 530# You can enable one or both FireWire driver stacks.
531#
532
533#
534# See the help texts for more information.
416# 535#
417# CONFIG_FIREWIRE is not set 536# CONFIG_FIREWIRE is not set
418# CONFIG_IEEE1394 is not set 537# CONFIG_IEEE1394 is not set
@@ -433,6 +552,8 @@ CONFIG_NET_ETHERNET=y
433# CONFIG_SUNGEM is not set 552# CONFIG_SUNGEM is not set
434# CONFIG_CASSINI is not set 553# CONFIG_CASSINI is not set
435# CONFIG_NET_VENDOR_3COM is not set 554# CONFIG_NET_VENDOR_3COM is not set
555# CONFIG_ETHOC is not set
556# CONFIG_DNET is not set
436# CONFIG_NET_TULIP is not set 557# CONFIG_NET_TULIP is not set
437# CONFIG_HP100 is not set 558# CONFIG_HP100 is not set
438CONFIG_IBM_NEW_EMAC=y 559CONFIG_IBM_NEW_EMAC=y
@@ -451,6 +572,7 @@ CONFIG_IBM_NEW_EMAC_EMAC4=y
451# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 572# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
452# CONFIG_NET_PCI is not set 573# CONFIG_NET_PCI is not set
453# CONFIG_B44 is not set 574# CONFIG_B44 is not set
575# CONFIG_KS8842 is not set
454# CONFIG_ATL2 is not set 576# CONFIG_ATL2 is not set
455# CONFIG_NETDEV_1000 is not set 577# CONFIG_NETDEV_1000 is not set
456# CONFIG_NETDEV_10000 is not set 578# CONFIG_NETDEV_10000 is not set
@@ -461,7 +583,6 @@ CONFIG_IBM_NEW_EMAC_EMAC4=y
461# 583#
462# CONFIG_WLAN_PRE80211 is not set 584# CONFIG_WLAN_PRE80211 is not set
463# CONFIG_WLAN_80211 is not set 585# CONFIG_WLAN_80211 is not set
464# CONFIG_IWLWIFI_LEDS is not set
465 586
466# 587#
467# Enable WiMAX (Networking options) to see the WiMAX drivers 588# Enable WiMAX (Networking options) to see the WiMAX drivers
@@ -533,13 +654,143 @@ CONFIG_LEGACY_PTY_COUNT=256
533# CONFIG_RAW_DRIVER is not set 654# CONFIG_RAW_DRIVER is not set
534# CONFIG_TCG_TPM is not set 655# CONFIG_TCG_TPM is not set
535CONFIG_DEVPORT=y 656CONFIG_DEVPORT=y
536# CONFIG_I2C is not set 657CONFIG_I2C=y
658CONFIG_I2C_BOARDINFO=y
659CONFIG_I2C_CHARDEV=y
660CONFIG_I2C_HELPER_AUTO=y
661
662#
663# I2C Hardware Bus support
664#
665
666#
667# PC SMBus host controller drivers
668#
669# CONFIG_I2C_ALI1535 is not set
670# CONFIG_I2C_ALI1563 is not set
671# CONFIG_I2C_ALI15X3 is not set
672# CONFIG_I2C_AMD756 is not set
673# CONFIG_I2C_AMD8111 is not set
674# CONFIG_I2C_I801 is not set
675# CONFIG_I2C_ISCH is not set
676# CONFIG_I2C_PIIX4 is not set
677# CONFIG_I2C_NFORCE2 is not set
678# CONFIG_I2C_SIS5595 is not set
679# CONFIG_I2C_SIS630 is not set
680# CONFIG_I2C_SIS96X is not set
681# CONFIG_I2C_VIA is not set
682# CONFIG_I2C_VIAPRO is not set
683
684#
685# I2C system bus drivers (mostly embedded / system-on-chip)
686#
687CONFIG_I2C_IBM_IIC=y
688# CONFIG_I2C_MPC is not set
689# CONFIG_I2C_OCORES is not set
690# CONFIG_I2C_SIMTEC is not set
691
692#
693# External I2C/SMBus adapter drivers
694#
695# CONFIG_I2C_PARPORT_LIGHT is not set
696# CONFIG_I2C_TAOS_EVM is not set
697
698#
699# Graphics adapter I2C/DDC channel drivers
700#
701# CONFIG_I2C_VOODOO3 is not set
702
703#
704# Other I2C/SMBus bus drivers
705#
706# CONFIG_I2C_PCA_PLATFORM is not set
707# CONFIG_I2C_STUB is not set
708
709#
710# Miscellaneous I2C Chip support
711#
712# CONFIG_DS1682 is not set
713# CONFIG_SENSORS_PCF8574 is not set
714# CONFIG_PCF8575 is not set
715# CONFIG_SENSORS_PCA9539 is not set
716# CONFIG_SENSORS_TSL2550 is not set
717# CONFIG_I2C_DEBUG_CORE is not set
718# CONFIG_I2C_DEBUG_ALGO is not set
719# CONFIG_I2C_DEBUG_BUS is not set
720# CONFIG_I2C_DEBUG_CHIP is not set
537# CONFIG_SPI is not set 721# CONFIG_SPI is not set
722
723#
724# PPS support
725#
726# CONFIG_PPS is not set
538CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 727CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
539# CONFIG_GPIOLIB is not set 728# CONFIG_GPIOLIB is not set
540# CONFIG_W1 is not set 729# CONFIG_W1 is not set
541# CONFIG_POWER_SUPPLY is not set 730# CONFIG_POWER_SUPPLY is not set
542# CONFIG_HWMON is not set 731CONFIG_HWMON=y
732# CONFIG_HWMON_VID is not set
733CONFIG_SENSORS_AD7414=y
734# CONFIG_SENSORS_AD7418 is not set
735# CONFIG_SENSORS_ADM1021 is not set
736# CONFIG_SENSORS_ADM1025 is not set
737# CONFIG_SENSORS_ADM1026 is not set
738# CONFIG_SENSORS_ADM1029 is not set
739# CONFIG_SENSORS_ADM1031 is not set
740# CONFIG_SENSORS_ADM9240 is not set
741# CONFIG_SENSORS_ADT7462 is not set
742# CONFIG_SENSORS_ADT7470 is not set
743# CONFIG_SENSORS_ADT7473 is not set
744# CONFIG_SENSORS_ADT7475 is not set
745# CONFIG_SENSORS_ATXP1 is not set
746# CONFIG_SENSORS_DS1621 is not set
747# CONFIG_SENSORS_I5K_AMB is not set
748# CONFIG_SENSORS_F71805F is not set
749# CONFIG_SENSORS_F71882FG is not set
750# CONFIG_SENSORS_F75375S is not set
751# CONFIG_SENSORS_G760A is not set
752# CONFIG_SENSORS_GL518SM is not set
753# CONFIG_SENSORS_GL520SM is not set
754# CONFIG_SENSORS_IT87 is not set
755# CONFIG_SENSORS_LM63 is not set
756# CONFIG_SENSORS_LM75 is not set
757# CONFIG_SENSORS_LM77 is not set
758# CONFIG_SENSORS_LM78 is not set
759# CONFIG_SENSORS_LM80 is not set
760# CONFIG_SENSORS_LM83 is not set
761# CONFIG_SENSORS_LM85 is not set
762# CONFIG_SENSORS_LM87 is not set
763# CONFIG_SENSORS_LM90 is not set
764# CONFIG_SENSORS_LM92 is not set
765# CONFIG_SENSORS_LM93 is not set
766# CONFIG_SENSORS_LTC4215 is not set
767# CONFIG_SENSORS_LTC4245 is not set
768# CONFIG_SENSORS_LM95241 is not set
769# CONFIG_SENSORS_MAX1619 is not set
770# CONFIG_SENSORS_MAX6650 is not set
771# CONFIG_SENSORS_PC87360 is not set
772# CONFIG_SENSORS_PC87427 is not set
773# CONFIG_SENSORS_PCF8591 is not set
774# CONFIG_SENSORS_SIS5595 is not set
775# CONFIG_SENSORS_DME1737 is not set
776# CONFIG_SENSORS_SMSC47M1 is not set
777# CONFIG_SENSORS_SMSC47M192 is not set
778# CONFIG_SENSORS_SMSC47B397 is not set
779# CONFIG_SENSORS_ADS7828 is not set
780# CONFIG_SENSORS_THMC50 is not set
781# CONFIG_SENSORS_TMP401 is not set
782# CONFIG_SENSORS_VIA686A is not set
783# CONFIG_SENSORS_VT1211 is not set
784# CONFIG_SENSORS_VT8231 is not set
785# CONFIG_SENSORS_W83781D is not set
786# CONFIG_SENSORS_W83791D is not set
787# CONFIG_SENSORS_W83792D is not set
788# CONFIG_SENSORS_W83793 is not set
789# CONFIG_SENSORS_W83L785TS is not set
790# CONFIG_SENSORS_W83L786NG is not set
791# CONFIG_SENSORS_W83627HF is not set
792# CONFIG_SENSORS_W83627EHF is not set
793# CONFIG_HWMON_DEBUG_CHIP is not set
543# CONFIG_THERMAL is not set 794# CONFIG_THERMAL is not set
544# CONFIG_THERMAL_HWMON is not set 795# CONFIG_THERMAL_HWMON is not set
545# CONFIG_WATCHDOG is not set 796# CONFIG_WATCHDOG is not set
@@ -556,24 +807,15 @@ CONFIG_SSB_POSSIBLE=y
556# CONFIG_MFD_CORE is not set 807# CONFIG_MFD_CORE is not set
557# CONFIG_MFD_SM501 is not set 808# CONFIG_MFD_SM501 is not set
558# CONFIG_HTC_PASIC3 is not set 809# CONFIG_HTC_PASIC3 is not set
810# CONFIG_TWL4030_CORE is not set
559# CONFIG_MFD_TMIO is not set 811# CONFIG_MFD_TMIO is not set
812# CONFIG_PMIC_DA903X is not set
813# CONFIG_MFD_WM8400 is not set
814# CONFIG_MFD_WM8350_I2C is not set
815# CONFIG_MFD_PCF50633 is not set
816# CONFIG_AB3100_CORE is not set
560# CONFIG_REGULATOR is not set 817# CONFIG_REGULATOR is not set
561 818# CONFIG_MEDIA_SUPPORT is not set
562#
563# Multimedia devices
564#
565
566#
567# Multimedia core support
568#
569# CONFIG_VIDEO_DEV is not set
570# CONFIG_DVB_CORE is not set
571# CONFIG_VIDEO_MEDIA is not set
572
573#
574# Multimedia drivers
575#
576CONFIG_DAB=y
577 819
578# 820#
579# Graphics support 821# Graphics support
@@ -600,7 +842,12 @@ CONFIG_VIDEO_OUTPUT_CONTROL=m
600# CONFIG_EDAC is not set 842# CONFIG_EDAC is not set
601# CONFIG_RTC_CLASS is not set 843# CONFIG_RTC_CLASS is not set
602# CONFIG_DMADEVICES is not set 844# CONFIG_DMADEVICES is not set
845# CONFIG_AUXDISPLAY is not set
603# CONFIG_UIO is not set 846# CONFIG_UIO is not set
847
848#
849# TI VLYNQ
850#
604# CONFIG_STAGING is not set 851# CONFIG_STAGING is not set
605 852
606# 853#
@@ -614,11 +861,12 @@ CONFIG_EXT2_FS=y
614# CONFIG_REISERFS_FS is not set 861# CONFIG_REISERFS_FS is not set
615# CONFIG_JFS_FS is not set 862# CONFIG_JFS_FS is not set
616# CONFIG_FS_POSIX_ACL is not set 863# CONFIG_FS_POSIX_ACL is not set
617CONFIG_FILE_LOCKING=y
618# CONFIG_XFS_FS is not set 864# CONFIG_XFS_FS is not set
619# CONFIG_GFS2_FS is not set 865# CONFIG_GFS2_FS is not set
620# CONFIG_OCFS2_FS is not set 866# CONFIG_OCFS2_FS is not set
621# CONFIG_BTRFS_FS is not set 867# CONFIG_BTRFS_FS is not set
868CONFIG_FILE_LOCKING=y
869CONFIG_FSNOTIFY=y
622CONFIG_DNOTIFY=y 870CONFIG_DNOTIFY=y
623CONFIG_INOTIFY=y 871CONFIG_INOTIFY=y
624CONFIG_INOTIFY_USER=y 872CONFIG_INOTIFY_USER=y
@@ -628,6 +876,11 @@ CONFIG_INOTIFY_USER=y
628# CONFIG_FUSE_FS is not set 876# CONFIG_FUSE_FS is not set
629 877
630# 878#
879# Caches
880#
881# CONFIG_FSCACHE is not set
882
883#
631# CD-ROM/DVD Filesystems 884# CD-ROM/DVD Filesystems
632# 885#
633# CONFIG_ISO9660_FS is not set 886# CONFIG_ISO9660_FS is not set
@@ -660,6 +913,17 @@ CONFIG_MISC_FILESYSTEMS=y
660# CONFIG_BEFS_FS is not set 913# CONFIG_BEFS_FS is not set
661# CONFIG_BFS_FS is not set 914# CONFIG_BFS_FS is not set
662# CONFIG_EFS_FS is not set 915# CONFIG_EFS_FS is not set
916CONFIG_JFFS2_FS=y
917CONFIG_JFFS2_FS_DEBUG=0
918CONFIG_JFFS2_FS_WRITEBUFFER=y
919# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
920# CONFIG_JFFS2_SUMMARY is not set
921# CONFIG_JFFS2_FS_XATTR is not set
922# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
923CONFIG_JFFS2_ZLIB=y
924# CONFIG_JFFS2_LZO is not set
925CONFIG_JFFS2_RTIME=y
926# CONFIG_JFFS2_RUBIN is not set
663CONFIG_CRAMFS=y 927CONFIG_CRAMFS=y
664# CONFIG_SQUASHFS is not set 928# CONFIG_SQUASHFS is not set
665# CONFIG_VXFS_FS is not set 929# CONFIG_VXFS_FS is not set
@@ -670,6 +934,7 @@ CONFIG_CRAMFS=y
670# CONFIG_ROMFS_FS is not set 934# CONFIG_ROMFS_FS is not set
671# CONFIG_SYSV_FS is not set 935# CONFIG_SYSV_FS is not set
672# CONFIG_UFS_FS is not set 936# CONFIG_UFS_FS is not set
937# CONFIG_NILFS2_FS is not set
673CONFIG_NETWORK_FILESYSTEMS=y 938CONFIG_NETWORK_FILESYSTEMS=y
674CONFIG_NFS_FS=y 939CONFIG_NFS_FS=y
675CONFIG_NFS_V3=y 940CONFIG_NFS_V3=y
@@ -681,7 +946,6 @@ CONFIG_LOCKD=y
681CONFIG_LOCKD_V4=y 946CONFIG_LOCKD_V4=y
682CONFIG_NFS_COMMON=y 947CONFIG_NFS_COMMON=y
683CONFIG_SUNRPC=y 948CONFIG_SUNRPC=y
684# CONFIG_SUNRPC_REGISTER_V4 is not set
685# CONFIG_RPCSEC_GSS_KRB5 is not set 949# CONFIG_RPCSEC_GSS_KRB5 is not set
686# CONFIG_RPCSEC_GSS_SPKM3 is not set 950# CONFIG_RPCSEC_GSS_SPKM3 is not set
687# CONFIG_SMB_FS is not set 951# CONFIG_SMB_FS is not set
@@ -697,6 +961,7 @@ CONFIG_SUNRPC=y
697CONFIG_MSDOS_PARTITION=y 961CONFIG_MSDOS_PARTITION=y
698# CONFIG_NLS is not set 962# CONFIG_NLS is not set
699# CONFIG_DLM is not set 963# CONFIG_DLM is not set
964# CONFIG_BINARY_PRINTF is not set
700 965
701# 966#
702# Library routines 967# Library routines
@@ -711,11 +976,14 @@ CONFIG_CRC32=y
711# CONFIG_CRC7 is not set 976# CONFIG_CRC7 is not set
712# CONFIG_LIBCRC32C is not set 977# CONFIG_LIBCRC32C is not set
713CONFIG_ZLIB_INFLATE=y 978CONFIG_ZLIB_INFLATE=y
714CONFIG_PLIST=y 979CONFIG_ZLIB_DEFLATE=y
980CONFIG_DECOMPRESS_GZIP=y
715CONFIG_HAS_IOMEM=y 981CONFIG_HAS_IOMEM=y
716CONFIG_HAS_IOPORT=y 982CONFIG_HAS_IOPORT=y
717CONFIG_HAS_DMA=y 983CONFIG_HAS_DMA=y
718CONFIG_HAVE_LMB=y 984CONFIG_HAVE_LMB=y
985CONFIG_NLATTR=y
986CONFIG_GENERIC_ATOMIC64=y
719 987
720# 988#
721# Kernel hacking 989# Kernel hacking
@@ -733,6 +1001,9 @@ CONFIG_DEBUG_KERNEL=y
733CONFIG_DETECT_SOFTLOCKUP=y 1001CONFIG_DETECT_SOFTLOCKUP=y
734# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set 1002# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
735CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 1003CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1004CONFIG_DETECT_HUNG_TASK=y
1005# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1006CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
736CONFIG_SCHED_DEBUG=y 1007CONFIG_SCHED_DEBUG=y
737# CONFIG_SCHEDSTATS is not set 1008# CONFIG_SCHEDSTATS is not set
738# CONFIG_TIMER_STATS is not set 1009# CONFIG_TIMER_STATS is not set
@@ -743,6 +1014,9 @@ CONFIG_SCHED_DEBUG=y
743# CONFIG_RT_MUTEX_TESTER is not set 1014# CONFIG_RT_MUTEX_TESTER is not set
744# CONFIG_DEBUG_SPINLOCK is not set 1015# CONFIG_DEBUG_SPINLOCK is not set
745# CONFIG_DEBUG_MUTEXES is not set 1016# CONFIG_DEBUG_MUTEXES is not set
1017# CONFIG_DEBUG_LOCK_ALLOC is not set
1018# CONFIG_PROVE_LOCKING is not set
1019# CONFIG_LOCK_STAT is not set
746# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1020# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
747# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1021# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
748# CONFIG_DEBUG_KOBJECT is not set 1022# CONFIG_DEBUG_KOBJECT is not set
@@ -754,7 +1028,6 @@ CONFIG_SCHED_DEBUG=y
754# CONFIG_DEBUG_LIST is not set 1028# CONFIG_DEBUG_LIST is not set
755# CONFIG_DEBUG_SG is not set 1029# CONFIG_DEBUG_SG is not set
756# CONFIG_DEBUG_NOTIFIERS is not set 1030# CONFIG_DEBUG_NOTIFIERS is not set
757# CONFIG_BOOT_PRINTK_DELAY is not set
758# CONFIG_RCU_TORTURE_TEST is not set 1031# CONFIG_RCU_TORTURE_TEST is not set
759# CONFIG_RCU_CPU_STALL_DETECTOR is not set 1032# CONFIG_RCU_CPU_STALL_DETECTOR is not set
760# CONFIG_BACKTRACE_SELF_TEST is not set 1033# CONFIG_BACKTRACE_SELF_TEST is not set
@@ -762,27 +1035,36 @@ CONFIG_SCHED_DEBUG=y
762# CONFIG_FAULT_INJECTION is not set 1035# CONFIG_FAULT_INJECTION is not set
763# CONFIG_LATENCYTOP is not set 1036# CONFIG_LATENCYTOP is not set
764CONFIG_SYSCTL_SYSCALL_CHECK=y 1037CONFIG_SYSCTL_SYSCALL_CHECK=y
1038# CONFIG_DEBUG_PAGEALLOC is not set
765CONFIG_HAVE_FUNCTION_TRACER=y 1039CONFIG_HAVE_FUNCTION_TRACER=y
1040CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
766CONFIG_HAVE_DYNAMIC_FTRACE=y 1041CONFIG_HAVE_DYNAMIC_FTRACE=y
767CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y 1042CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
768 1043CONFIG_TRACING_SUPPORT=y
769# 1044CONFIG_FTRACE=y
770# Tracers
771#
772# CONFIG_FUNCTION_TRACER is not set 1045# CONFIG_FUNCTION_TRACER is not set
1046# CONFIG_IRQSOFF_TRACER is not set
773# CONFIG_SCHED_TRACER is not set 1047# CONFIG_SCHED_TRACER is not set
774# CONFIG_CONTEXT_SWITCH_TRACER is not set 1048# CONFIG_ENABLE_DEFAULT_TRACERS is not set
775# CONFIG_BOOT_TRACER is not set 1049# CONFIG_BOOT_TRACER is not set
776# CONFIG_TRACE_BRANCH_PROFILING is not set 1050CONFIG_BRANCH_PROFILE_NONE=y
1051# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1052# CONFIG_PROFILE_ALL_BRANCHES is not set
777# CONFIG_STACK_TRACER is not set 1053# CONFIG_STACK_TRACER is not set
778# CONFIG_DYNAMIC_PRINTK_DEBUG is not set 1054# CONFIG_KMEMTRACE is not set
1055# CONFIG_WORKQUEUE_TRACER is not set
1056# CONFIG_BLK_DEV_IO_TRACE is not set
1057# CONFIG_DYNAMIC_DEBUG is not set
779# CONFIG_SAMPLES is not set 1058# CONFIG_SAMPLES is not set
780CONFIG_HAVE_ARCH_KGDB=y 1059CONFIG_HAVE_ARCH_KGDB=y
781# CONFIG_KGDB is not set 1060# CONFIG_KGDB is not set
1061# CONFIG_KMEMCHECK is not set
1062# CONFIG_PPC_DISABLE_WERROR is not set
1063CONFIG_PPC_WERROR=y
782CONFIG_PRINT_STACK_DEPTH=64 1064CONFIG_PRINT_STACK_DEPTH=64
783# CONFIG_DEBUG_STACKOVERFLOW is not set 1065# CONFIG_DEBUG_STACKOVERFLOW is not set
784# CONFIG_DEBUG_STACK_USAGE is not set 1066# CONFIG_DEBUG_STACK_USAGE is not set
785# CONFIG_DEBUG_PAGEALLOC is not set 1067# CONFIG_PPC_EMULATED_STATS is not set
786# CONFIG_CODE_PATCHING_SELFTEST is not set 1068# CONFIG_CODE_PATCHING_SELFTEST is not set
787# CONFIG_FTR_FIXUP_SELFTEST is not set 1069# CONFIG_FTR_FIXUP_SELFTEST is not set
788# CONFIG_MSI_BITMAP_SELFTEST is not set 1070# CONFIG_MSI_BITMAP_SELFTEST is not set
diff --git a/arch/powerpc/configs/44x/canyonlands_defconfig b/arch/powerpc/configs/44x/canyonlands_defconfig
index 5e85412eb9fa..b312b166be66 100644
--- a/arch/powerpc/configs/44x/canyonlands_defconfig
+++ b/arch/powerpc/configs/44x/canyonlands_defconfig
@@ -1,14 +1,14 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.29-rc3 3# Linux kernel version: 2.6.31-rc4
4# Mon Feb 2 13:13:04 2009 4# Wed Jul 29 17:27:20 2009
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7 7
8# 8#
9# Processor support 9# Processor support
10# 10#
11# CONFIG_6xx is not set 11# CONFIG_PPC_BOOK3S_32 is not set
12# CONFIG_PPC_85xx is not set 12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set 13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set 14# CONFIG_40x is not set
@@ -31,15 +31,16 @@ CONFIG_GENERIC_TIME=y
31CONFIG_GENERIC_TIME_VSYSCALL=y 31CONFIG_GENERIC_TIME_VSYSCALL=y
32CONFIG_GENERIC_CLOCKEVENTS=y 32CONFIG_GENERIC_CLOCKEVENTS=y
33CONFIG_GENERIC_HARDIRQS=y 33CONFIG_GENERIC_HARDIRQS=y
34CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
34# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set 35# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
35CONFIG_IRQ_PER_CPU=y 36CONFIG_IRQ_PER_CPU=y
36CONFIG_STACKTRACE_SUPPORT=y 37CONFIG_STACKTRACE_SUPPORT=y
37CONFIG_HAVE_LATENCYTOP_SUPPORT=y 38CONFIG_HAVE_LATENCYTOP_SUPPORT=y
39CONFIG_TRACE_IRQFLAGS_SUPPORT=y
38CONFIG_LOCKDEP_SUPPORT=y 40CONFIG_LOCKDEP_SUPPORT=y
39CONFIG_RWSEM_XCHGADD_ALGORITHM=y 41CONFIG_RWSEM_XCHGADD_ALGORITHM=y
40CONFIG_ARCH_HAS_ILOG2_U32=y 42CONFIG_ARCH_HAS_ILOG2_U32=y
41CONFIG_GENERIC_HWEIGHT=y 43CONFIG_GENERIC_HWEIGHT=y
42CONFIG_GENERIC_CALIBRATE_DELAY=y
43CONFIG_GENERIC_FIND_NEXT_BIT=y 44CONFIG_GENERIC_FIND_NEXT_BIT=y
44# CONFIG_ARCH_NO_VIRT_TO_BUS is not set 45# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
45CONFIG_PPC=y 46CONFIG_PPC=y
@@ -53,11 +54,14 @@ CONFIG_PPC_UDBG_16550=y
53# CONFIG_GENERIC_TBSYNC is not set 54# CONFIG_GENERIC_TBSYNC is not set
54CONFIG_AUDIT_ARCH=y 55CONFIG_AUDIT_ARCH=y
55CONFIG_GENERIC_BUG=y 56CONFIG_GENERIC_BUG=y
57CONFIG_DTC=y
56# CONFIG_DEFAULT_UIMAGE is not set 58# CONFIG_DEFAULT_UIMAGE is not set
57CONFIG_PPC_DCR_NATIVE=y 59CONFIG_PPC_DCR_NATIVE=y
58# CONFIG_PPC_DCR_MMIO is not set 60# CONFIG_PPC_DCR_MMIO is not set
59CONFIG_PPC_DCR=y 61CONFIG_PPC_DCR=y
62CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
60CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 63CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
64CONFIG_CONSTRUCTORS=y
61 65
62# 66#
63# General setup 67# General setup
@@ -71,6 +75,7 @@ CONFIG_SWAP=y
71CONFIG_SYSVIPC=y 75CONFIG_SYSVIPC=y
72CONFIG_SYSVIPC_SYSCTL=y 76CONFIG_SYSVIPC_SYSCTL=y
73CONFIG_POSIX_MQUEUE=y 77CONFIG_POSIX_MQUEUE=y
78CONFIG_POSIX_MQUEUE_SYSCTL=y
74# CONFIG_BSD_PROCESS_ACCT is not set 79# CONFIG_BSD_PROCESS_ACCT is not set
75# CONFIG_TASKSTATS is not set 80# CONFIG_TASKSTATS is not set
76# CONFIG_AUDIT is not set 81# CONFIG_AUDIT is not set
@@ -93,8 +98,12 @@ CONFIG_SYSFS_DEPRECATED_V2=y
93# CONFIG_NAMESPACES is not set 98# CONFIG_NAMESPACES is not set
94CONFIG_BLK_DEV_INITRD=y 99CONFIG_BLK_DEV_INITRD=y
95CONFIG_INITRAMFS_SOURCE="" 100CONFIG_INITRAMFS_SOURCE=""
101CONFIG_RD_GZIP=y
102# CONFIG_RD_BZIP2 is not set
103# CONFIG_RD_LZMA is not set
96# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 104# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
97CONFIG_SYSCTL=y 105CONFIG_SYSCTL=y
106CONFIG_ANON_INODES=y
98CONFIG_EMBEDDED=y 107CONFIG_EMBEDDED=y
99CONFIG_SYSCTL_SYSCALL=y 108CONFIG_SYSCTL_SYSCALL=y
100CONFIG_KALLSYMS=y 109CONFIG_KALLSYMS=y
@@ -104,23 +113,30 @@ CONFIG_HOTPLUG=y
104CONFIG_PRINTK=y 113CONFIG_PRINTK=y
105CONFIG_BUG=y 114CONFIG_BUG=y
106CONFIG_ELF_CORE=y 115CONFIG_ELF_CORE=y
107CONFIG_COMPAT_BRK=y
108CONFIG_BASE_FULL=y 116CONFIG_BASE_FULL=y
109CONFIG_FUTEX=y 117CONFIG_FUTEX=y
110CONFIG_ANON_INODES=y
111CONFIG_EPOLL=y 118CONFIG_EPOLL=y
112CONFIG_SIGNALFD=y 119CONFIG_SIGNALFD=y
113CONFIG_TIMERFD=y 120CONFIG_TIMERFD=y
114CONFIG_EVENTFD=y 121CONFIG_EVENTFD=y
115CONFIG_SHMEM=y 122CONFIG_SHMEM=y
116CONFIG_AIO=y 123CONFIG_AIO=y
124CONFIG_HAVE_PERF_COUNTERS=y
125
126#
127# Performance Counters
128#
129# CONFIG_PERF_COUNTERS is not set
117CONFIG_VM_EVENT_COUNTERS=y 130CONFIG_VM_EVENT_COUNTERS=y
118CONFIG_PCI_QUIRKS=y 131CONFIG_PCI_QUIRKS=y
119CONFIG_SLUB_DEBUG=y 132CONFIG_SLUB_DEBUG=y
133# CONFIG_STRIP_ASM_SYMS is not set
134CONFIG_COMPAT_BRK=y
120# CONFIG_SLAB is not set 135# CONFIG_SLAB is not set
121CONFIG_SLUB=y 136CONFIG_SLUB=y
122# CONFIG_SLOB is not set 137# CONFIG_SLOB is not set
123# CONFIG_PROFILING is not set 138# CONFIG_PROFILING is not set
139# CONFIG_MARKERS is not set
124CONFIG_HAVE_OPROFILE=y 140CONFIG_HAVE_OPROFILE=y
125# CONFIG_KPROBES is not set 141# CONFIG_KPROBES is not set
126CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y 142CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
@@ -128,6 +144,12 @@ CONFIG_HAVE_IOREMAP_PROT=y
128CONFIG_HAVE_KPROBES=y 144CONFIG_HAVE_KPROBES=y
129CONFIG_HAVE_KRETPROBES=y 145CONFIG_HAVE_KRETPROBES=y
130CONFIG_HAVE_ARCH_TRACEHOOK=y 146CONFIG_HAVE_ARCH_TRACEHOOK=y
147
148#
149# GCOV-based kernel profiling
150#
151# CONFIG_GCOV_KERNEL is not set
152# CONFIG_SLOW_WORK is not set
131# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 153# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
132CONFIG_SLABINFO=y 154CONFIG_SLABINFO=y
133CONFIG_RT_MUTEXES=y 155CONFIG_RT_MUTEXES=y
@@ -139,8 +161,7 @@ CONFIG_MODULE_UNLOAD=y
139# CONFIG_MODVERSIONS is not set 161# CONFIG_MODVERSIONS is not set
140# CONFIG_MODULE_SRCVERSION_ALL is not set 162# CONFIG_MODULE_SRCVERSION_ALL is not set
141CONFIG_BLOCK=y 163CONFIG_BLOCK=y
142CONFIG_LBD=y 164CONFIG_LBDAF=y
143# CONFIG_BLK_DEV_IO_TRACE is not set
144# CONFIG_BLK_DEV_BSG is not set 165# CONFIG_BLK_DEV_BSG is not set
145# CONFIG_BLK_DEV_INTEGRITY is not set 166# CONFIG_BLK_DEV_INTEGRITY is not set
146 167
@@ -176,6 +197,7 @@ CONFIG_PPC4xx_PCI_EXPRESS=y
176# CONFIG_ARCHES is not set 197# CONFIG_ARCHES is not set
177CONFIG_CANYONLANDS=y 198CONFIG_CANYONLANDS=y
178# CONFIG_GLACIER is not set 199# CONFIG_GLACIER is not set
200# CONFIG_REDWOOD is not set
179# CONFIG_YOSEMITE is not set 201# CONFIG_YOSEMITE is not set
180# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set 202# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set
181CONFIG_PPC44x_SIMPLE=y 203CONFIG_PPC44x_SIMPLE=y
@@ -218,6 +240,7 @@ CONFIG_BINFMT_ELF=y
218# CONFIG_BINFMT_MISC is not set 240# CONFIG_BINFMT_MISC is not set
219# CONFIG_MATH_EMULATION is not set 241# CONFIG_MATH_EMULATION is not set
220# CONFIG_IOMMU_HELPER is not set 242# CONFIG_IOMMU_HELPER is not set
243# CONFIG_SWIOTLB is not set
221CONFIG_PPC_NEED_DMA_SYNC_OPS=y 244CONFIG_PPC_NEED_DMA_SYNC_OPS=y
222CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 245CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
223CONFIG_ARCH_HAS_WALK_MEMORY=y 246CONFIG_ARCH_HAS_WALK_MEMORY=y
@@ -237,10 +260,14 @@ CONFIG_PHYS_ADDR_T_64BIT=y
237CONFIG_ZONE_DMA_FLAG=1 260CONFIG_ZONE_DMA_FLAG=1
238CONFIG_BOUNCE=y 261CONFIG_BOUNCE=y
239CONFIG_VIRT_TO_BUS=y 262CONFIG_VIRT_TO_BUS=y
240CONFIG_UNEVICTABLE_LRU=y 263CONFIG_HAVE_MLOCK=y
264CONFIG_HAVE_MLOCKED_PAGE_BIT=y
265CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
266CONFIG_STDBINUTILS=y
241CONFIG_PPC_4K_PAGES=y 267CONFIG_PPC_4K_PAGES=y
242# CONFIG_PPC_16K_PAGES is not set 268# CONFIG_PPC_16K_PAGES is not set
243# CONFIG_PPC_64K_PAGES is not set 269# CONFIG_PPC_64K_PAGES is not set
270# CONFIG_PPC_256K_PAGES is not set
244CONFIG_FORCE_MAX_ZONEORDER=11 271CONFIG_FORCE_MAX_ZONEORDER=11
245CONFIG_PROC_DEVICETREE=y 272CONFIG_PROC_DEVICETREE=y
246CONFIG_CMDLINE_BOOL=y 273CONFIG_CMDLINE_BOOL=y
@@ -265,6 +292,7 @@ CONFIG_ARCH_SUPPORTS_MSI=y
265# CONFIG_PCI_LEGACY is not set 292# CONFIG_PCI_LEGACY is not set
266# CONFIG_PCI_DEBUG is not set 293# CONFIG_PCI_DEBUG is not set
267# CONFIG_PCI_STUB is not set 294# CONFIG_PCI_STUB is not set
295# CONFIG_PCI_IOV is not set
268# CONFIG_PCCARD is not set 296# CONFIG_PCCARD is not set
269# CONFIG_HOTPLUG_PCI is not set 297# CONFIG_HOTPLUG_PCI is not set
270# CONFIG_HAS_RAPIDIO is not set 298# CONFIG_HAS_RAPIDIO is not set
@@ -282,14 +310,12 @@ CONFIG_PAGE_OFFSET=0xc0000000
282CONFIG_KERNEL_START=0xc0000000 310CONFIG_KERNEL_START=0xc0000000
283CONFIG_PHYSICAL_START=0x00000000 311CONFIG_PHYSICAL_START=0x00000000
284CONFIG_TASK_SIZE=0xc0000000 312CONFIG_TASK_SIZE=0xc0000000
285CONFIG_CONSISTENT_START=0xff100000
286CONFIG_CONSISTENT_SIZE=0x00200000 313CONFIG_CONSISTENT_SIZE=0x00200000
287CONFIG_NET=y 314CONFIG_NET=y
288 315
289# 316#
290# Networking options 317# Networking options
291# 318#
292CONFIG_COMPAT_NET_DEV_OPS=y
293CONFIG_PACKET=y 319CONFIG_PACKET=y
294# CONFIG_PACKET_MMAP is not set 320# CONFIG_PACKET_MMAP is not set
295CONFIG_UNIX=y 321CONFIG_UNIX=y
@@ -339,6 +365,8 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
339# CONFIG_LAPB is not set 365# CONFIG_LAPB is not set
340# CONFIG_ECONET is not set 366# CONFIG_ECONET is not set
341# CONFIG_WAN_ROUTER is not set 367# CONFIG_WAN_ROUTER is not set
368# CONFIG_PHONET is not set
369# CONFIG_IEEE802154 is not set
342# CONFIG_NET_SCHED is not set 370# CONFIG_NET_SCHED is not set
343# CONFIG_DCB is not set 371# CONFIG_DCB is not set
344 372
@@ -351,7 +379,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
351# CONFIG_IRDA is not set 379# CONFIG_IRDA is not set
352# CONFIG_BT is not set 380# CONFIG_BT is not set
353# CONFIG_AF_RXRPC is not set 381# CONFIG_AF_RXRPC is not set
354# CONFIG_PHONET is not set
355# CONFIG_WIRELESS is not set 382# CONFIG_WIRELESS is not set
356# CONFIG_WIMAX is not set 383# CONFIG_WIMAX is not set
357# CONFIG_RFKILL is not set 384# CONFIG_RFKILL is not set
@@ -375,7 +402,101 @@ CONFIG_EXTRA_FIRMWARE=""
375# CONFIG_SYS_HYPERVISOR is not set 402# CONFIG_SYS_HYPERVISOR is not set
376CONFIG_CONNECTOR=y 403CONFIG_CONNECTOR=y
377CONFIG_PROC_EVENTS=y 404CONFIG_PROC_EVENTS=y
378# CONFIG_MTD is not set 405CONFIG_MTD=y
406# CONFIG_MTD_DEBUG is not set
407# CONFIG_MTD_CONCAT is not set
408CONFIG_MTD_PARTITIONS=y
409# CONFIG_MTD_TESTS is not set
410# CONFIG_MTD_REDBOOT_PARTS is not set
411CONFIG_MTD_CMDLINE_PARTS=y
412CONFIG_MTD_OF_PARTS=y
413# CONFIG_MTD_AR7_PARTS is not set
414
415#
416# User Modules And Translation Layers
417#
418CONFIG_MTD_CHAR=y
419CONFIG_MTD_BLKDEVS=y
420CONFIG_MTD_BLOCK=y
421# CONFIG_FTL is not set
422# CONFIG_NFTL is not set
423# CONFIG_INFTL is not set
424# CONFIG_RFD_FTL is not set
425# CONFIG_SSFDC is not set
426# CONFIG_MTD_OOPS is not set
427
428#
429# RAM/ROM/Flash chip drivers
430#
431CONFIG_MTD_CFI=y
432# CONFIG_MTD_JEDECPROBE is not set
433CONFIG_MTD_GEN_PROBE=y
434# CONFIG_MTD_CFI_ADV_OPTIONS is not set
435CONFIG_MTD_MAP_BANK_WIDTH_1=y
436CONFIG_MTD_MAP_BANK_WIDTH_2=y
437CONFIG_MTD_MAP_BANK_WIDTH_4=y
438# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
439# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
440# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
441CONFIG_MTD_CFI_I1=y
442CONFIG_MTD_CFI_I2=y
443# CONFIG_MTD_CFI_I4 is not set
444# CONFIG_MTD_CFI_I8 is not set
445# CONFIG_MTD_CFI_INTELEXT is not set
446CONFIG_MTD_CFI_AMDSTD=y
447# CONFIG_MTD_CFI_STAA is not set
448CONFIG_MTD_CFI_UTIL=y
449# CONFIG_MTD_RAM is not set
450# CONFIG_MTD_ROM is not set
451# CONFIG_MTD_ABSENT is not set
452
453#
454# Mapping drivers for chip access
455#
456# CONFIG_MTD_COMPLEX_MAPPINGS is not set
457# CONFIG_MTD_PHYSMAP is not set
458CONFIG_MTD_PHYSMAP_OF=y
459# CONFIG_MTD_INTEL_VR_NOR is not set
460# CONFIG_MTD_PLATRAM is not set
461
462#
463# Self-contained MTD device drivers
464#
465# CONFIG_MTD_PMC551 is not set
466# CONFIG_MTD_SLRAM is not set
467# CONFIG_MTD_PHRAM is not set
468# CONFIG_MTD_MTDRAM is not set
469# CONFIG_MTD_BLOCK2MTD is not set
470
471#
472# Disk-On-Chip Device Drivers
473#
474# CONFIG_MTD_DOC2000 is not set
475# CONFIG_MTD_DOC2001 is not set
476# CONFIG_MTD_DOC2001PLUS is not set
477CONFIG_MTD_NAND=y
478# CONFIG_MTD_NAND_VERIFY_WRITE is not set
479CONFIG_MTD_NAND_ECC_SMC=y
480# CONFIG_MTD_NAND_MUSEUM_IDS is not set
481CONFIG_MTD_NAND_IDS=y
482CONFIG_MTD_NAND_NDFC=y
483# CONFIG_MTD_NAND_DISKONCHIP is not set
484# CONFIG_MTD_NAND_CAFE 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_NAND_FSL_ELBC is not set
489# CONFIG_MTD_ONENAND is not set
490
491#
492# LPDDR flash memory drivers
493#
494# CONFIG_MTD_LPDDR is not set
495
496#
497# UBI - Unsorted block images
498#
499# CONFIG_MTD_UBI is not set
379CONFIG_OF_DEVICE=y 500CONFIG_OF_DEVICE=y
380CONFIG_OF_I2C=y 501CONFIG_OF_I2C=y
381# CONFIG_PARPORT is not set 502# CONFIG_PARPORT is not set
@@ -418,7 +539,11 @@ CONFIG_HAVE_IDE=y
418# 539#
419 540
420# 541#
421# Enable only one of the two stacks, unless you know what you are doing 542# You can enable one or both FireWire driver stacks.
543#
544
545#
546# See the help texts for more information.
422# 547#
423# CONFIG_FIREWIRE is not set 548# CONFIG_FIREWIRE is not set
424# CONFIG_IEEE1394 is not set 549# CONFIG_IEEE1394 is not set
@@ -439,6 +564,8 @@ CONFIG_NET_ETHERNET=y
439# CONFIG_SUNGEM is not set 564# CONFIG_SUNGEM is not set
440# CONFIG_CASSINI is not set 565# CONFIG_CASSINI is not set
441# CONFIG_NET_VENDOR_3COM is not set 566# CONFIG_NET_VENDOR_3COM is not set
567# CONFIG_ETHOC is not set
568# CONFIG_DNET is not set
442# CONFIG_NET_TULIP is not set 569# CONFIG_NET_TULIP is not set
443# CONFIG_HP100 is not set 570# CONFIG_HP100 is not set
444CONFIG_IBM_NEW_EMAC=y 571CONFIG_IBM_NEW_EMAC=y
@@ -457,6 +584,7 @@ CONFIG_IBM_NEW_EMAC_EMAC4=y
457# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 584# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
458# CONFIG_NET_PCI is not set 585# CONFIG_NET_PCI is not set
459# CONFIG_B44 is not set 586# CONFIG_B44 is not set
587# CONFIG_KS8842 is not set
460# CONFIG_ATL2 is not set 588# CONFIG_ATL2 is not set
461# CONFIG_NETDEV_1000 is not set 589# CONFIG_NETDEV_1000 is not set
462# CONFIG_NETDEV_10000 is not set 590# CONFIG_NETDEV_10000 is not set
@@ -467,7 +595,6 @@ CONFIG_IBM_NEW_EMAC_EMAC4=y
467# 595#
468# CONFIG_WLAN_PRE80211 is not set 596# CONFIG_WLAN_PRE80211 is not set
469# CONFIG_WLAN_80211 is not set 597# CONFIG_WLAN_80211 is not set
470# CONFIG_IWLWIFI_LEDS is not set
471 598
472# 599#
473# Enable WiMAX (Networking options) to see the WiMAX drivers 600# Enable WiMAX (Networking options) to see the WiMAX drivers
@@ -542,7 +669,6 @@ CONFIG_LEGACY_PTY_COUNT=256
542# CONFIG_IPMI_HANDLER is not set 669# CONFIG_IPMI_HANDLER is not set
543# CONFIG_HW_RANDOM is not set 670# CONFIG_HW_RANDOM is not set
544# CONFIG_NVRAM is not set 671# CONFIG_NVRAM is not set
545# CONFIG_GEN_RTC is not set
546# CONFIG_R3964 is not set 672# CONFIG_R3964 is not set
547# CONFIG_APPLICOM is not set 673# CONFIG_APPLICOM is not set
548# CONFIG_RAW_DRIVER is not set 674# CONFIG_RAW_DRIVER is not set
@@ -608,14 +734,17 @@ CONFIG_I2C_IBM_IIC=y
608# CONFIG_SENSORS_PCF8574 is not set 734# CONFIG_SENSORS_PCF8574 is not set
609# CONFIG_PCF8575 is not set 735# CONFIG_PCF8575 is not set
610# CONFIG_SENSORS_PCA9539 is not set 736# CONFIG_SENSORS_PCA9539 is not set
611# CONFIG_SENSORS_PCF8591 is not set
612# CONFIG_SENSORS_MAX6875 is not set
613# CONFIG_SENSORS_TSL2550 is not set 737# CONFIG_SENSORS_TSL2550 is not set
614# CONFIG_I2C_DEBUG_CORE is not set 738# CONFIG_I2C_DEBUG_CORE is not set
615# CONFIG_I2C_DEBUG_ALGO is not set 739# CONFIG_I2C_DEBUG_ALGO is not set
616# CONFIG_I2C_DEBUG_BUS is not set 740# CONFIG_I2C_DEBUG_BUS is not set
617# CONFIG_I2C_DEBUG_CHIP is not set 741# CONFIG_I2C_DEBUG_CHIP is not set
618# CONFIG_SPI is not set 742# CONFIG_SPI is not set
743
744#
745# PPS support
746#
747# CONFIG_PPS is not set
619CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 748CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
620# CONFIG_GPIOLIB is not set 749# CONFIG_GPIOLIB is not set
621# CONFIG_W1 is not set 750# CONFIG_W1 is not set
@@ -640,6 +769,7 @@ CONFIG_SENSORS_AD7414=y
640# CONFIG_SENSORS_F71805F is not set 769# CONFIG_SENSORS_F71805F is not set
641# CONFIG_SENSORS_F71882FG is not set 770# CONFIG_SENSORS_F71882FG is not set
642# CONFIG_SENSORS_F75375S is not set 771# CONFIG_SENSORS_F75375S is not set
772# CONFIG_SENSORS_G760A is not set
643# CONFIG_SENSORS_GL518SM is not set 773# CONFIG_SENSORS_GL518SM is not set
644# CONFIG_SENSORS_GL520SM is not set 774# CONFIG_SENSORS_GL520SM is not set
645# CONFIG_SENSORS_IT87 is not set 775# CONFIG_SENSORS_IT87 is not set
@@ -654,11 +784,14 @@ CONFIG_SENSORS_AD7414=y
654# CONFIG_SENSORS_LM90 is not set 784# CONFIG_SENSORS_LM90 is not set
655# CONFIG_SENSORS_LM92 is not set 785# CONFIG_SENSORS_LM92 is not set
656# CONFIG_SENSORS_LM93 is not set 786# CONFIG_SENSORS_LM93 is not set
787# CONFIG_SENSORS_LTC4215 is not set
657# CONFIG_SENSORS_LTC4245 is not set 788# CONFIG_SENSORS_LTC4245 is not set
789# CONFIG_SENSORS_LM95241 is not set
658# CONFIG_SENSORS_MAX1619 is not set 790# CONFIG_SENSORS_MAX1619 is not set
659# CONFIG_SENSORS_MAX6650 is not set 791# CONFIG_SENSORS_MAX6650 is not set
660# CONFIG_SENSORS_PC87360 is not set 792# CONFIG_SENSORS_PC87360 is not set
661# CONFIG_SENSORS_PC87427 is not set 793# CONFIG_SENSORS_PC87427 is not set
794# CONFIG_SENSORS_PCF8591 is not set
662# CONFIG_SENSORS_SIS5595 is not set 795# CONFIG_SENSORS_SIS5595 is not set
663# CONFIG_SENSORS_DME1737 is not set 796# CONFIG_SENSORS_DME1737 is not set
664# CONFIG_SENSORS_SMSC47M1 is not set 797# CONFIG_SENSORS_SMSC47M1 is not set
@@ -666,6 +799,7 @@ CONFIG_SENSORS_AD7414=y
666# CONFIG_SENSORS_SMSC47B397 is not set 799# CONFIG_SENSORS_SMSC47B397 is not set
667# CONFIG_SENSORS_ADS7828 is not set 800# CONFIG_SENSORS_ADS7828 is not set
668# CONFIG_SENSORS_THMC50 is not set 801# CONFIG_SENSORS_THMC50 is not set
802# CONFIG_SENSORS_TMP401 is not set
669# CONFIG_SENSORS_VIA686A is not set 803# CONFIG_SENSORS_VIA686A is not set
670# CONFIG_SENSORS_VT1211 is not set 804# CONFIG_SENSORS_VT1211 is not set
671# CONFIG_SENSORS_VT8231 is not set 805# CONFIG_SENSORS_VT8231 is not set
@@ -700,24 +834,9 @@ CONFIG_SSB_POSSIBLE=y
700# CONFIG_MFD_WM8400 is not set 834# CONFIG_MFD_WM8400 is not set
701# CONFIG_MFD_WM8350_I2C is not set 835# CONFIG_MFD_WM8350_I2C is not set
702# CONFIG_MFD_PCF50633 is not set 836# CONFIG_MFD_PCF50633 is not set
837# CONFIG_AB3100_CORE is not set
703# CONFIG_REGULATOR is not set 838# CONFIG_REGULATOR is not set
704 839# CONFIG_MEDIA_SUPPORT is not set
705#
706# Multimedia devices
707#
708
709#
710# Multimedia core support
711#
712# CONFIG_VIDEO_DEV is not set
713# CONFIG_DVB_CORE is not set
714# CONFIG_VIDEO_MEDIA is not set
715
716#
717# Multimedia drivers
718#
719# CONFIG_DAB is not set
720# CONFIG_USB_DABUSB is not set
721 840
722# 841#
723# Graphics support 842# Graphics support
@@ -759,6 +878,7 @@ CONFIG_USB_MON=y
759# USB Host Controller Drivers 878# USB Host Controller Drivers
760# 879#
761# CONFIG_USB_C67X00_HCD is not set 880# CONFIG_USB_C67X00_HCD is not set
881# CONFIG_USB_XHCI_HCD is not set
762CONFIG_USB_EHCI_HCD=m 882CONFIG_USB_EHCI_HCD=m
763# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 883# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
764# CONFIG_USB_EHCI_TT_NEWSCHED is not set 884# CONFIG_USB_EHCI_TT_NEWSCHED is not set
@@ -767,9 +887,9 @@ CONFIG_USB_EHCI_HCD_PPC_OF=y
767# CONFIG_USB_ISP116X_HCD is not set 887# CONFIG_USB_ISP116X_HCD is not set
768# CONFIG_USB_ISP1760_HCD is not set 888# CONFIG_USB_ISP1760_HCD is not set
769CONFIG_USB_OHCI_HCD=y 889CONFIG_USB_OHCI_HCD=y
770CONFIG_USB_OHCI_HCD_PPC_OF=y
771CONFIG_USB_OHCI_HCD_PPC_OF_BE=y 890CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
772CONFIG_USB_OHCI_HCD_PPC_OF_LE=y 891CONFIG_USB_OHCI_HCD_PPC_OF_LE=y
892CONFIG_USB_OHCI_HCD_PPC_OF=y
773CONFIG_USB_OHCI_HCD_PCI=y 893CONFIG_USB_OHCI_HCD_PCI=y
774CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y 894CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
775CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y 895CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
@@ -789,11 +909,11 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
789# CONFIG_USB_TMC is not set 909# CONFIG_USB_TMC is not set
790 910
791# 911#
792# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; 912# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
793# 913#
794 914
795# 915#
796# see USB_STORAGE Help for more information 916# also be needed; see USB_STORAGE Help for more info
797# 917#
798CONFIG_USB_LIBUSUAL=y 918CONFIG_USB_LIBUSUAL=y
799 919
@@ -821,7 +941,6 @@ CONFIG_USB_LIBUSUAL=y
821# CONFIG_USB_LED is not set 941# CONFIG_USB_LED is not set
822# CONFIG_USB_CYPRESS_CY7C63 is not set 942# CONFIG_USB_CYPRESS_CY7C63 is not set
823# CONFIG_USB_CYTHERM is not set 943# CONFIG_USB_CYTHERM is not set
824# CONFIG_USB_PHIDGET is not set
825# CONFIG_USB_IDMOUSE is not set 944# CONFIG_USB_IDMOUSE is not set
826# CONFIG_USB_FTDI_ELAN is not set 945# CONFIG_USB_FTDI_ELAN is not set
827# CONFIG_USB_APPLEDISPLAY is not set 946# CONFIG_USB_APPLEDISPLAY is not set
@@ -837,6 +956,7 @@ CONFIG_USB_LIBUSUAL=y
837# 956#
838# OTG and related infrastructure 957# OTG and related infrastructure
839# 958#
959# CONFIG_NOP_USB_XCEIV is not set
840# CONFIG_UWB is not set 960# CONFIG_UWB is not set
841# CONFIG_MMC is not set 961# CONFIG_MMC is not set
842# CONFIG_MEMSTICK is not set 962# CONFIG_MEMSTICK is not set
@@ -844,9 +964,70 @@ CONFIG_USB_LIBUSUAL=y
844# CONFIG_ACCESSIBILITY is not set 964# CONFIG_ACCESSIBILITY is not set
845# CONFIG_INFINIBAND is not set 965# CONFIG_INFINIBAND is not set
846# CONFIG_EDAC is not set 966# CONFIG_EDAC is not set
847# CONFIG_RTC_CLASS is not set 967CONFIG_RTC_LIB=y
968CONFIG_RTC_CLASS=y
969CONFIG_RTC_HCTOSYS=y
970CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
971# CONFIG_RTC_DEBUG is not set
972
973#
974# RTC interfaces
975#
976CONFIG_RTC_INTF_SYSFS=y
977CONFIG_RTC_INTF_PROC=y
978CONFIG_RTC_INTF_DEV=y
979# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
980# CONFIG_RTC_DRV_TEST is not set
981
982#
983# I2C RTC drivers
984#
985# CONFIG_RTC_DRV_DS1307 is not set
986# CONFIG_RTC_DRV_DS1374 is not set
987# CONFIG_RTC_DRV_DS1672 is not set
988# CONFIG_RTC_DRV_MAX6900 is not set
989# CONFIG_RTC_DRV_RS5C372 is not set
990# CONFIG_RTC_DRV_ISL1208 is not set
991# CONFIG_RTC_DRV_X1205 is not set
992# CONFIG_RTC_DRV_PCF8563 is not set
993# CONFIG_RTC_DRV_PCF8583 is not set
994CONFIG_RTC_DRV_M41T80=y
995# CONFIG_RTC_DRV_M41T80_WDT is not set
996# CONFIG_RTC_DRV_S35390A is not set
997# CONFIG_RTC_DRV_FM3130 is not set
998# CONFIG_RTC_DRV_RX8581 is not set
999# CONFIG_RTC_DRV_RX8025 is not set
1000
1001#
1002# SPI RTC drivers
1003#
1004
1005#
1006# Platform RTC drivers
1007#
1008# CONFIG_RTC_DRV_CMOS is not set
1009# CONFIG_RTC_DRV_DS1286 is not set
1010# CONFIG_RTC_DRV_DS1511 is not set
1011# CONFIG_RTC_DRV_DS1553 is not set
1012# CONFIG_RTC_DRV_DS1742 is not set
1013# CONFIG_RTC_DRV_STK17TA8 is not set
1014# CONFIG_RTC_DRV_M48T86 is not set
1015# CONFIG_RTC_DRV_M48T35 is not set
1016# CONFIG_RTC_DRV_M48T59 is not set
1017# CONFIG_RTC_DRV_BQ4802 is not set
1018# CONFIG_RTC_DRV_V3020 is not set
1019
1020#
1021# on-CPU RTC drivers
1022#
1023# CONFIG_RTC_DRV_GENERIC is not set
848# CONFIG_DMADEVICES is not set 1024# CONFIG_DMADEVICES is not set
1025# CONFIG_AUXDISPLAY is not set
849# CONFIG_UIO is not set 1026# CONFIG_UIO is not set
1027
1028#
1029# TI VLYNQ
1030#
850# CONFIG_STAGING is not set 1031# CONFIG_STAGING is not set
851 1032
852# 1033#
@@ -860,11 +1041,12 @@ CONFIG_EXT2_FS=y
860# CONFIG_REISERFS_FS is not set 1041# CONFIG_REISERFS_FS is not set
861# CONFIG_JFS_FS is not set 1042# CONFIG_JFS_FS is not set
862# CONFIG_FS_POSIX_ACL is not set 1043# CONFIG_FS_POSIX_ACL is not set
863CONFIG_FILE_LOCKING=y
864# CONFIG_XFS_FS is not set 1044# CONFIG_XFS_FS is not set
865# CONFIG_GFS2_FS is not set 1045# CONFIG_GFS2_FS is not set
866# CONFIG_OCFS2_FS is not set 1046# CONFIG_OCFS2_FS is not set
867# CONFIG_BTRFS_FS is not set 1047# CONFIG_BTRFS_FS is not set
1048CONFIG_FILE_LOCKING=y
1049CONFIG_FSNOTIFY=y
868CONFIG_DNOTIFY=y 1050CONFIG_DNOTIFY=y
869CONFIG_INOTIFY=y 1051CONFIG_INOTIFY=y
870CONFIG_INOTIFY_USER=y 1052CONFIG_INOTIFY_USER=y
@@ -874,6 +1056,11 @@ CONFIG_INOTIFY_USER=y
874# CONFIG_FUSE_FS is not set 1056# CONFIG_FUSE_FS is not set
875 1057
876# 1058#
1059# Caches
1060#
1061# CONFIG_FSCACHE is not set
1062
1063#
877# CD-ROM/DVD Filesystems 1064# CD-ROM/DVD Filesystems
878# 1065#
879# CONFIG_ISO9660_FS is not set 1066# CONFIG_ISO9660_FS is not set
@@ -906,6 +1093,7 @@ CONFIG_MISC_FILESYSTEMS=y
906# CONFIG_BEFS_FS is not set 1093# CONFIG_BEFS_FS is not set
907# CONFIG_BFS_FS is not set 1094# CONFIG_BFS_FS is not set
908# CONFIG_EFS_FS is not set 1095# CONFIG_EFS_FS is not set
1096# CONFIG_JFFS2_FS is not set
909CONFIG_CRAMFS=y 1097CONFIG_CRAMFS=y
910# CONFIG_SQUASHFS is not set 1098# CONFIG_SQUASHFS is not set
911# CONFIG_VXFS_FS is not set 1099# CONFIG_VXFS_FS is not set
@@ -916,6 +1104,7 @@ CONFIG_CRAMFS=y
916# CONFIG_ROMFS_FS is not set 1104# CONFIG_ROMFS_FS is not set
917# CONFIG_SYSV_FS is not set 1105# CONFIG_SYSV_FS is not set
918# CONFIG_UFS_FS is not set 1106# CONFIG_UFS_FS is not set
1107# CONFIG_NILFS2_FS is not set
919CONFIG_NETWORK_FILESYSTEMS=y 1108CONFIG_NETWORK_FILESYSTEMS=y
920CONFIG_NFS_FS=y 1109CONFIG_NFS_FS=y
921CONFIG_NFS_V3=y 1110CONFIG_NFS_V3=y
@@ -927,7 +1116,6 @@ CONFIG_LOCKD=y
927CONFIG_LOCKD_V4=y 1116CONFIG_LOCKD_V4=y
928CONFIG_NFS_COMMON=y 1117CONFIG_NFS_COMMON=y
929CONFIG_SUNRPC=y 1118CONFIG_SUNRPC=y
930# CONFIG_SUNRPC_REGISTER_V4 is not set
931# CONFIG_RPCSEC_GSS_KRB5 is not set 1119# CONFIG_RPCSEC_GSS_KRB5 is not set
932# CONFIG_RPCSEC_GSS_SPKM3 is not set 1120# CONFIG_RPCSEC_GSS_SPKM3 is not set
933# CONFIG_SMB_FS is not set 1121# CONFIG_SMB_FS is not set
@@ -941,8 +1129,48 @@ CONFIG_SUNRPC=y
941# 1129#
942# CONFIG_PARTITION_ADVANCED is not set 1130# CONFIG_PARTITION_ADVANCED is not set
943CONFIG_MSDOS_PARTITION=y 1131CONFIG_MSDOS_PARTITION=y
944# CONFIG_NLS is not set 1132CONFIG_NLS=y
1133CONFIG_NLS_DEFAULT="iso8859-1"
1134# CONFIG_NLS_CODEPAGE_437 is not set
1135# CONFIG_NLS_CODEPAGE_737 is not set
1136# CONFIG_NLS_CODEPAGE_775 is not set
1137# CONFIG_NLS_CODEPAGE_850 is not set
1138# CONFIG_NLS_CODEPAGE_852 is not set
1139# CONFIG_NLS_CODEPAGE_855 is not set
1140# CONFIG_NLS_CODEPAGE_857 is not set
1141# CONFIG_NLS_CODEPAGE_860 is not set
1142# CONFIG_NLS_CODEPAGE_861 is not set
1143# CONFIG_NLS_CODEPAGE_862 is not set
1144# CONFIG_NLS_CODEPAGE_863 is not set
1145# CONFIG_NLS_CODEPAGE_864 is not set
1146# CONFIG_NLS_CODEPAGE_865 is not set
1147# CONFIG_NLS_CODEPAGE_866 is not set
1148# CONFIG_NLS_CODEPAGE_869 is not set
1149# CONFIG_NLS_CODEPAGE_936 is not set
1150# CONFIG_NLS_CODEPAGE_950 is not set
1151# CONFIG_NLS_CODEPAGE_932 is not set
1152# CONFIG_NLS_CODEPAGE_949 is not set
1153# CONFIG_NLS_CODEPAGE_874 is not set
1154# CONFIG_NLS_ISO8859_8 is not set
1155# CONFIG_NLS_CODEPAGE_1250 is not set
1156# CONFIG_NLS_CODEPAGE_1251 is not set
1157# CONFIG_NLS_ASCII is not set
1158# CONFIG_NLS_ISO8859_1 is not set
1159# CONFIG_NLS_ISO8859_2 is not set
1160# CONFIG_NLS_ISO8859_3 is not set
1161# CONFIG_NLS_ISO8859_4 is not set
1162# CONFIG_NLS_ISO8859_5 is not set
1163# CONFIG_NLS_ISO8859_6 is not set
1164# CONFIG_NLS_ISO8859_7 is not set
1165# CONFIG_NLS_ISO8859_9 is not set
1166# CONFIG_NLS_ISO8859_13 is not set
1167# CONFIG_NLS_ISO8859_14 is not set
1168# CONFIG_NLS_ISO8859_15 is not set
1169# CONFIG_NLS_KOI8_R is not set
1170# CONFIG_NLS_KOI8_U is not set
1171# CONFIG_NLS_UTF8 is not set
945# CONFIG_DLM is not set 1172# CONFIG_DLM is not set
1173# CONFIG_BINARY_PRINTF is not set
946 1174
947# 1175#
948# Library routines 1176# Library routines
@@ -957,11 +1185,13 @@ CONFIG_CRC32=y
957# CONFIG_CRC7 is not set 1185# CONFIG_CRC7 is not set
958# CONFIG_LIBCRC32C is not set 1186# CONFIG_LIBCRC32C is not set
959CONFIG_ZLIB_INFLATE=y 1187CONFIG_ZLIB_INFLATE=y
960CONFIG_PLIST=y 1188CONFIG_DECOMPRESS_GZIP=y
961CONFIG_HAS_IOMEM=y 1189CONFIG_HAS_IOMEM=y
962CONFIG_HAS_IOPORT=y 1190CONFIG_HAS_IOPORT=y
963CONFIG_HAS_DMA=y 1191CONFIG_HAS_DMA=y
964CONFIG_HAVE_LMB=y 1192CONFIG_HAVE_LMB=y
1193CONFIG_NLATTR=y
1194CONFIG_GENERIC_ATOMIC64=y
965 1195
966# 1196#
967# Kernel hacking 1197# Kernel hacking
@@ -979,6 +1209,9 @@ CONFIG_DEBUG_KERNEL=y
979CONFIG_DETECT_SOFTLOCKUP=y 1209CONFIG_DETECT_SOFTLOCKUP=y
980# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set 1210# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
981CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 1211CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1212CONFIG_DETECT_HUNG_TASK=y
1213# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1214CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
982CONFIG_SCHED_DEBUG=y 1215CONFIG_SCHED_DEBUG=y
983# CONFIG_SCHEDSTATS is not set 1216# CONFIG_SCHEDSTATS is not set
984# CONFIG_TIMER_STATS is not set 1217# CONFIG_TIMER_STATS is not set
@@ -989,6 +1222,9 @@ CONFIG_SCHED_DEBUG=y
989# CONFIG_RT_MUTEX_TESTER is not set 1222# CONFIG_RT_MUTEX_TESTER is not set
990# CONFIG_DEBUG_SPINLOCK is not set 1223# CONFIG_DEBUG_SPINLOCK is not set
991# CONFIG_DEBUG_MUTEXES is not set 1224# CONFIG_DEBUG_MUTEXES is not set
1225# CONFIG_DEBUG_LOCK_ALLOC is not set
1226# CONFIG_PROVE_LOCKING is not set
1227# CONFIG_LOCK_STAT is not set
992# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1228# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
993# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1229# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
994# CONFIG_DEBUG_KOBJECT is not set 1230# CONFIG_DEBUG_KOBJECT is not set
@@ -1000,7 +1236,6 @@ CONFIG_SCHED_DEBUG=y
1000# CONFIG_DEBUG_LIST is not set 1236# CONFIG_DEBUG_LIST is not set
1001# CONFIG_DEBUG_SG is not set 1237# CONFIG_DEBUG_SG is not set
1002# CONFIG_DEBUG_NOTIFIERS is not set 1238# CONFIG_DEBUG_NOTIFIERS is not set
1003# CONFIG_BOOT_PRINTK_DELAY is not set
1004# CONFIG_RCU_TORTURE_TEST is not set 1239# CONFIG_RCU_TORTURE_TEST is not set
1005# CONFIG_RCU_CPU_STALL_DETECTOR is not set 1240# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1006# CONFIG_BACKTRACE_SELF_TEST is not set 1241# CONFIG_BACKTRACE_SELF_TEST is not set
@@ -1008,27 +1243,36 @@ CONFIG_SCHED_DEBUG=y
1008# CONFIG_FAULT_INJECTION is not set 1243# CONFIG_FAULT_INJECTION is not set
1009# CONFIG_LATENCYTOP is not set 1244# CONFIG_LATENCYTOP is not set
1010CONFIG_SYSCTL_SYSCALL_CHECK=y 1245CONFIG_SYSCTL_SYSCALL_CHECK=y
1246# CONFIG_DEBUG_PAGEALLOC is not set
1011CONFIG_HAVE_FUNCTION_TRACER=y 1247CONFIG_HAVE_FUNCTION_TRACER=y
1248CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1012CONFIG_HAVE_DYNAMIC_FTRACE=y 1249CONFIG_HAVE_DYNAMIC_FTRACE=y
1013CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y 1250CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1014 1251CONFIG_TRACING_SUPPORT=y
1015# 1252CONFIG_FTRACE=y
1016# Tracers
1017#
1018# CONFIG_FUNCTION_TRACER is not set 1253# CONFIG_FUNCTION_TRACER is not set
1254# CONFIG_IRQSOFF_TRACER is not set
1019# CONFIG_SCHED_TRACER is not set 1255# CONFIG_SCHED_TRACER is not set
1020# CONFIG_CONTEXT_SWITCH_TRACER is not set 1256# CONFIG_ENABLE_DEFAULT_TRACERS is not set
1021# CONFIG_BOOT_TRACER is not set 1257# CONFIG_BOOT_TRACER is not set
1022# CONFIG_TRACE_BRANCH_PROFILING is not set 1258CONFIG_BRANCH_PROFILE_NONE=y
1259# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1260# CONFIG_PROFILE_ALL_BRANCHES is not set
1023# CONFIG_STACK_TRACER is not set 1261# CONFIG_STACK_TRACER is not set
1024# CONFIG_DYNAMIC_PRINTK_DEBUG is not set 1262# CONFIG_KMEMTRACE is not set
1263# CONFIG_WORKQUEUE_TRACER is not set
1264# CONFIG_BLK_DEV_IO_TRACE is not set
1265# CONFIG_DYNAMIC_DEBUG is not set
1025# CONFIG_SAMPLES is not set 1266# CONFIG_SAMPLES is not set
1026CONFIG_HAVE_ARCH_KGDB=y 1267CONFIG_HAVE_ARCH_KGDB=y
1027# CONFIG_KGDB is not set 1268# CONFIG_KGDB is not set
1269# CONFIG_KMEMCHECK is not set
1270# CONFIG_PPC_DISABLE_WERROR is not set
1271CONFIG_PPC_WERROR=y
1028CONFIG_PRINT_STACK_DEPTH=64 1272CONFIG_PRINT_STACK_DEPTH=64
1029# CONFIG_DEBUG_STACKOVERFLOW is not set 1273# CONFIG_DEBUG_STACKOVERFLOW is not set
1030# CONFIG_DEBUG_STACK_USAGE is not set 1274# CONFIG_DEBUG_STACK_USAGE is not set
1031# CONFIG_DEBUG_PAGEALLOC is not set 1275# CONFIG_PPC_EMULATED_STATS is not set
1032# CONFIG_CODE_PATCHING_SELFTEST is not set 1276# CONFIG_CODE_PATCHING_SELFTEST is not set
1033# CONFIG_FTR_FIXUP_SELFTEST is not set 1277# CONFIG_FTR_FIXUP_SELFTEST is not set
1034# CONFIG_MSI_BITMAP_SELFTEST is not set 1278# CONFIG_MSI_BITMAP_SELFTEST is not set
diff --git a/arch/powerpc/configs/44x/eiger_defconfig b/arch/powerpc/configs/44x/eiger_defconfig
new file mode 100644
index 000000000000..007f3bd939e7
--- /dev/null
+++ b/arch/powerpc/configs/44x/eiger_defconfig
@@ -0,0 +1,1252 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.31-rc6
4# Wed Aug 19 13:06:50 2009
5#
6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11# CONFIG_PPC_BOOK3S_32 is not set
12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15CONFIG_44x=y
16# CONFIG_E200 is not set
17CONFIG_PPC_FPU=y
18CONFIG_4xx=y
19CONFIG_BOOKE=y
20CONFIG_PTE_64BIT=y
21CONFIG_PHYS_64BIT=y
22CONFIG_PPC_MMU_NOHASH=y
23CONFIG_PPC_MMU_NOHASH_32=y
24# CONFIG_PPC_MM_SLICES is not set
25CONFIG_NOT_COHERENT_CACHE=y
26CONFIG_PPC32=y
27CONFIG_WORD_SIZE=32
28CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
29CONFIG_MMU=y
30CONFIG_GENERIC_CMOS_UPDATE=y
31CONFIG_GENERIC_TIME=y
32CONFIG_GENERIC_TIME_VSYSCALL=y
33CONFIG_GENERIC_CLOCKEVENTS=y
34CONFIG_GENERIC_HARDIRQS=y
35CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
36# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
37CONFIG_IRQ_PER_CPU=y
38CONFIG_STACKTRACE_SUPPORT=y
39CONFIG_HAVE_LATENCYTOP_SUPPORT=y
40CONFIG_TRACE_IRQFLAGS_SUPPORT=y
41CONFIG_LOCKDEP_SUPPORT=y
42CONFIG_RWSEM_XCHGADD_ALGORITHM=y
43CONFIG_ARCH_HAS_ILOG2_U32=y
44CONFIG_GENERIC_HWEIGHT=y
45CONFIG_GENERIC_FIND_NEXT_BIT=y
46# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
47CONFIG_PPC=y
48CONFIG_EARLY_PRINTK=y
49CONFIG_GENERIC_NVRAM=y
50CONFIG_SCHED_OMIT_FRAME_POINTER=y
51CONFIG_ARCH_MAY_HAVE_PC_FDC=y
52CONFIG_PPC_OF=y
53CONFIG_OF=y
54CONFIG_PPC_UDBG_16550=y
55# CONFIG_GENERIC_TBSYNC is not set
56CONFIG_AUDIT_ARCH=y
57CONFIG_GENERIC_BUG=y
58CONFIG_DTC=y
59# CONFIG_DEFAULT_UIMAGE is not set
60CONFIG_PPC_DCR_NATIVE=y
61# CONFIG_PPC_DCR_MMIO is not set
62CONFIG_PPC_DCR=y
63CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
64CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
65CONFIG_CONSTRUCTORS=y
66
67#
68# General setup
69#
70CONFIG_EXPERIMENTAL=y
71CONFIG_BROKEN_ON_SMP=y
72CONFIG_INIT_ENV_ARG_LIMIT=32
73CONFIG_LOCALVERSION=""
74CONFIG_LOCALVERSION_AUTO=y
75CONFIG_SWAP=y
76CONFIG_SYSVIPC=y
77CONFIG_SYSVIPC_SYSCTL=y
78CONFIG_POSIX_MQUEUE=y
79CONFIG_POSIX_MQUEUE_SYSCTL=y
80# CONFIG_BSD_PROCESS_ACCT is not set
81# CONFIG_TASKSTATS is not set
82# CONFIG_AUDIT is not set
83
84#
85# RCU Subsystem
86#
87CONFIG_CLASSIC_RCU=y
88# CONFIG_TREE_RCU is not set
89# CONFIG_PREEMPT_RCU is not set
90# CONFIG_TREE_RCU_TRACE is not set
91# CONFIG_PREEMPT_RCU_TRACE is not set
92# CONFIG_IKCONFIG is not set
93CONFIG_LOG_BUF_SHIFT=14
94# CONFIG_GROUP_SCHED is not set
95# CONFIG_CGROUPS is not set
96CONFIG_SYSFS_DEPRECATED=y
97CONFIG_SYSFS_DEPRECATED_V2=y
98# CONFIG_RELAY is not set
99# CONFIG_NAMESPACES is not set
100CONFIG_BLK_DEV_INITRD=y
101CONFIG_INITRAMFS_SOURCE=""
102CONFIG_RD_GZIP=y
103# CONFIG_RD_BZIP2 is not set
104# CONFIG_RD_LZMA is not set
105# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
106CONFIG_SYSCTL=y
107CONFIG_ANON_INODES=y
108CONFIG_EMBEDDED=y
109CONFIG_SYSCTL_SYSCALL=y
110CONFIG_KALLSYMS=y
111# CONFIG_KALLSYMS_ALL is not set
112# CONFIG_KALLSYMS_EXTRA_PASS is not set
113CONFIG_HOTPLUG=y
114CONFIG_PRINTK=y
115CONFIG_BUG=y
116CONFIG_ELF_CORE=y
117CONFIG_BASE_FULL=y
118CONFIG_FUTEX=y
119CONFIG_EPOLL=y
120CONFIG_SIGNALFD=y
121CONFIG_TIMERFD=y
122CONFIG_EVENTFD=y
123CONFIG_SHMEM=y
124CONFIG_AIO=y
125CONFIG_HAVE_PERF_COUNTERS=y
126
127#
128# Performance Counters
129#
130# CONFIG_PERF_COUNTERS is not set
131CONFIG_VM_EVENT_COUNTERS=y
132CONFIG_PCI_QUIRKS=y
133CONFIG_SLUB_DEBUG=y
134# CONFIG_STRIP_ASM_SYMS is not set
135CONFIG_COMPAT_BRK=y
136# CONFIG_SLAB is not set
137CONFIG_SLUB=y
138# CONFIG_SLOB is not set
139# CONFIG_PROFILING is not set
140# CONFIG_MARKERS is not set
141CONFIG_HAVE_OPROFILE=y
142# CONFIG_KPROBES is not set
143CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
144CONFIG_HAVE_IOREMAP_PROT=y
145CONFIG_HAVE_KPROBES=y
146CONFIG_HAVE_KRETPROBES=y
147CONFIG_HAVE_ARCH_TRACEHOOK=y
148
149#
150# GCOV-based kernel profiling
151#
152# CONFIG_GCOV_KERNEL is not set
153# CONFIG_SLOW_WORK is not set
154# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
155CONFIG_SLABINFO=y
156CONFIG_RT_MUTEXES=y
157CONFIG_BASE_SMALL=0
158CONFIG_MODULES=y
159# CONFIG_MODULE_FORCE_LOAD is not set
160CONFIG_MODULE_UNLOAD=y
161# CONFIG_MODULE_FORCE_UNLOAD is not set
162# CONFIG_MODVERSIONS is not set
163# CONFIG_MODULE_SRCVERSION_ALL is not set
164CONFIG_BLOCK=y
165CONFIG_LBDAF=y
166# CONFIG_BLK_DEV_BSG is not set
167# CONFIG_BLK_DEV_INTEGRITY is not set
168
169#
170# IO Schedulers
171#
172CONFIG_IOSCHED_NOOP=y
173CONFIG_IOSCHED_AS=y
174CONFIG_IOSCHED_DEADLINE=y
175CONFIG_IOSCHED_CFQ=y
176CONFIG_DEFAULT_AS=y
177# CONFIG_DEFAULT_DEADLINE is not set
178# CONFIG_DEFAULT_CFQ is not set
179# CONFIG_DEFAULT_NOOP is not set
180CONFIG_DEFAULT_IOSCHED="anticipatory"
181# CONFIG_FREEZER is not set
182CONFIG_PPC4xx_PCI_EXPRESS=y
183
184#
185# Platform support
186#
187# CONFIG_PPC_CELL is not set
188# CONFIG_PPC_CELL_NATIVE is not set
189# CONFIG_PQ2ADS is not set
190# CONFIG_BAMBOO is not set
191# CONFIG_EBONY is not set
192# CONFIG_SAM440EP is not set
193# CONFIG_SEQUOIA is not set
194# CONFIG_TAISHAN is not set
195# CONFIG_KATMAI is not set
196# CONFIG_RAINIER is not set
197# CONFIG_WARP is not set
198# CONFIG_ARCHES is not set
199# CONFIG_CANYONLANDS is not set
200# CONFIG_GLACIER is not set
201# CONFIG_REDWOOD is not set
202CONFIG_EIGER=y
203# CONFIG_YOSEMITE is not set
204# CONFIG_XILINX_VIRTEX440_GENERIC_BOARD is not set
205CONFIG_PPC44x_SIMPLE=y
206# CONFIG_PPC4xx_GPIO is not set
207CONFIG_460SX=y
208# CONFIG_IPIC is not set
209# CONFIG_MPIC is not set
210# CONFIG_MPIC_WEIRD is not set
211# CONFIG_PPC_I8259 is not set
212# CONFIG_PPC_RTAS is not set
213# CONFIG_MMIO_NVRAM is not set
214# CONFIG_PPC_MPC106 is not set
215# CONFIG_PPC_970_NAP is not set
216# CONFIG_PPC_INDIRECT_IO is not set
217# CONFIG_GENERIC_IOMAP is not set
218# CONFIG_CPU_FREQ is not set
219# CONFIG_FSL_ULI1575 is not set
220# CONFIG_SIMPLE_GPIO is not set
221
222#
223# Kernel options
224#
225# CONFIG_HIGHMEM is not set
226CONFIG_TICK_ONESHOT=y
227CONFIG_NO_HZ=y
228CONFIG_HIGH_RES_TIMERS=y
229CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
230# CONFIG_HZ_100 is not set
231CONFIG_HZ_250=y
232# CONFIG_HZ_300 is not set
233# CONFIG_HZ_1000 is not set
234CONFIG_HZ=250
235CONFIG_SCHED_HRTICK=y
236CONFIG_PREEMPT_NONE=y
237# CONFIG_PREEMPT_VOLUNTARY is not set
238# CONFIG_PREEMPT is not set
239CONFIG_BINFMT_ELF=y
240# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
241# CONFIG_HAVE_AOUT is not set
242# CONFIG_BINFMT_MISC is not set
243# CONFIG_MATH_EMULATION is not set
244# CONFIG_IOMMU_HELPER is not set
245# CONFIG_SWIOTLB is not set
246CONFIG_PPC_NEED_DMA_SYNC_OPS=y
247CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
248CONFIG_ARCH_HAS_WALK_MEMORY=y
249CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
250CONFIG_ARCH_FLATMEM_ENABLE=y
251CONFIG_ARCH_POPULATES_NODE_MAP=y
252CONFIG_SELECT_MEMORY_MODEL=y
253CONFIG_FLATMEM_MANUAL=y
254# CONFIG_DISCONTIGMEM_MANUAL is not set
255# CONFIG_SPARSEMEM_MANUAL is not set
256CONFIG_FLATMEM=y
257CONFIG_FLAT_NODE_MEM_MAP=y
258CONFIG_PAGEFLAGS_EXTENDED=y
259CONFIG_SPLIT_PTLOCK_CPUS=4
260CONFIG_MIGRATION=y
261CONFIG_PHYS_ADDR_T_64BIT=y
262CONFIG_ZONE_DMA_FLAG=1
263CONFIG_BOUNCE=y
264CONFIG_VIRT_TO_BUS=y
265CONFIG_HAVE_MLOCK=y
266CONFIG_HAVE_MLOCKED_PAGE_BIT=y
267CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
268CONFIG_STDBINUTILS=y
269CONFIG_PPC_4K_PAGES=y
270# CONFIG_PPC_16K_PAGES is not set
271# CONFIG_PPC_64K_PAGES is not set
272# CONFIG_PPC_256K_PAGES is not set
273CONFIG_FORCE_MAX_ZONEORDER=11
274CONFIG_PROC_DEVICETREE=y
275CONFIG_CMDLINE_BOOL=y
276CONFIG_CMDLINE=""
277CONFIG_EXTRA_TARGETS=""
278CONFIG_SECCOMP=y
279CONFIG_ISA_DMA_API=y
280
281#
282# Bus options
283#
284CONFIG_ZONE_DMA=y
285CONFIG_PPC_INDIRECT_PCI=y
286CONFIG_4xx_SOC=y
287CONFIG_PPC_PCI_CHOICE=y
288CONFIG_PCI=y
289CONFIG_PCI_DOMAINS=y
290CONFIG_PCI_SYSCALL=y
291CONFIG_PCIEPORTBUS=y
292CONFIG_PCIEAER=y
293# CONFIG_PCIE_ECRC is not set
294# CONFIG_PCIEAER_INJECT is not set
295# CONFIG_PCIEASPM is not set
296CONFIG_ARCH_SUPPORTS_MSI=y
297# CONFIG_PCI_MSI is not set
298CONFIG_PCI_LEGACY=y
299# CONFIG_PCI_DEBUG is not set
300# CONFIG_PCI_STUB is not set
301# CONFIG_PCI_IOV is not set
302# CONFIG_PCCARD is not set
303# CONFIG_HOTPLUG_PCI is not set
304# CONFIG_HAS_RAPIDIO is not set
305
306#
307# Advanced setup
308#
309# CONFIG_ADVANCED_OPTIONS is not set
310
311#
312# Default settings for advanced configuration options are used
313#
314CONFIG_LOWMEM_SIZE=0x30000000
315CONFIG_PAGE_OFFSET=0xc0000000
316CONFIG_KERNEL_START=0xc0000000
317CONFIG_PHYSICAL_START=0x00000000
318CONFIG_TASK_SIZE=0xc0000000
319CONFIG_CONSISTENT_SIZE=0x00200000
320CONFIG_NET=y
321
322#
323# Networking options
324#
325CONFIG_PACKET=y
326# CONFIG_PACKET_MMAP is not set
327CONFIG_UNIX=y
328# CONFIG_NET_KEY is not set
329CONFIG_INET=y
330# CONFIG_IP_MULTICAST is not set
331# CONFIG_IP_ADVANCED_ROUTER is not set
332CONFIG_IP_FIB_HASH=y
333CONFIG_IP_PNP=y
334CONFIG_IP_PNP_DHCP=y
335CONFIG_IP_PNP_BOOTP=y
336# CONFIG_IP_PNP_RARP is not set
337# CONFIG_NET_IPIP is not set
338# CONFIG_NET_IPGRE is not set
339# CONFIG_ARPD is not set
340# CONFIG_SYN_COOKIES is not set
341# CONFIG_INET_AH is not set
342# CONFIG_INET_ESP is not set
343# CONFIG_INET_IPCOMP is not set
344# CONFIG_INET_XFRM_TUNNEL is not set
345# CONFIG_INET_TUNNEL is not set
346# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
347# CONFIG_INET_XFRM_MODE_TUNNEL is not set
348# CONFIG_INET_XFRM_MODE_BEET is not set
349# CONFIG_INET_LRO is not set
350CONFIG_INET_DIAG=y
351CONFIG_INET_TCP_DIAG=y
352# CONFIG_TCP_CONG_ADVANCED is not set
353CONFIG_TCP_CONG_CUBIC=y
354CONFIG_DEFAULT_TCP_CONG="cubic"
355# CONFIG_TCP_MD5SIG is not set
356# CONFIG_IPV6 is not set
357# CONFIG_NETWORK_SECMARK is not set
358# CONFIG_NETFILTER is not set
359# CONFIG_IP_DCCP is not set
360# CONFIG_IP_SCTP is not set
361# CONFIG_TIPC is not set
362# CONFIG_ATM is not set
363# CONFIG_BRIDGE is not set
364# CONFIG_NET_DSA is not set
365# CONFIG_VLAN_8021Q is not set
366# CONFIG_DECNET is not set
367# CONFIG_LLC2 is not set
368# CONFIG_IPX is not set
369# CONFIG_ATALK is not set
370# CONFIG_X25 is not set
371# CONFIG_LAPB is not set
372# CONFIG_ECONET is not set
373# CONFIG_WAN_ROUTER is not set
374# CONFIG_PHONET is not set
375# CONFIG_IEEE802154 is not set
376# CONFIG_NET_SCHED is not set
377# CONFIG_DCB is not set
378
379#
380# Network testing
381#
382# CONFIG_NET_PKTGEN is not set
383# CONFIG_HAMRADIO is not set
384# CONFIG_CAN is not set
385# CONFIG_IRDA is not set
386# CONFIG_BT is not set
387# CONFIG_AF_RXRPC is not set
388CONFIG_WIRELESS=y
389# CONFIG_CFG80211 is not set
390CONFIG_WIRELESS_OLD_REGULATORY=y
391# CONFIG_WIRELESS_EXT is not set
392# CONFIG_LIB80211 is not set
393
394#
395# CFG80211 needs to be enabled for MAC80211
396#
397CONFIG_MAC80211_DEFAULT_PS_VALUE=0
398# CONFIG_WIMAX is not set
399# CONFIG_RFKILL is not set
400# CONFIG_NET_9P is not set
401
402#
403# Device Drivers
404#
405
406#
407# Generic Driver Options
408#
409CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
410CONFIG_STANDALONE=y
411CONFIG_PREVENT_FIRMWARE_BUILD=y
412CONFIG_FW_LOADER=y
413CONFIG_FIRMWARE_IN_KERNEL=y
414CONFIG_EXTRA_FIRMWARE=""
415# CONFIG_DEBUG_DRIVER is not set
416# CONFIG_DEBUG_DEVRES is not set
417# CONFIG_SYS_HYPERVISOR is not set
418CONFIG_CONNECTOR=y
419CONFIG_PROC_EVENTS=y
420CONFIG_MTD=y
421# CONFIG_MTD_DEBUG is not set
422CONFIG_MTD_CONCAT=y
423CONFIG_MTD_PARTITIONS=y
424# CONFIG_MTD_TESTS is not set
425# CONFIG_MTD_REDBOOT_PARTS is not set
426CONFIG_MTD_CMDLINE_PARTS=y
427CONFIG_MTD_OF_PARTS=y
428# CONFIG_MTD_AR7_PARTS is not set
429
430#
431# User Modules And Translation Layers
432#
433CONFIG_MTD_CHAR=y
434CONFIG_MTD_BLKDEVS=y
435CONFIG_MTD_BLOCK=y
436# CONFIG_FTL is not set
437# CONFIG_NFTL is not set
438# CONFIG_INFTL is not set
439# CONFIG_RFD_FTL is not set
440# CONFIG_SSFDC is not set
441# CONFIG_MTD_OOPS is not set
442
443#
444# RAM/ROM/Flash chip drivers
445#
446CONFIG_MTD_CFI=y
447# CONFIG_MTD_JEDECPROBE is not set
448CONFIG_MTD_GEN_PROBE=y
449# CONFIG_MTD_CFI_ADV_OPTIONS is not set
450CONFIG_MTD_MAP_BANK_WIDTH_1=y
451CONFIG_MTD_MAP_BANK_WIDTH_2=y
452CONFIG_MTD_MAP_BANK_WIDTH_4=y
453# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
454# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
455# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
456CONFIG_MTD_CFI_I1=y
457CONFIG_MTD_CFI_I2=y
458# CONFIG_MTD_CFI_I4 is not set
459# CONFIG_MTD_CFI_I8 is not set
460# CONFIG_MTD_CFI_INTELEXT is not set
461CONFIG_MTD_CFI_AMDSTD=y
462# CONFIG_MTD_CFI_STAA is not set
463CONFIG_MTD_CFI_UTIL=y
464# CONFIG_MTD_RAM is not set
465# CONFIG_MTD_ROM is not set
466# CONFIG_MTD_ABSENT is not set
467
468#
469# Mapping drivers for chip access
470#
471# CONFIG_MTD_COMPLEX_MAPPINGS is not set
472# CONFIG_MTD_PHYSMAP is not set
473CONFIG_MTD_PHYSMAP_OF=y
474# CONFIG_MTD_INTEL_VR_NOR is not set
475# CONFIG_MTD_PLATRAM is not set
476
477#
478# Self-contained MTD device drivers
479#
480# CONFIG_MTD_PMC551 is not set
481# CONFIG_MTD_SLRAM is not set
482# CONFIG_MTD_PHRAM is not set
483# CONFIG_MTD_MTDRAM is not set
484# CONFIG_MTD_BLOCK2MTD is not set
485
486#
487# Disk-On-Chip Device Drivers
488#
489# CONFIG_MTD_DOC2000 is not set
490# CONFIG_MTD_DOC2001 is not set
491# CONFIG_MTD_DOC2001PLUS is not set
492CONFIG_MTD_NAND=y
493# CONFIG_MTD_NAND_VERIFY_WRITE is not set
494CONFIG_MTD_NAND_ECC_SMC=y
495# CONFIG_MTD_NAND_MUSEUM_IDS is not set
496CONFIG_MTD_NAND_IDS=y
497CONFIG_MTD_NAND_NDFC=y
498# CONFIG_MTD_NAND_DISKONCHIP is not set
499# CONFIG_MTD_NAND_CAFE is not set
500# CONFIG_MTD_NAND_NANDSIM is not set
501# CONFIG_MTD_NAND_PLATFORM is not set
502# CONFIG_MTD_NAND_FSL_ELBC is not set
503# CONFIG_MTD_ONENAND is not set
504
505#
506# LPDDR flash memory drivers
507#
508# CONFIG_MTD_LPDDR is not set
509
510#
511# UBI - Unsorted block images
512#
513# CONFIG_MTD_UBI is not set
514CONFIG_OF_DEVICE=y
515CONFIG_OF_I2C=y
516# CONFIG_PARPORT is not set
517CONFIG_BLK_DEV=y
518# CONFIG_BLK_DEV_FD is not set
519# CONFIG_BLK_CPQ_DA is not set
520# CONFIG_BLK_CPQ_CISS_DA is not set
521# CONFIG_BLK_DEV_DAC960 is not set
522# CONFIG_BLK_DEV_UMEM is not set
523# CONFIG_BLK_DEV_COW_COMMON is not set
524# CONFIG_BLK_DEV_LOOP is not set
525# CONFIG_BLK_DEV_NBD is not set
526# CONFIG_BLK_DEV_SX8 is not set
527CONFIG_BLK_DEV_RAM=y
528CONFIG_BLK_DEV_RAM_COUNT=16
529CONFIG_BLK_DEV_RAM_SIZE=35000
530# CONFIG_BLK_DEV_XIP is not set
531# CONFIG_CDROM_PKTCDVD is not set
532# CONFIG_ATA_OVER_ETH is not set
533# CONFIG_XILINX_SYSACE is not set
534# CONFIG_BLK_DEV_HD is not set
535# CONFIG_MISC_DEVICES is not set
536CONFIG_HAVE_IDE=y
537# CONFIG_IDE is not set
538
539#
540# SCSI device support
541#
542# CONFIG_RAID_ATTRS is not set
543CONFIG_SCSI=y
544CONFIG_SCSI_DMA=y
545# CONFIG_SCSI_TGT is not set
546# CONFIG_SCSI_NETLINK is not set
547CONFIG_SCSI_PROC_FS=y
548
549#
550# SCSI support type (disk, tape, CD-ROM)
551#
552CONFIG_BLK_DEV_SD=y
553# CONFIG_CHR_DEV_ST is not set
554# CONFIG_CHR_DEV_OSST is not set
555# CONFIG_BLK_DEV_SR is not set
556CONFIG_CHR_DEV_SG=y
557# CONFIG_CHR_DEV_SCH is not set
558# CONFIG_SCSI_MULTI_LUN is not set
559# CONFIG_SCSI_CONSTANTS is not set
560# CONFIG_SCSI_LOGGING is not set
561# CONFIG_SCSI_SCAN_ASYNC is not set
562CONFIG_SCSI_WAIT_SCAN=m
563
564#
565# SCSI Transports
566#
567# CONFIG_SCSI_SPI_ATTRS is not set
568# CONFIG_SCSI_FC_ATTRS is not set
569# CONFIG_SCSI_ISCSI_ATTRS is not set
570CONFIG_SCSI_SAS_ATTRS=y
571# CONFIG_SCSI_SAS_LIBSAS is not set
572# CONFIG_SCSI_SRP_ATTRS is not set
573CONFIG_SCSI_LOWLEVEL=y
574# CONFIG_ISCSI_TCP is not set
575# CONFIG_SCSI_BNX2_ISCSI is not set
576# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
577# CONFIG_SCSI_3W_9XXX is not set
578# CONFIG_SCSI_ACARD is not set
579# CONFIG_SCSI_AACRAID is not set
580# CONFIG_SCSI_AIC7XXX is not set
581# CONFIG_SCSI_AIC7XXX_OLD is not set
582# CONFIG_SCSI_AIC79XX is not set
583# CONFIG_SCSI_AIC94XX is not set
584# CONFIG_SCSI_MVSAS is not set
585# CONFIG_SCSI_DPT_I2O is not set
586# CONFIG_SCSI_ADVANSYS is not set
587# CONFIG_SCSI_ARCMSR is not set
588# CONFIG_MEGARAID_NEWGEN is not set
589# CONFIG_MEGARAID_LEGACY is not set
590# CONFIG_MEGARAID_SAS is not set
591# CONFIG_SCSI_MPT2SAS is not set
592# CONFIG_SCSI_HPTIOP is not set
593# CONFIG_SCSI_BUSLOGIC is not set
594# CONFIG_LIBFC is not set
595# CONFIG_LIBFCOE is not set
596# CONFIG_FCOE is not set
597# CONFIG_SCSI_DMX3191D is not set
598# CONFIG_SCSI_EATA is not set
599# CONFIG_SCSI_FUTURE_DOMAIN is not set
600# CONFIG_SCSI_GDTH is not set
601# CONFIG_SCSI_IPS is not set
602# CONFIG_SCSI_INITIO is not set
603# CONFIG_SCSI_INIA100 is not set
604# CONFIG_SCSI_STEX is not set
605# CONFIG_SCSI_SYM53C8XX_2 is not set
606# CONFIG_SCSI_QLOGIC_1280 is not set
607# CONFIG_SCSI_QLA_FC is not set
608# CONFIG_SCSI_QLA_ISCSI is not set
609# CONFIG_SCSI_LPFC is not set
610# CONFIG_SCSI_DC395x is not set
611# CONFIG_SCSI_DC390T is not set
612# CONFIG_SCSI_NSP32 is not set
613# CONFIG_SCSI_DEBUG is not set
614# CONFIG_SCSI_SRP is not set
615# CONFIG_SCSI_DH is not set
616# CONFIG_SCSI_OSD_INITIATOR is not set
617# CONFIG_ATA is not set
618# CONFIG_MD is not set
619CONFIG_FUSION=y
620# CONFIG_FUSION_SPI is not set
621# CONFIG_FUSION_FC is not set
622CONFIG_FUSION_SAS=y
623CONFIG_FUSION_MAX_SGE=128
624# CONFIG_FUSION_CTL is not set
625# CONFIG_FUSION_LOGGING is not set
626
627#
628# IEEE 1394 (FireWire) support
629#
630
631#
632# You can enable one or both FireWire driver stacks.
633#
634
635#
636# See the help texts for more information.
637#
638# CONFIG_FIREWIRE is not set
639# CONFIG_IEEE1394 is not set
640CONFIG_I2O=y
641CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
642CONFIG_I2O_EXT_ADAPTEC=y
643# CONFIG_I2O_CONFIG is not set
644# CONFIG_I2O_BUS is not set
645# CONFIG_I2O_BLOCK is not set
646# CONFIG_I2O_SCSI is not set
647# CONFIG_I2O_PROC is not set
648# CONFIG_MACINTOSH_DRIVERS is not set
649CONFIG_NETDEVICES=y
650# CONFIG_DUMMY is not set
651# CONFIG_BONDING is not set
652# CONFIG_MACVLAN is not set
653# CONFIG_EQUALIZER is not set
654# CONFIG_TUN is not set
655# CONFIG_VETH is not set
656# CONFIG_ARCNET is not set
657# CONFIG_PHYLIB is not set
658CONFIG_NET_ETHERNET=y
659# CONFIG_MII is not set
660# CONFIG_HAPPYMEAL is not set
661# CONFIG_SUNGEM is not set
662# CONFIG_CASSINI is not set
663# CONFIG_NET_VENDOR_3COM is not set
664# CONFIG_ETHOC is not set
665# CONFIG_DNET is not set
666# CONFIG_NET_TULIP is not set
667# CONFIG_HP100 is not set
668CONFIG_IBM_NEW_EMAC=y
669CONFIG_IBM_NEW_EMAC_RXB=256
670CONFIG_IBM_NEW_EMAC_TXB=256
671CONFIG_IBM_NEW_EMAC_POLL_WEIGHT=32
672CONFIG_IBM_NEW_EMAC_RX_COPY_THRESHOLD=256
673CONFIG_IBM_NEW_EMAC_RX_SKB_HEADROOM=0
674# CONFIG_IBM_NEW_EMAC_DEBUG is not set
675CONFIG_IBM_NEW_EMAC_ZMII=y
676CONFIG_IBM_NEW_EMAC_RGMII=y
677CONFIG_IBM_NEW_EMAC_TAH=y
678CONFIG_IBM_NEW_EMAC_EMAC4=y
679# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
680# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
681# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
682# CONFIG_NET_PCI is not set
683# CONFIG_B44 is not set
684# CONFIG_KS8842 is not set
685# CONFIG_ATL2 is not set
686CONFIG_NETDEV_1000=y
687# CONFIG_ACENIC is not set
688# CONFIG_DL2K is not set
689# CONFIG_E1000 is not set
690CONFIG_E1000E=y
691# CONFIG_IP1000 is not set
692# CONFIG_IGB is not set
693# CONFIG_IGBVF is not set
694# CONFIG_NS83820 is not set
695# CONFIG_HAMACHI is not set
696# CONFIG_YELLOWFIN is not set
697# CONFIG_R8169 is not set
698# CONFIG_SIS190 is not set
699# CONFIG_SKGE is not set
700# CONFIG_SKY2 is not set
701# CONFIG_VIA_VELOCITY is not set
702# CONFIG_TIGON3 is not set
703# CONFIG_BNX2 is not set
704# CONFIG_CNIC is not set
705# CONFIG_MV643XX_ETH is not set
706# CONFIG_XILINX_LL_TEMAC is not set
707# CONFIG_QLA3XXX is not set
708# CONFIG_ATL1 is not set
709# CONFIG_ATL1E is not set
710# CONFIG_ATL1C is not set
711# CONFIG_JME is not set
712# CONFIG_NETDEV_10000 is not set
713# CONFIG_TR is not set
714
715#
716# Wireless LAN
717#
718# CONFIG_WLAN_PRE80211 is not set
719# CONFIG_WLAN_80211 is not set
720
721#
722# Enable WiMAX (Networking options) to see the WiMAX drivers
723#
724# CONFIG_WAN is not set
725# CONFIG_FDDI is not set
726# CONFIG_HIPPI is not set
727# CONFIG_PPP is not set
728# CONFIG_SLIP is not set
729# CONFIG_NET_FC is not set
730# CONFIG_NETCONSOLE is not set
731# CONFIG_NETPOLL is not set
732# CONFIG_NET_POLL_CONTROLLER is not set
733# CONFIG_ISDN is not set
734# CONFIG_PHONE is not set
735
736#
737# Input device support
738#
739# CONFIG_INPUT is not set
740
741#
742# Hardware I/O ports
743#
744# CONFIG_SERIO is not set
745# CONFIG_GAMEPORT is not set
746
747#
748# Character devices
749#
750# CONFIG_VT is not set
751CONFIG_DEVKMEM=y
752# CONFIG_SERIAL_NONSTANDARD is not set
753# CONFIG_NOZOMI is not set
754
755#
756# Serial drivers
757#
758CONFIG_SERIAL_8250=y
759CONFIG_SERIAL_8250_CONSOLE=y
760# CONFIG_SERIAL_8250_PCI is not set
761CONFIG_SERIAL_8250_NR_UARTS=2
762CONFIG_SERIAL_8250_RUNTIME_UARTS=2
763CONFIG_SERIAL_8250_EXTENDED=y
764# CONFIG_SERIAL_8250_MANY_PORTS is not set
765CONFIG_SERIAL_8250_SHARE_IRQ=y
766# CONFIG_SERIAL_8250_DETECT_IRQ is not set
767# CONFIG_SERIAL_8250_RSA is not set
768
769#
770# Non-8250 serial port support
771#
772# CONFIG_SERIAL_UARTLITE is not set
773CONFIG_SERIAL_CORE=y
774CONFIG_SERIAL_CORE_CONSOLE=y
775# CONFIG_SERIAL_JSM is not set
776CONFIG_SERIAL_OF_PLATFORM=y
777# CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL is not set
778CONFIG_UNIX98_PTYS=y
779# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
780CONFIG_LEGACY_PTYS=y
781CONFIG_LEGACY_PTY_COUNT=256
782# CONFIG_HVC_UDBG is not set
783# CONFIG_IPMI_HANDLER is not set
784# CONFIG_HW_RANDOM is not set
785# CONFIG_NVRAM is not set
786# CONFIG_GEN_RTC is not set
787# CONFIG_R3964 is not set
788# CONFIG_APPLICOM is not set
789# CONFIG_RAW_DRIVER is not set
790# CONFIG_TCG_TPM is not set
791CONFIG_DEVPORT=y
792CONFIG_I2C=y
793CONFIG_I2C_BOARDINFO=y
794CONFIG_I2C_CHARDEV=y
795CONFIG_I2C_HELPER_AUTO=y
796
797#
798# I2C Hardware Bus support
799#
800
801#
802# PC SMBus host controller drivers
803#
804# CONFIG_I2C_ALI1535 is not set
805# CONFIG_I2C_ALI1563 is not set
806# CONFIG_I2C_ALI15X3 is not set
807# CONFIG_I2C_AMD756 is not set
808# CONFIG_I2C_AMD8111 is not set
809# CONFIG_I2C_I801 is not set
810# CONFIG_I2C_ISCH is not set
811# CONFIG_I2C_PIIX4 is not set
812# CONFIG_I2C_NFORCE2 is not set
813# CONFIG_I2C_SIS5595 is not set
814# CONFIG_I2C_SIS630 is not set
815# CONFIG_I2C_SIS96X is not set
816# CONFIG_I2C_VIA is not set
817# CONFIG_I2C_VIAPRO is not set
818
819#
820# I2C system bus drivers (mostly embedded / system-on-chip)
821#
822CONFIG_I2C_IBM_IIC=y
823# CONFIG_I2C_MPC is not set
824# CONFIG_I2C_OCORES is not set
825# CONFIG_I2C_SIMTEC is not set
826
827#
828# External I2C/SMBus adapter drivers
829#
830# CONFIG_I2C_PARPORT_LIGHT is not set
831# CONFIG_I2C_TAOS_EVM is not set
832
833#
834# Graphics adapter I2C/DDC channel drivers
835#
836# CONFIG_I2C_VOODOO3 is not set
837
838#
839# Other I2C/SMBus bus drivers
840#
841# CONFIG_I2C_PCA_PLATFORM is not set
842# CONFIG_I2C_STUB is not set
843
844#
845# Miscellaneous I2C Chip support
846#
847# CONFIG_DS1682 is not set
848# CONFIG_SENSORS_PCF8574 is not set
849# CONFIG_PCF8575 is not set
850# CONFIG_SENSORS_PCA9539 is not set
851# CONFIG_SENSORS_TSL2550 is not set
852CONFIG_I2C_DEBUG_CORE=y
853CONFIG_I2C_DEBUG_ALGO=y
854CONFIG_I2C_DEBUG_BUS=y
855CONFIG_I2C_DEBUG_CHIP=y
856# CONFIG_SPI is not set
857
858#
859# PPS support
860#
861# CONFIG_PPS is not set
862CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
863# CONFIG_GPIOLIB is not set
864# CONFIG_W1 is not set
865# CONFIG_POWER_SUPPLY is not set
866# CONFIG_HWMON is not set
867# CONFIG_THERMAL is not set
868# CONFIG_THERMAL_HWMON is not set
869# CONFIG_WATCHDOG is not set
870CONFIG_SSB_POSSIBLE=y
871
872#
873# Sonics Silicon Backplane
874#
875# CONFIG_SSB is not set
876
877#
878# Multifunction device drivers
879#
880# CONFIG_MFD_CORE is not set
881# CONFIG_MFD_SM501 is not set
882# CONFIG_HTC_PASIC3 is not set
883# CONFIG_TWL4030_CORE is not set
884# CONFIG_MFD_TMIO is not set
885# CONFIG_PMIC_DA903X is not set
886# CONFIG_MFD_WM8400 is not set
887# CONFIG_MFD_WM8350_I2C is not set
888# CONFIG_MFD_PCF50633 is not set
889# CONFIG_AB3100_CORE is not set
890# CONFIG_REGULATOR is not set
891# CONFIG_MEDIA_SUPPORT is not set
892
893#
894# Graphics support
895#
896# CONFIG_AGP is not set
897# CONFIG_DRM is not set
898# CONFIG_VGASTATE is not set
899CONFIG_VIDEO_OUTPUT_CONTROL=m
900# CONFIG_FB is not set
901# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
902
903#
904# Display device support
905#
906# CONFIG_DISPLAY_SUPPORT is not set
907# CONFIG_SOUND is not set
908# CONFIG_USB_SUPPORT is not set
909# CONFIG_UWB is not set
910# CONFIG_MMC is not set
911# CONFIG_MEMSTICK is not set
912# CONFIG_NEW_LEDS is not set
913# CONFIG_ACCESSIBILITY is not set
914# CONFIG_INFINIBAND is not set
915# CONFIG_EDAC is not set
916# CONFIG_RTC_CLASS is not set
917CONFIG_DMADEVICES=y
918
919#
920# DMA Devices
921#
922# CONFIG_AUXDISPLAY is not set
923# CONFIG_UIO is not set
924
925#
926# TI VLYNQ
927#
928# CONFIG_STAGING is not set
929
930#
931# File systems
932#
933CONFIG_EXT2_FS=y
934# CONFIG_EXT2_FS_XATTR is not set
935# CONFIG_EXT2_FS_XIP is not set
936# CONFIG_EXT3_FS is not set
937# CONFIG_EXT4_FS is not set
938# CONFIG_REISERFS_FS is not set
939# CONFIG_JFS_FS is not set
940# CONFIG_FS_POSIX_ACL is not set
941# CONFIG_XFS_FS is not set
942# CONFIG_GFS2_FS is not set
943# CONFIG_OCFS2_FS is not set
944# CONFIG_BTRFS_FS is not set
945CONFIG_FILE_LOCKING=y
946CONFIG_FSNOTIFY=y
947CONFIG_DNOTIFY=y
948CONFIG_INOTIFY=y
949CONFIG_INOTIFY_USER=y
950# CONFIG_QUOTA is not set
951# CONFIG_AUTOFS_FS is not set
952# CONFIG_AUTOFS4_FS is not set
953# CONFIG_FUSE_FS is not set
954
955#
956# Caches
957#
958# CONFIG_FSCACHE is not set
959
960#
961# CD-ROM/DVD Filesystems
962#
963# CONFIG_ISO9660_FS is not set
964# CONFIG_UDF_FS is not set
965
966#
967# DOS/FAT/NT Filesystems
968#
969# CONFIG_MSDOS_FS is not set
970# CONFIG_VFAT_FS is not set
971# CONFIG_NTFS_FS is not set
972
973#
974# Pseudo filesystems
975#
976CONFIG_PROC_FS=y
977CONFIG_PROC_KCORE=y
978CONFIG_PROC_SYSCTL=y
979CONFIG_PROC_PAGE_MONITOR=y
980CONFIG_SYSFS=y
981CONFIG_TMPFS=y
982# CONFIG_TMPFS_POSIX_ACL is not set
983# CONFIG_HUGETLB_PAGE is not set
984# CONFIG_CONFIGFS_FS is not set
985CONFIG_MISC_FILESYSTEMS=y
986# CONFIG_ADFS_FS is not set
987# CONFIG_AFFS_FS is not set
988# CONFIG_HFS_FS is not set
989# CONFIG_HFSPLUS_FS is not set
990# CONFIG_BEFS_FS is not set
991# CONFIG_BFS_FS is not set
992# CONFIG_EFS_FS is not set
993# CONFIG_JFFS2_FS is not set
994CONFIG_CRAMFS=y
995# CONFIG_SQUASHFS is not set
996# CONFIG_VXFS_FS is not set
997# CONFIG_MINIX_FS is not set
998# CONFIG_OMFS_FS is not set
999# CONFIG_HPFS_FS is not set
1000# CONFIG_QNX4FS_FS is not set
1001# CONFIG_ROMFS_FS is not set
1002# CONFIG_SYSV_FS is not set
1003# CONFIG_UFS_FS is not set
1004# CONFIG_NILFS2_FS is not set
1005CONFIG_NETWORK_FILESYSTEMS=y
1006CONFIG_NFS_FS=y
1007CONFIG_NFS_V3=y
1008# CONFIG_NFS_V3_ACL is not set
1009# CONFIG_NFS_V4 is not set
1010CONFIG_ROOT_NFS=y
1011# CONFIG_NFSD is not set
1012CONFIG_LOCKD=y
1013CONFIG_LOCKD_V4=y
1014CONFIG_NFS_COMMON=y
1015CONFIG_SUNRPC=y
1016# CONFIG_RPCSEC_GSS_KRB5 is not set
1017# CONFIG_RPCSEC_GSS_SPKM3 is not set
1018# CONFIG_SMB_FS is not set
1019# CONFIG_CIFS is not set
1020# CONFIG_NCP_FS is not set
1021# CONFIG_CODA_FS is not set
1022# CONFIG_AFS_FS is not set
1023
1024#
1025# Partition Types
1026#
1027# CONFIG_PARTITION_ADVANCED is not set
1028CONFIG_MSDOS_PARTITION=y
1029# CONFIG_NLS is not set
1030# CONFIG_DLM is not set
1031# CONFIG_BINARY_PRINTF is not set
1032
1033#
1034# Library routines
1035#
1036CONFIG_BITREVERSE=y
1037CONFIG_GENERIC_FIND_LAST_BIT=y
1038# CONFIG_CRC_CCITT is not set
1039# CONFIG_CRC16 is not set
1040# CONFIG_CRC_T10DIF is not set
1041# CONFIG_CRC_ITU_T is not set
1042CONFIG_CRC32=y
1043# CONFIG_CRC7 is not set
1044# CONFIG_LIBCRC32C is not set
1045CONFIG_ZLIB_INFLATE=y
1046CONFIG_DECOMPRESS_GZIP=y
1047CONFIG_HAS_IOMEM=y
1048CONFIG_HAS_IOPORT=y
1049CONFIG_HAS_DMA=y
1050CONFIG_HAVE_LMB=y
1051CONFIG_NLATTR=y
1052CONFIG_GENERIC_ATOMIC64=y
1053
1054#
1055# Kernel hacking
1056#
1057# CONFIG_PRINTK_TIME is not set
1058CONFIG_ENABLE_WARN_DEPRECATED=y
1059CONFIG_ENABLE_MUST_CHECK=y
1060CONFIG_FRAME_WARN=1024
1061CONFIG_MAGIC_SYSRQ=y
1062# CONFIG_UNUSED_SYMBOLS is not set
1063CONFIG_DEBUG_FS=y
1064# CONFIG_HEADERS_CHECK is not set
1065CONFIG_DEBUG_KERNEL=y
1066# CONFIG_DEBUG_SHIRQ is not set
1067CONFIG_DETECT_SOFTLOCKUP=y
1068# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
1069CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1070CONFIG_DETECT_HUNG_TASK=y
1071# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1072CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1073CONFIG_SCHED_DEBUG=y
1074# CONFIG_SCHEDSTATS is not set
1075# CONFIG_TIMER_STATS is not set
1076# CONFIG_DEBUG_OBJECTS is not set
1077# CONFIG_SLUB_DEBUG_ON is not set
1078# CONFIG_SLUB_STATS is not set
1079# CONFIG_DEBUG_KMEMLEAK is not set
1080# CONFIG_DEBUG_RT_MUTEXES is not set
1081# CONFIG_RT_MUTEX_TESTER is not set
1082# CONFIG_DEBUG_SPINLOCK is not set
1083# CONFIG_DEBUG_MUTEXES is not set
1084# CONFIG_DEBUG_LOCK_ALLOC is not set
1085# CONFIG_PROVE_LOCKING is not set
1086# CONFIG_LOCK_STAT is not set
1087# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1088# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1089# CONFIG_DEBUG_KOBJECT is not set
1090# CONFIG_DEBUG_BUGVERBOSE is not set
1091# CONFIG_DEBUG_INFO is not set
1092# CONFIG_DEBUG_VM is not set
1093# CONFIG_DEBUG_WRITECOUNT is not set
1094# CONFIG_DEBUG_MEMORY_INIT is not set
1095# CONFIG_DEBUG_LIST is not set
1096# CONFIG_DEBUG_SG is not set
1097# CONFIG_DEBUG_NOTIFIERS is not set
1098# CONFIG_RCU_TORTURE_TEST is not set
1099# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1100# CONFIG_BACKTRACE_SELF_TEST is not set
1101# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1102# CONFIG_FAULT_INJECTION is not set
1103# CONFIG_LATENCYTOP is not set
1104CONFIG_SYSCTL_SYSCALL_CHECK=y
1105# CONFIG_DEBUG_PAGEALLOC is not set
1106CONFIG_HAVE_FUNCTION_TRACER=y
1107CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1108CONFIG_HAVE_DYNAMIC_FTRACE=y
1109CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1110CONFIG_TRACING_SUPPORT=y
1111CONFIG_FTRACE=y
1112# CONFIG_FUNCTION_TRACER is not set
1113# CONFIG_IRQSOFF_TRACER is not set
1114# CONFIG_SCHED_TRACER is not set
1115# CONFIG_ENABLE_DEFAULT_TRACERS is not set
1116# CONFIG_BOOT_TRACER is not set
1117CONFIG_BRANCH_PROFILE_NONE=y
1118# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
1119# CONFIG_PROFILE_ALL_BRANCHES is not set
1120# CONFIG_STACK_TRACER is not set
1121# CONFIG_KMEMTRACE is not set
1122# CONFIG_WORKQUEUE_TRACER is not set
1123# CONFIG_BLK_DEV_IO_TRACE is not set
1124# CONFIG_DYNAMIC_DEBUG is not set
1125# CONFIG_SAMPLES is not set
1126CONFIG_HAVE_ARCH_KGDB=y
1127# CONFIG_KGDB is not set
1128# CONFIG_KMEMCHECK is not set
1129# CONFIG_PPC_DISABLE_WERROR is not set
1130CONFIG_PPC_WERROR=y
1131CONFIG_PRINT_STACK_DEPTH=64
1132# CONFIG_DEBUG_STACKOVERFLOW is not set
1133# CONFIG_DEBUG_STACK_USAGE is not set
1134# CONFIG_PPC_EMULATED_STATS is not set
1135# CONFIG_CODE_PATCHING_SELFTEST is not set
1136# CONFIG_FTR_FIXUP_SELFTEST is not set
1137# CONFIG_MSI_BITMAP_SELFTEST is not set
1138# CONFIG_XMON is not set
1139# CONFIG_IRQSTACKS is not set
1140# CONFIG_VIRQ_DEBUG is not set
1141# CONFIG_BDI_SWITCH is not set
1142# CONFIG_PPC_EARLY_DEBUG is not set
1143
1144#
1145# Security options
1146#
1147# CONFIG_KEYS is not set
1148# CONFIG_SECURITY is not set
1149# CONFIG_SECURITYFS is not set
1150# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1151CONFIG_CRYPTO=y
1152
1153#
1154# Crypto core or helper
1155#
1156# CONFIG_CRYPTO_FIPS is not set
1157CONFIG_CRYPTO_ALGAPI=y
1158CONFIG_CRYPTO_ALGAPI2=y
1159CONFIG_CRYPTO_AEAD=y
1160CONFIG_CRYPTO_AEAD2=y
1161CONFIG_CRYPTO_BLKCIPHER=y
1162CONFIG_CRYPTO_BLKCIPHER2=y
1163CONFIG_CRYPTO_HASH=y
1164CONFIG_CRYPTO_HASH2=y
1165CONFIG_CRYPTO_RNG=y
1166CONFIG_CRYPTO_RNG2=y
1167CONFIG_CRYPTO_PCOMP=y
1168CONFIG_CRYPTO_MANAGER=y
1169CONFIG_CRYPTO_MANAGER2=y
1170CONFIG_CRYPTO_GF128MUL=y
1171# CONFIG_CRYPTO_NULL is not set
1172CONFIG_CRYPTO_WORKQUEUE=y
1173CONFIG_CRYPTO_CRYPTD=y
1174CONFIG_CRYPTO_AUTHENC=y
1175# CONFIG_CRYPTO_TEST is not set
1176
1177#
1178# Authenticated Encryption with Associated Data
1179#
1180CONFIG_CRYPTO_CCM=y
1181CONFIG_CRYPTO_GCM=y
1182CONFIG_CRYPTO_SEQIV=y
1183
1184#
1185# Block modes
1186#
1187CONFIG_CRYPTO_CBC=y
1188CONFIG_CRYPTO_CTR=y
1189CONFIG_CRYPTO_CTS=y
1190CONFIG_CRYPTO_ECB=y
1191CONFIG_CRYPTO_LRW=y
1192CONFIG_CRYPTO_PCBC=y
1193CONFIG_CRYPTO_XTS=y
1194
1195#
1196# Hash modes
1197#
1198CONFIG_CRYPTO_HMAC=y
1199CONFIG_CRYPTO_XCBC=y
1200
1201#
1202# Digest
1203#
1204# CONFIG_CRYPTO_CRC32C is not set
1205CONFIG_CRYPTO_MD4=y
1206CONFIG_CRYPTO_MD5=y
1207# CONFIG_CRYPTO_MICHAEL_MIC is not set
1208# CONFIG_CRYPTO_RMD128 is not set
1209# CONFIG_CRYPTO_RMD160 is not set
1210# CONFIG_CRYPTO_RMD256 is not set
1211# CONFIG_CRYPTO_RMD320 is not set
1212CONFIG_CRYPTO_SHA1=y
1213CONFIG_CRYPTO_SHA256=y
1214CONFIG_CRYPTO_SHA512=y
1215# CONFIG_CRYPTO_TGR192 is not set
1216# CONFIG_CRYPTO_WP512 is not set
1217
1218#
1219# Ciphers
1220#
1221CONFIG_CRYPTO_AES=y
1222# CONFIG_CRYPTO_ANUBIS is not set
1223CONFIG_CRYPTO_ARC4=y
1224CONFIG_CRYPTO_BLOWFISH=y
1225# CONFIG_CRYPTO_CAMELLIA is not set
1226# CONFIG_CRYPTO_CAST5 is not set
1227# CONFIG_CRYPTO_CAST6 is not set
1228CONFIG_CRYPTO_DES=y
1229# CONFIG_CRYPTO_FCRYPT is not set
1230# CONFIG_CRYPTO_KHAZAD is not set
1231# CONFIG_CRYPTO_SALSA20 is not set
1232# CONFIG_CRYPTO_SEED is not set
1233# CONFIG_CRYPTO_SERPENT is not set
1234# CONFIG_CRYPTO_TEA is not set
1235# CONFIG_CRYPTO_TWOFISH is not set
1236
1237#
1238# Compression
1239#
1240# CONFIG_CRYPTO_DEFLATE is not set
1241# CONFIG_CRYPTO_ZLIB is not set
1242# CONFIG_CRYPTO_LZO is not set
1243
1244#
1245# Random Number Generation
1246#
1247# CONFIG_CRYPTO_ANSI_CPRNG is not set
1248CONFIG_CRYPTO_HW=y
1249# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1250# CONFIG_CRYPTO_DEV_PPC4XX is not set
1251# CONFIG_PPC_CLOCK is not set
1252# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/configs/83xx/sbc834x_defconfig b/arch/powerpc/configs/83xx/sbc834x_defconfig
index a592b5efdc4d..3a68f861b1bd 100644
--- a/arch/powerpc/configs/83xx/sbc834x_defconfig
+++ b/arch/powerpc/configs/83xx/sbc834x_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.31-rc4 3# Linux kernel version: 2.6.31-rc5
4# Wed Jul 29 23:32:13 2009 4# Tue Aug 11 19:57:51 2009
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7 7
@@ -420,7 +420,90 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
420# CONFIG_FW_LOADER is not set 420# CONFIG_FW_LOADER is not set
421# CONFIG_SYS_HYPERVISOR is not set 421# CONFIG_SYS_HYPERVISOR is not set
422# CONFIG_CONNECTOR is not set 422# CONFIG_CONNECTOR is not set
423# CONFIG_MTD is not set 423CONFIG_MTD=y
424# CONFIG_MTD_DEBUG is not set
425CONFIG_MTD_CONCAT=y
426CONFIG_MTD_PARTITIONS=y
427# CONFIG_MTD_TESTS is not set
428# CONFIG_MTD_REDBOOT_PARTS is not set
429CONFIG_MTD_CMDLINE_PARTS=y
430CONFIG_MTD_OF_PARTS=y
431# CONFIG_MTD_AR7_PARTS is not set
432
433#
434# User Modules And Translation Layers
435#
436CONFIG_MTD_CHAR=y
437CONFIG_MTD_BLKDEVS=y
438CONFIG_MTD_BLOCK=y
439# CONFIG_FTL is not set
440# CONFIG_NFTL is not set
441# CONFIG_INFTL is not set
442# CONFIG_RFD_FTL is not set
443# CONFIG_SSFDC is not set
444# CONFIG_MTD_OOPS is not set
445
446#
447# RAM/ROM/Flash chip drivers
448#
449CONFIG_MTD_CFI=y
450# CONFIG_MTD_JEDECPROBE is not set
451CONFIG_MTD_GEN_PROBE=y
452# CONFIG_MTD_CFI_ADV_OPTIONS is not set
453CONFIG_MTD_MAP_BANK_WIDTH_1=y
454CONFIG_MTD_MAP_BANK_WIDTH_2=y
455CONFIG_MTD_MAP_BANK_WIDTH_4=y
456# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
457# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
458# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
459CONFIG_MTD_CFI_I1=y
460CONFIG_MTD_CFI_I2=y
461# CONFIG_MTD_CFI_I4 is not set
462# CONFIG_MTD_CFI_I8 is not set
463CONFIG_MTD_CFI_INTELEXT=y
464# CONFIG_MTD_CFI_AMDSTD is not set
465# CONFIG_MTD_CFI_STAA is not set
466CONFIG_MTD_CFI_UTIL=y
467# CONFIG_MTD_RAM is not set
468# CONFIG_MTD_ROM is not set
469# CONFIG_MTD_ABSENT is not set
470
471#
472# Mapping drivers for chip access
473#
474# CONFIG_MTD_COMPLEX_MAPPINGS is not set
475# CONFIG_MTD_PHYSMAP is not set
476CONFIG_MTD_PHYSMAP_OF=y
477# CONFIG_MTD_INTEL_VR_NOR is not set
478# CONFIG_MTD_PLATRAM is not set
479
480#
481# Self-contained MTD device drivers
482#
483# CONFIG_MTD_PMC551 is not set
484# CONFIG_MTD_SLRAM is not set
485# CONFIG_MTD_PHRAM is not set
486# CONFIG_MTD_MTDRAM is not set
487# CONFIG_MTD_BLOCK2MTD is not set
488
489#
490# Disk-On-Chip Device Drivers
491#
492# CONFIG_MTD_DOC2000 is not set
493# CONFIG_MTD_DOC2001 is not set
494# CONFIG_MTD_DOC2001PLUS is not set
495# CONFIG_MTD_NAND is not set
496# CONFIG_MTD_ONENAND is not set
497
498#
499# LPDDR flash memory drivers
500#
501# CONFIG_MTD_LPDDR is not set
502
503#
504# UBI - Unsorted block images
505#
506# CONFIG_MTD_UBI is not set
424CONFIG_OF_DEVICE=y 507CONFIG_OF_DEVICE=y
425CONFIG_OF_I2C=y 508CONFIG_OF_I2C=y
426CONFIG_OF_MDIO=y 509CONFIG_OF_MDIO=y
@@ -436,6 +519,7 @@ CONFIG_BLK_DEV_LOOP=y
436# CONFIG_BLK_DEV_CRYPTOLOOP is not set 519# CONFIG_BLK_DEV_CRYPTOLOOP is not set
437# CONFIG_BLK_DEV_NBD is not set 520# CONFIG_BLK_DEV_NBD is not set
438# CONFIG_BLK_DEV_SX8 is not set 521# CONFIG_BLK_DEV_SX8 is not set
522# CONFIG_BLK_DEV_UB is not set
439CONFIG_BLK_DEV_RAM=y 523CONFIG_BLK_DEV_RAM=y
440CONFIG_BLK_DEV_RAM_COUNT=16 524CONFIG_BLK_DEV_RAM_COUNT=16
441CONFIG_BLK_DEV_RAM_SIZE=32768 525CONFIG_BLK_DEV_RAM_SIZE=32768
@@ -468,9 +552,38 @@ CONFIG_HAVE_IDE=y
468# SCSI device support 552# SCSI device support
469# 553#
470# CONFIG_RAID_ATTRS is not set 554# CONFIG_RAID_ATTRS is not set
471# CONFIG_SCSI is not set 555CONFIG_SCSI=y
472# CONFIG_SCSI_DMA is not set 556CONFIG_SCSI_DMA=y
557# CONFIG_SCSI_TGT is not set
473# CONFIG_SCSI_NETLINK is not set 558# CONFIG_SCSI_NETLINK is not set
559# CONFIG_SCSI_PROC_FS is not set
560
561#
562# SCSI support type (disk, tape, CD-ROM)
563#
564CONFIG_BLK_DEV_SD=y
565# CONFIG_CHR_DEV_ST is not set
566# CONFIG_CHR_DEV_OSST is not set
567# CONFIG_BLK_DEV_SR is not set
568# CONFIG_CHR_DEV_SG is not set
569# CONFIG_CHR_DEV_SCH is not set
570# CONFIG_SCSI_MULTI_LUN is not set
571# CONFIG_SCSI_CONSTANTS is not set
572# CONFIG_SCSI_LOGGING is not set
573# CONFIG_SCSI_SCAN_ASYNC is not set
574CONFIG_SCSI_WAIT_SCAN=m
575
576#
577# SCSI Transports
578#
579# CONFIG_SCSI_SPI_ATTRS is not set
580# CONFIG_SCSI_FC_ATTRS is not set
581# CONFIG_SCSI_ISCSI_ATTRS is not set
582# CONFIG_SCSI_SAS_LIBSAS is not set
583# CONFIG_SCSI_SRP_ATTRS is not set
584# CONFIG_SCSI_LOWLEVEL is not set
585# CONFIG_SCSI_DH is not set
586# CONFIG_SCSI_OSD_INITIATOR is not set
474# CONFIG_ATA is not set 587# CONFIG_ATA is not set
475# CONFIG_MD is not set 588# CONFIG_MD is not set
476# CONFIG_FUSION is not set 589# CONFIG_FUSION is not set
@@ -578,11 +691,21 @@ CONFIG_GIANFAR=y
578# 691#
579# Enable WiMAX (Networking options) to see the WiMAX drivers 692# Enable WiMAX (Networking options) to see the WiMAX drivers
580# 693#
694
695#
696# USB Network Adapters
697#
698# CONFIG_USB_CATC is not set
699# CONFIG_USB_KAWETH is not set
700# CONFIG_USB_PEGASUS is not set
701# CONFIG_USB_RTL8150 is not set
702# CONFIG_USB_USBNET is not set
581# CONFIG_WAN is not set 703# CONFIG_WAN is not set
582# CONFIG_FDDI is not set 704# CONFIG_FDDI is not set
583# CONFIG_HIPPI is not set 705# CONFIG_HIPPI is not set
584# CONFIG_PPP is not set 706# CONFIG_PPP is not set
585# CONFIG_SLIP is not set 707# CONFIG_SLIP is not set
708# CONFIG_NET_FC is not set
586# CONFIG_NETCONSOLE is not set 709# CONFIG_NETCONSOLE is not set
587# CONFIG_NETPOLL is not set 710# CONFIG_NETPOLL is not set
588# CONFIG_NET_POLL_CONTROLLER is not set 711# CONFIG_NET_POLL_CONTROLLER is not set
@@ -633,9 +756,9 @@ CONFIG_DEVKMEM=y
633# 756#
634CONFIG_SERIAL_8250=y 757CONFIG_SERIAL_8250=y
635CONFIG_SERIAL_8250_CONSOLE=y 758CONFIG_SERIAL_8250_CONSOLE=y
636CONFIG_SERIAL_8250_PCI=y 759# CONFIG_SERIAL_8250_PCI is not set
637CONFIG_SERIAL_8250_NR_UARTS=4 760CONFIG_SERIAL_8250_NR_UARTS=2
638CONFIG_SERIAL_8250_RUNTIME_UARTS=4 761CONFIG_SERIAL_8250_RUNTIME_UARTS=2
639# CONFIG_SERIAL_8250_EXTENDED is not set 762# CONFIG_SERIAL_8250_EXTENDED is not set
640 763
641# 764#
@@ -700,6 +823,7 @@ CONFIG_I2C_MPC=y
700# 823#
701# CONFIG_I2C_PARPORT_LIGHT is not set 824# CONFIG_I2C_PARPORT_LIGHT is not set
702# CONFIG_I2C_TAOS_EVM is not set 825# CONFIG_I2C_TAOS_EVM is not set
826# CONFIG_I2C_TINY_USB is not set
703 827
704# 828#
705# Graphics adapter I2C/DDC channel drivers 829# Graphics adapter I2C/DDC channel drivers
@@ -814,6 +938,11 @@ CONFIG_WATCHDOG=y
814# 938#
815# CONFIG_PCIPCWATCHDOG is not set 939# CONFIG_PCIPCWATCHDOG is not set
816# CONFIG_WDTPCI is not set 940# CONFIG_WDTPCI is not set
941
942#
943# USB-based Watchdog Cards
944#
945# CONFIG_USBPCWATCHDOG is not set
817CONFIG_SSB_POSSIBLE=y 946CONFIG_SSB_POSSIBLE=y
818 947
819# 948#
@@ -856,12 +985,134 @@ CONFIG_HID_SUPPORT=y
856CONFIG_HID=y 985CONFIG_HID=y
857# CONFIG_HID_DEBUG is not set 986# CONFIG_HID_DEBUG is not set
858# CONFIG_HIDRAW is not set 987# CONFIG_HIDRAW is not set
988
989#
990# USB Input Devices
991#
992# CONFIG_USB_HID is not set
859# CONFIG_HID_PID is not set 993# CONFIG_HID_PID is not set
860 994
861# 995#
996# USB HID Boot Protocol drivers
997#
998# CONFIG_USB_KBD is not set
999# CONFIG_USB_MOUSE is not set
1000
1001#
862# Special HID drivers 1002# Special HID drivers
863# 1003#
864# CONFIG_USB_SUPPORT is not set 1004CONFIG_USB_SUPPORT=y
1005CONFIG_USB_ARCH_HAS_HCD=y
1006CONFIG_USB_ARCH_HAS_OHCI=y
1007CONFIG_USB_ARCH_HAS_EHCI=y
1008CONFIG_USB=y
1009# CONFIG_USB_DEBUG is not set
1010# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
1011
1012#
1013# Miscellaneous USB options
1014#
1015CONFIG_USB_DEVICEFS=y
1016CONFIG_USB_DEVICE_CLASS=y
1017# CONFIG_USB_DYNAMIC_MINORS is not set
1018# CONFIG_USB_OTG is not set
1019# CONFIG_USB_OTG_WHITELIST is not set
1020# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1021CONFIG_USB_MON=y
1022# CONFIG_USB_WUSB is not set
1023# CONFIG_USB_WUSB_CBAF is not set
1024
1025#
1026# USB Host Controller Drivers
1027#
1028# CONFIG_USB_C67X00_HCD is not set
1029# CONFIG_USB_XHCI_HCD is not set
1030CONFIG_USB_EHCI_HCD=y
1031CONFIG_USB_EHCI_ROOT_HUB_TT=y
1032# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1033CONFIG_USB_EHCI_FSL=y
1034CONFIG_USB_EHCI_HCD_PPC_OF=y
1035# CONFIG_USB_OXU210HP_HCD is not set
1036# CONFIG_USB_ISP116X_HCD is not set
1037# CONFIG_USB_ISP1760_HCD is not set
1038# CONFIG_USB_OHCI_HCD is not set
1039# CONFIG_USB_UHCI_HCD is not set
1040# CONFIG_USB_SL811_HCD is not set
1041# CONFIG_USB_R8A66597_HCD is not set
1042# CONFIG_USB_WHCI_HCD is not set
1043# CONFIG_USB_HWA_HCD is not set
1044
1045#
1046# USB Device Class drivers
1047#
1048# CONFIG_USB_ACM is not set
1049# CONFIG_USB_PRINTER is not set
1050# CONFIG_USB_WDM is not set
1051# CONFIG_USB_TMC is not set
1052
1053#
1054# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
1055#
1056
1057#
1058# also be needed; see USB_STORAGE Help for more info
1059#
1060CONFIG_USB_STORAGE=y
1061# CONFIG_USB_STORAGE_DEBUG is not set
1062# CONFIG_USB_STORAGE_DATAFAB is not set
1063# CONFIG_USB_STORAGE_FREECOM is not set
1064# CONFIG_USB_STORAGE_ISD200 is not set
1065# CONFIG_USB_STORAGE_USBAT is not set
1066# CONFIG_USB_STORAGE_SDDR09 is not set
1067# CONFIG_USB_STORAGE_SDDR55 is not set
1068# CONFIG_USB_STORAGE_JUMPSHOT is not set
1069# CONFIG_USB_STORAGE_ALAUDA is not set
1070# CONFIG_USB_STORAGE_ONETOUCH is not set
1071# CONFIG_USB_STORAGE_KARMA is not set
1072# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
1073# CONFIG_USB_LIBUSUAL is not set
1074
1075#
1076# USB Imaging devices
1077#
1078# CONFIG_USB_MDC800 is not set
1079# CONFIG_USB_MICROTEK is not set
1080
1081#
1082# USB port drivers
1083#
1084# CONFIG_USB_SERIAL is not set
1085
1086#
1087# USB Miscellaneous drivers
1088#
1089# CONFIG_USB_EMI62 is not set
1090# CONFIG_USB_EMI26 is not set
1091# CONFIG_USB_ADUTUX is not set
1092# CONFIG_USB_SEVSEG is not set
1093# CONFIG_USB_RIO500 is not set
1094# CONFIG_USB_LEGOTOWER is not set
1095# CONFIG_USB_LCD is not set
1096# CONFIG_USB_BERRY_CHARGE is not set
1097# CONFIG_USB_LED is not set
1098# CONFIG_USB_CYPRESS_CY7C63 is not set
1099# CONFIG_USB_CYTHERM is not set
1100# CONFIG_USB_IDMOUSE is not set
1101# CONFIG_USB_FTDI_ELAN is not set
1102# CONFIG_USB_APPLEDISPLAY is not set
1103# CONFIG_USB_SISUSBVGA is not set
1104# CONFIG_USB_LD is not set
1105# CONFIG_USB_TRANCEVIBRATOR is not set
1106# CONFIG_USB_IOWARRIOR is not set
1107# CONFIG_USB_TEST is not set
1108# CONFIG_USB_ISIGHTFW is not set
1109# CONFIG_USB_VST is not set
1110# CONFIG_USB_GADGET is not set
1111
1112#
1113# OTG and related infrastructure
1114#
1115# CONFIG_NOP_USB_XCEIV is not set
865# CONFIG_UWB is not set 1116# CONFIG_UWB is not set
866# CONFIG_MMC is not set 1117# CONFIG_MMC is not set
867# CONFIG_MEMSTICK is not set 1118# CONFIG_MEMSTICK is not set
@@ -882,9 +1133,14 @@ CONFIG_HID=y
882# 1133#
883# File systems 1134# File systems
884# 1135#
885# CONFIG_EXT2_FS is not set 1136CONFIG_EXT2_FS=y
886# CONFIG_EXT3_FS is not set 1137# CONFIG_EXT2_FS_XATTR is not set
1138# CONFIG_EXT2_FS_XIP is not set
1139CONFIG_EXT3_FS=y
1140# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
1141# CONFIG_EXT3_FS_XATTR is not set
887# CONFIG_EXT4_FS is not set 1142# CONFIG_EXT4_FS is not set
1143CONFIG_JBD=y
888# CONFIG_REISERFS_FS is not set 1144# CONFIG_REISERFS_FS is not set
889# CONFIG_JFS_FS is not set 1145# CONFIG_JFS_FS is not set
890# CONFIG_FS_POSIX_ACL is not set 1146# CONFIG_FS_POSIX_ACL is not set
@@ -940,6 +1196,7 @@ CONFIG_MISC_FILESYSTEMS=y
940# CONFIG_BEFS_FS is not set 1196# CONFIG_BEFS_FS is not set
941# CONFIG_BFS_FS is not set 1197# CONFIG_BFS_FS is not set
942# CONFIG_EFS_FS is not set 1198# CONFIG_EFS_FS is not set
1199# CONFIG_JFFS2_FS is not set
943# CONFIG_CRAMFS is not set 1200# CONFIG_CRAMFS is not set
944# CONFIG_SQUASHFS is not set 1201# CONFIG_SQUASHFS is not set
945# CONFIG_VXFS_FS is not set 1202# CONFIG_VXFS_FS is not set
@@ -977,7 +1234,46 @@ CONFIG_RPCSEC_GSS_KRB5=y
977# 1234#
978# CONFIG_PARTITION_ADVANCED is not set 1235# CONFIG_PARTITION_ADVANCED is not set
979CONFIG_MSDOS_PARTITION=y 1236CONFIG_MSDOS_PARTITION=y
980# CONFIG_NLS is not set 1237CONFIG_NLS=y
1238CONFIG_NLS_DEFAULT="iso8859-1"
1239# CONFIG_NLS_CODEPAGE_437 is not set
1240# CONFIG_NLS_CODEPAGE_737 is not set
1241# CONFIG_NLS_CODEPAGE_775 is not set
1242# CONFIG_NLS_CODEPAGE_850 is not set
1243# CONFIG_NLS_CODEPAGE_852 is not set
1244# CONFIG_NLS_CODEPAGE_855 is not set
1245# CONFIG_NLS_CODEPAGE_857 is not set
1246# CONFIG_NLS_CODEPAGE_860 is not set
1247# CONFIG_NLS_CODEPAGE_861 is not set
1248# CONFIG_NLS_CODEPAGE_862 is not set
1249# CONFIG_NLS_CODEPAGE_863 is not set
1250# CONFIG_NLS_CODEPAGE_864 is not set
1251# CONFIG_NLS_CODEPAGE_865 is not set
1252# CONFIG_NLS_CODEPAGE_866 is not set
1253# CONFIG_NLS_CODEPAGE_869 is not set
1254# CONFIG_NLS_CODEPAGE_936 is not set
1255# CONFIG_NLS_CODEPAGE_950 is not set
1256# CONFIG_NLS_CODEPAGE_932 is not set
1257# CONFIG_NLS_CODEPAGE_949 is not set
1258# CONFIG_NLS_CODEPAGE_874 is not set
1259# CONFIG_NLS_ISO8859_8 is not set
1260# CONFIG_NLS_CODEPAGE_1250 is not set
1261# CONFIG_NLS_CODEPAGE_1251 is not set
1262# CONFIG_NLS_ASCII is not set
1263# CONFIG_NLS_ISO8859_1 is not set
1264# CONFIG_NLS_ISO8859_2 is not set
1265# CONFIG_NLS_ISO8859_3 is not set
1266# CONFIG_NLS_ISO8859_4 is not set
1267# CONFIG_NLS_ISO8859_5 is not set
1268# CONFIG_NLS_ISO8859_6 is not set
1269# CONFIG_NLS_ISO8859_7 is not set
1270# CONFIG_NLS_ISO8859_9 is not set
1271# CONFIG_NLS_ISO8859_13 is not set
1272# CONFIG_NLS_ISO8859_14 is not set
1273# CONFIG_NLS_ISO8859_15 is not set
1274# CONFIG_NLS_KOI8_R is not set
1275# CONFIG_NLS_KOI8_U is not set
1276# CONFIG_NLS_UTF8 is not set
981# CONFIG_DLM is not set 1277# CONFIG_DLM is not set
982# CONFIG_BINARY_PRINTF is not set 1278# CONFIG_BINARY_PRINTF is not set
983 1279
diff --git a/arch/powerpc/configs/mgcoge_defconfig b/arch/powerpc/configs/mgcoge_defconfig
index e9491c1c3f31..30b68bfacebf 100644
--- a/arch/powerpc/configs/mgcoge_defconfig
+++ b/arch/powerpc/configs/mgcoge_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.31-rc4 3# Linux kernel version: 2.6.31-rc5
4# Wed Jul 29 23:31:51 2009 4# Fri Aug 7 08:19:15 2009
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7 7
@@ -158,6 +158,7 @@ CONFIG_BASE_SMALL=0
158# CONFIG_MODULES is not set 158# CONFIG_MODULES is not set
159CONFIG_BLOCK=y 159CONFIG_BLOCK=y
160CONFIG_LBDAF=y 160CONFIG_LBDAF=y
161CONFIG_BLK_DEV_BSG=y
161# CONFIG_BLK_DEV_INTEGRITY is not set 162# CONFIG_BLK_DEV_INTEGRITY is not set
162 163
163# 164#
@@ -506,6 +507,7 @@ CONFIG_MTD_PHYSMAP_OF=y
506# CONFIG_MTD_UBI is not set 507# CONFIG_MTD_UBI is not set
507CONFIG_OF_DEVICE=y 508CONFIG_OF_DEVICE=y
508CONFIG_OF_GPIO=y 509CONFIG_OF_GPIO=y
510CONFIG_OF_I2C=y
509CONFIG_OF_MDIO=y 511CONFIG_OF_MDIO=y
510# CONFIG_PARPORT is not set 512# CONFIG_PARPORT is not set
511CONFIG_BLK_DEV=y 513CONFIG_BLK_DEV=y
@@ -582,7 +584,8 @@ CONFIG_PHYLIB=y
582# CONFIG_STE10XP is not set 584# CONFIG_STE10XP is not set
583# CONFIG_LSI_ET1011C_PHY is not set 585# CONFIG_LSI_ET1011C_PHY is not set
584CONFIG_FIXED_PHY=y 586CONFIG_FIXED_PHY=y
585# CONFIG_MDIO_BITBANG is not set 587CONFIG_MDIO_BITBANG=y
588# CONFIG_MDIO_GPIO is not set
586CONFIG_NET_ETHERNET=y 589CONFIG_NET_ETHERNET=y
587CONFIG_MII=y 590CONFIG_MII=y
588# CONFIG_MACE is not set 591# CONFIG_MACE is not set
@@ -608,8 +611,8 @@ CONFIG_MII=y
608# CONFIG_ATL2 is not set 611# CONFIG_ATL2 is not set
609CONFIG_FS_ENET=y 612CONFIG_FS_ENET=y
610CONFIG_FS_ENET_HAS_SCC=y 613CONFIG_FS_ENET_HAS_SCC=y
611# CONFIG_FS_ENET_HAS_FCC is not set 614CONFIG_FS_ENET_HAS_FCC=y
612# CONFIG_FS_ENET_MDIO_FCC is not set 615CONFIG_FS_ENET_MDIO_FCC=y
613# CONFIG_NETDEV_1000 is not set 616# CONFIG_NETDEV_1000 is not set
614# CONFIG_NETDEV_10000 is not set 617# CONFIG_NETDEV_10000 is not set
615# CONFIG_TR is not set 618# CONFIG_TR is not set
@@ -680,7 +683,68 @@ CONFIG_HW_RANDOM=y
680# CONFIG_APPLICOM is not set 683# CONFIG_APPLICOM is not set
681# CONFIG_RAW_DRIVER is not set 684# CONFIG_RAW_DRIVER is not set
682CONFIG_DEVPORT=y 685CONFIG_DEVPORT=y
683# CONFIG_I2C is not set 686CONFIG_I2C=y
687CONFIG_I2C_BOARDINFO=y
688CONFIG_I2C_CHARDEV=y
689CONFIG_I2C_HELPER_AUTO=y
690
691#
692# I2C Hardware Bus support
693#
694
695#
696# PC SMBus host controller drivers
697#
698# CONFIG_I2C_ALI1535 is not set
699# CONFIG_I2C_ALI15X3 is not set
700# CONFIG_I2C_AMD756 is not set
701# CONFIG_I2C_AMD8111 is not set
702# CONFIG_I2C_I801 is not set
703# CONFIG_I2C_ISCH is not set
704# CONFIG_I2C_PIIX4 is not set
705# CONFIG_I2C_NFORCE2 is not set
706# CONFIG_I2C_SIS5595 is not set
707# CONFIG_I2C_SIS630 is not set
708# CONFIG_I2C_SIS96X is not set
709# CONFIG_I2C_VIAPRO is not set
710
711#
712# Mac SMBus host controller drivers
713#
714# CONFIG_I2C_POWERMAC is not set
715
716#
717# I2C system bus drivers (mostly embedded / system-on-chip)
718#
719CONFIG_I2C_CPM=y
720# CONFIG_I2C_DESIGNWARE is not set
721# CONFIG_I2C_GPIO is not set
722# CONFIG_I2C_MPC is not set
723# CONFIG_I2C_SIMTEC is not set
724
725#
726# External I2C/SMBus adapter drivers
727#
728# CONFIG_I2C_PARPORT_LIGHT is not set
729
730#
731# Graphics adapter I2C/DDC channel drivers
732#
733# CONFIG_I2C_VOODOO3 is not set
734
735#
736# Other I2C/SMBus bus drivers
737#
738# CONFIG_I2C_PCA_PLATFORM is not set
739
740#
741# Miscellaneous I2C Chip support
742#
743# CONFIG_PCF8575 is not set
744# CONFIG_I2C_DEBUG_CORE is not set
745# CONFIG_I2C_DEBUG_ALGO is not set
746# CONFIG_I2C_DEBUG_BUS is not set
747# CONFIG_I2C_DEBUG_CHIP is not set
684# CONFIG_SPI is not set 748# CONFIG_SPI is not set
685 749
686# 750#
@@ -699,6 +763,9 @@ CONFIG_GPIOLIB=y
699# 763#
700# I2C GPIO expanders: 764# I2C GPIO expanders:
701# 765#
766# CONFIG_GPIO_MAX732X is not set
767# CONFIG_GPIO_PCA953X is not set
768# CONFIG_GPIO_PCF857X is not set
702 769
703# 770#
704# PCI GPIO expanders: 771# PCI GPIO expanders:
@@ -727,7 +794,14 @@ CONFIG_SSB_POSSIBLE=y
727# CONFIG_MFD_CORE is not set 794# CONFIG_MFD_CORE is not set
728# CONFIG_MFD_SM501 is not set 795# CONFIG_MFD_SM501 is not set
729# CONFIG_HTC_PASIC3 is not set 796# CONFIG_HTC_PASIC3 is not set
797# CONFIG_TPS65010 is not set
798# CONFIG_TWL4030_CORE is not set
730# CONFIG_MFD_TMIO is not set 799# CONFIG_MFD_TMIO is not set
800# CONFIG_PMIC_DA903X is not set
801# CONFIG_MFD_WM8400 is not set
802# CONFIG_MFD_WM8350_I2C is not set
803# CONFIG_MFD_PCF50633 is not set
804# CONFIG_AB3100_CORE is not set
731# CONFIG_REGULATOR is not set 805# CONFIG_REGULATOR is not set
732# CONFIG_MEDIA_SUPPORT is not set 806# CONFIG_MEDIA_SUPPORT is not set
733 807
diff --git a/arch/powerpc/configs/mpc85xx_defconfig b/arch/powerpc/configs/mpc85xx_defconfig
index ada595898af1..ee6acc6557f8 100644
--- a/arch/powerpc/configs/mpc85xx_defconfig
+++ b/arch/powerpc/configs/mpc85xx_defconfig
@@ -203,6 +203,7 @@ CONFIG_MPC85xx_CDS=y
203CONFIG_MPC85xx_MDS=y 203CONFIG_MPC85xx_MDS=y
204CONFIG_MPC8536_DS=y 204CONFIG_MPC8536_DS=y
205CONFIG_MPC85xx_DS=y 205CONFIG_MPC85xx_DS=y
206CONFIG_MPC85xx_RDB=y
206CONFIG_SOCRATES=y 207CONFIG_SOCRATES=y
207CONFIG_KSI8560=y 208CONFIG_KSI8560=y
208# CONFIG_XES_MPC85xx is not set 209# CONFIG_XES_MPC85xx is not set
diff --git a/arch/powerpc/include/asm/agp.h b/arch/powerpc/include/asm/agp.h
index 86455c4c31ee..416e12c2d505 100644
--- a/arch/powerpc/include/asm/agp.h
+++ b/arch/powerpc/include/asm/agp.h
@@ -8,10 +8,6 @@
8#define unmap_page_from_agp(page) 8#define unmap_page_from_agp(page)
9#define flush_agp_cache() mb() 9#define flush_agp_cache() mb()
10 10
11/* Convert a physical address to an address suitable for the GART. */
12#define phys_to_gart(x) (x)
13#define gart_to_phys(x) (x)
14
15/* GATT allocation. Returns/accepts GATT kernel virtual address. */ 11/* GATT allocation. Returns/accepts GATT kernel virtual address. */
16#define alloc_gatt_pages(order) \ 12#define alloc_gatt_pages(order) \
17 ((char *)__get_free_pages(GFP_KERNEL, (order))) 13 ((char *)__get_free_pages(GFP_KERNEL, (order)))
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 897eade3afbe..56f2f2ea5631 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -56,174 +56,102 @@
56#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) 56#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
57#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) 57#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
58 58
59/* Macro for generating the ***_bits() functions */
60#define DEFINE_BITOP(fn, op, prefix, postfix) \
61static __inline__ void fn(unsigned long mask, \
62 volatile unsigned long *_p) \
63{ \
64 unsigned long old; \
65 unsigned long *p = (unsigned long *)_p; \
66 __asm__ __volatile__ ( \
67 prefix \
68"1:" PPC_LLARX "%0,0,%3\n" \
69 stringify_in_c(op) "%0,%0,%2\n" \
70 PPC405_ERR77(0,%3) \
71 PPC_STLCX "%0,0,%3\n" \
72 "bne- 1b\n" \
73 postfix \
74 : "=&r" (old), "+m" (*p) \
75 : "r" (mask), "r" (p) \
76 : "cc", "memory"); \
77}
78
79DEFINE_BITOP(set_bits, or, "", "")
80DEFINE_BITOP(clear_bits, andc, "", "")
81DEFINE_BITOP(clear_bits_unlock, andc, LWSYNC_ON_SMP, "")
82DEFINE_BITOP(change_bits, xor, "", "")
83
59static __inline__ void set_bit(int nr, volatile unsigned long *addr) 84static __inline__ void set_bit(int nr, volatile unsigned long *addr)
60{ 85{
61 unsigned long old; 86 set_bits(BITOP_MASK(nr), addr + BITOP_WORD(nr));
62 unsigned long mask = BITOP_MASK(nr);
63 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
64
65 __asm__ __volatile__(
66"1:" PPC_LLARX "%0,0,%3 # set_bit\n"
67 "or %0,%0,%2\n"
68 PPC405_ERR77(0,%3)
69 PPC_STLCX "%0,0,%3\n"
70 "bne- 1b"
71 : "=&r" (old), "+m" (*p)
72 : "r" (mask), "r" (p)
73 : "cc" );
74} 87}
75 88
76static __inline__ void clear_bit(int nr, volatile unsigned long *addr) 89static __inline__ void clear_bit(int nr, volatile unsigned long *addr)
77{ 90{
78 unsigned long old; 91 clear_bits(BITOP_MASK(nr), addr + BITOP_WORD(nr));
79 unsigned long mask = BITOP_MASK(nr);
80 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
81
82 __asm__ __volatile__(
83"1:" PPC_LLARX "%0,0,%3 # clear_bit\n"
84 "andc %0,%0,%2\n"
85 PPC405_ERR77(0,%3)
86 PPC_STLCX "%0,0,%3\n"
87 "bne- 1b"
88 : "=&r" (old), "+m" (*p)
89 : "r" (mask), "r" (p)
90 : "cc" );
91} 92}
92 93
93static __inline__ void clear_bit_unlock(int nr, volatile unsigned long *addr) 94static __inline__ void clear_bit_unlock(int nr, volatile unsigned long *addr)
94{ 95{
95 unsigned long old; 96 clear_bits_unlock(BITOP_MASK(nr), addr + BITOP_WORD(nr));
96 unsigned long mask = BITOP_MASK(nr);
97 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
98
99 __asm__ __volatile__(
100 LWSYNC_ON_SMP
101"1:" PPC_LLARX "%0,0,%3 # clear_bit_unlock\n"
102 "andc %0,%0,%2\n"
103 PPC405_ERR77(0,%3)
104 PPC_STLCX "%0,0,%3\n"
105 "bne- 1b"
106 : "=&r" (old), "+m" (*p)
107 : "r" (mask), "r" (p)
108 : "cc", "memory");
109} 97}
110 98
111static __inline__ void change_bit(int nr, volatile unsigned long *addr) 99static __inline__ void change_bit(int nr, volatile unsigned long *addr)
112{ 100{
113 unsigned long old; 101 change_bits(BITOP_MASK(nr), addr + BITOP_WORD(nr));
114 unsigned long mask = BITOP_MASK(nr); 102}
115 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); 103
116 104/* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output
117 __asm__ __volatile__( 105 * operands. */
118"1:" PPC_LLARX "%0,0,%3 # change_bit\n" 106#define DEFINE_TESTOP(fn, op, prefix, postfix) \
119 "xor %0,%0,%2\n" 107static __inline__ unsigned long fn( \
120 PPC405_ERR77(0,%3) 108 unsigned long mask, \
121 PPC_STLCX "%0,0,%3\n" 109 volatile unsigned long *_p) \
122 "bne- 1b" 110{ \
123 : "=&r" (old), "+m" (*p) 111 unsigned long old, t; \
124 : "r" (mask), "r" (p) 112 unsigned long *p = (unsigned long *)_p; \
125 : "cc" ); 113 __asm__ __volatile__ ( \
114 prefix \
115"1:" PPC_LLARX "%0,0,%3\n" \
116 stringify_in_c(op) "%1,%0,%2\n" \
117 PPC405_ERR77(0,%3) \
118 PPC_STLCX "%1,0,%3\n" \
119 "bne- 1b\n" \
120 postfix \
121 : "=&r" (old), "=&r" (t) \
122 : "r" (mask), "r" (p) \
123 : "cc", "memory"); \
124 return (old & mask); \
126} 125}
127 126
127DEFINE_TESTOP(test_and_set_bits, or, LWSYNC_ON_SMP, ISYNC_ON_SMP)
128DEFINE_TESTOP(test_and_set_bits_lock, or, "", ISYNC_ON_SMP)
129DEFINE_TESTOP(test_and_clear_bits, andc, LWSYNC_ON_SMP, ISYNC_ON_SMP)
130DEFINE_TESTOP(test_and_change_bits, xor, LWSYNC_ON_SMP, ISYNC_ON_SMP)
131
128static __inline__ int test_and_set_bit(unsigned long nr, 132static __inline__ int test_and_set_bit(unsigned long nr,
129 volatile unsigned long *addr) 133 volatile unsigned long *addr)
130{ 134{
131 unsigned long old, t; 135 return test_and_set_bits(BITOP_MASK(nr), addr + BITOP_WORD(nr)) != 0;
132 unsigned long mask = BITOP_MASK(nr);
133 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
134
135 __asm__ __volatile__(
136 LWSYNC_ON_SMP
137"1:" PPC_LLARX "%0,0,%3 # test_and_set_bit\n"
138 "or %1,%0,%2 \n"
139 PPC405_ERR77(0,%3)
140 PPC_STLCX "%1,0,%3 \n"
141 "bne- 1b"
142 ISYNC_ON_SMP
143 : "=&r" (old), "=&r" (t)
144 : "r" (mask), "r" (p)
145 : "cc", "memory");
146
147 return (old & mask) != 0;
148} 136}
149 137
150static __inline__ int test_and_set_bit_lock(unsigned long nr, 138static __inline__ int test_and_set_bit_lock(unsigned long nr,
151 volatile unsigned long *addr) 139 volatile unsigned long *addr)
152{ 140{
153 unsigned long old, t; 141 return test_and_set_bits_lock(BITOP_MASK(nr),
154 unsigned long mask = BITOP_MASK(nr); 142 addr + BITOP_WORD(nr)) != 0;
155 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
156
157 __asm__ __volatile__(
158"1:" PPC_LLARX "%0,0,%3 # test_and_set_bit_lock\n"
159 "or %1,%0,%2 \n"
160 PPC405_ERR77(0,%3)
161 PPC_STLCX "%1,0,%3 \n"
162 "bne- 1b"
163 ISYNC_ON_SMP
164 : "=&r" (old), "=&r" (t)
165 : "r" (mask), "r" (p)
166 : "cc", "memory");
167
168 return (old & mask) != 0;
169} 143}
170 144
171static __inline__ int test_and_clear_bit(unsigned long nr, 145static __inline__ int test_and_clear_bit(unsigned long nr,
172 volatile unsigned long *addr) 146 volatile unsigned long *addr)
173{ 147{
174 unsigned long old, t; 148 return test_and_clear_bits(BITOP_MASK(nr), addr + BITOP_WORD(nr)) != 0;
175 unsigned long mask = BITOP_MASK(nr);
176 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
177
178 __asm__ __volatile__(
179 LWSYNC_ON_SMP
180"1:" PPC_LLARX "%0,0,%3 # test_and_clear_bit\n"
181 "andc %1,%0,%2 \n"
182 PPC405_ERR77(0,%3)
183 PPC_STLCX "%1,0,%3 \n"
184 "bne- 1b"
185 ISYNC_ON_SMP
186 : "=&r" (old), "=&r" (t)
187 : "r" (mask), "r" (p)
188 : "cc", "memory");
189
190 return (old & mask) != 0;
191} 149}
192 150
193static __inline__ int test_and_change_bit(unsigned long nr, 151static __inline__ int test_and_change_bit(unsigned long nr,
194 volatile unsigned long *addr) 152 volatile unsigned long *addr)
195{ 153{
196 unsigned long old, t; 154 return test_and_change_bits(BITOP_MASK(nr), addr + BITOP_WORD(nr)) != 0;
197 unsigned long mask = BITOP_MASK(nr);
198 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
199
200 __asm__ __volatile__(
201 LWSYNC_ON_SMP
202"1:" PPC_LLARX "%0,0,%3 # test_and_change_bit\n"
203 "xor %1,%0,%2 \n"
204 PPC405_ERR77(0,%3)
205 PPC_STLCX "%1,0,%3 \n"
206 "bne- 1b"
207 ISYNC_ON_SMP
208 : "=&r" (old), "=&r" (t)
209 : "r" (mask), "r" (p)
210 : "cc", "memory");
211
212 return (old & mask) != 0;
213}
214
215static __inline__ void set_bits(unsigned long mask, unsigned long *addr)
216{
217 unsigned long old;
218
219 __asm__ __volatile__(
220"1:" PPC_LLARX "%0,0,%3 # set_bits\n"
221 "or %0,%0,%2\n"
222 PPC_STLCX "%0,0,%3\n"
223 "bne- 1b"
224 : "=&r" (old), "+m" (*addr)
225 : "r" (mask), "r" (addr)
226 : "cc");
227} 155}
228 156
229#include <asm-generic/bitops/non-atomic.h> 157#include <asm-generic/bitops/non-atomic.h>
diff --git a/arch/powerpc/include/asm/cell-regs.h b/arch/powerpc/include/asm/cell-regs.h
index fd6fd00434ef..fdf64fd25950 100644
--- a/arch/powerpc/include/asm/cell-regs.h
+++ b/arch/powerpc/include/asm/cell-regs.h
@@ -303,6 +303,17 @@ struct cbe_mic_tm_regs {
303extern struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np); 303extern struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np);
304extern struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu); 304extern struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu);
305 305
306
307/* Cell page table entries */
308#define CBE_IOPTE_PP_W 0x8000000000000000ul /* protection: write */
309#define CBE_IOPTE_PP_R 0x4000000000000000ul /* protection: read */
310#define CBE_IOPTE_M 0x2000000000000000ul /* coherency required */
311#define CBE_IOPTE_SO_R 0x1000000000000000ul /* ordering: writes */
312#define CBE_IOPTE_SO_RW 0x1800000000000000ul /* ordering: r & w */
313#define CBE_IOPTE_RPN_Mask 0x07fffffffffff000ul /* RPN */
314#define CBE_IOPTE_H 0x0000000000000800ul /* cache hint */
315#define CBE_IOPTE_IOID_Mask 0x00000000000007fful /* ioid */
316
306/* some utility functions to deal with SMT */ 317/* some utility functions to deal with SMT */
307extern u32 cbe_get_hw_thread_id(int cpu); 318extern u32 cbe_get_hw_thread_id(int cpu);
308extern u32 cbe_cpu_to_node(int cpu); 319extern u32 cbe_cpu_to_node(int cpu);
diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
index fb11b0c459b8..a8e18447c62b 100644
--- a/arch/powerpc/include/asm/cputhreads.h
+++ b/arch/powerpc/include/asm/cputhreads.h
@@ -5,6 +5,15 @@
5 5
6/* 6/*
7 * Mapping of threads to cores 7 * Mapping of threads to cores
8 *
9 * Note: This implementation is limited to a power of 2 number of
10 * threads per core and the same number for each core in the system
11 * (though it would work if some processors had less threads as long
12 * as the CPU numbers are still allocated, just not brought offline).
13 *
14 * However, the API allows for a different implementation in the future
15 * if needed, as long as you only use the functions and not the variables
16 * directly.
8 */ 17 */
9 18
10#ifdef CONFIG_SMP 19#ifdef CONFIG_SMP
@@ -67,5 +76,12 @@ static inline int cpu_first_thread_in_core(int cpu)
67 return cpu & ~(threads_per_core - 1); 76 return cpu & ~(threads_per_core - 1);
68} 77}
69 78
79static inline int cpu_last_thread_in_core(int cpu)
80{
81 return cpu | (threads_per_core - 1);
82}
83
84
85
70#endif /* _ASM_POWERPC_CPUTHREADS_H */ 86#endif /* _ASM_POWERPC_CPUTHREADS_H */
71 87
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index e3e06e0f7fc0..9dade15d1ab4 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -6,7 +6,7 @@
6#ifndef _ASM_POWERPC_DEVICE_H 6#ifndef _ASM_POWERPC_DEVICE_H
7#define _ASM_POWERPC_DEVICE_H 7#define _ASM_POWERPC_DEVICE_H
8 8
9struct dma_mapping_ops; 9struct dma_map_ops;
10struct device_node; 10struct device_node;
11 11
12struct dev_archdata { 12struct dev_archdata {
@@ -14,8 +14,11 @@ struct dev_archdata {
14 struct device_node *of_node; 14 struct device_node *of_node;
15 15
16 /* DMA operations on that device */ 16 /* DMA operations on that device */
17 struct dma_mapping_ops *dma_ops; 17 struct dma_map_ops *dma_ops;
18 void *dma_data; 18 void *dma_data;
19#ifdef CONFIG_SWIOTLB
20 dma_addr_t max_direct_dma_addr;
21#endif
19}; 22};
20 23
21static inline void dev_archdata_set_node(struct dev_archdata *ad, 24static inline void dev_archdata_set_node(struct dev_archdata *ad,
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 0c34371ec49c..cb2ca41dd526 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -14,6 +14,7 @@
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/scatterlist.h> 15#include <linux/scatterlist.h>
16#include <linux/dma-attrs.h> 16#include <linux/dma-attrs.h>
17#include <linux/dma-debug.h>
17#include <asm/io.h> 18#include <asm/io.h>
18#include <asm/swiotlb.h> 19#include <asm/swiotlb.h>
19 20
@@ -64,58 +65,14 @@ static inline unsigned long device_to_mask(struct device *dev)
64} 65}
65 66
66/* 67/*
67 * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
68 */
69struct dma_mapping_ops {
70 void * (*alloc_coherent)(struct device *dev, size_t size,
71 dma_addr_t *dma_handle, gfp_t flag);
72 void (*free_coherent)(struct device *dev, size_t size,
73 void *vaddr, dma_addr_t dma_handle);
74 int (*map_sg)(struct device *dev, struct scatterlist *sg,
75 int nents, enum dma_data_direction direction,
76 struct dma_attrs *attrs);
77 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
78 int nents, enum dma_data_direction direction,
79 struct dma_attrs *attrs);
80 int (*dma_supported)(struct device *dev, u64 mask);
81 int (*set_dma_mask)(struct device *dev, u64 dma_mask);
82 dma_addr_t (*map_page)(struct device *dev, struct page *page,
83 unsigned long offset, size_t size,
84 enum dma_data_direction direction,
85 struct dma_attrs *attrs);
86 void (*unmap_page)(struct device *dev,
87 dma_addr_t dma_address, size_t size,
88 enum dma_data_direction direction,
89 struct dma_attrs *attrs);
90 int (*addr_needs_map)(struct device *dev, dma_addr_t addr,
91 size_t size);
92#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
93 void (*sync_single_range_for_cpu)(struct device *hwdev,
94 dma_addr_t dma_handle, unsigned long offset,
95 size_t size,
96 enum dma_data_direction direction);
97 void (*sync_single_range_for_device)(struct device *hwdev,
98 dma_addr_t dma_handle, unsigned long offset,
99 size_t size,
100 enum dma_data_direction direction);
101 void (*sync_sg_for_cpu)(struct device *hwdev,
102 struct scatterlist *sg, int nelems,
103 enum dma_data_direction direction);
104 void (*sync_sg_for_device)(struct device *hwdev,
105 struct scatterlist *sg, int nelems,
106 enum dma_data_direction direction);
107#endif
108};
109
110/*
111 * Available generic sets of operations 68 * Available generic sets of operations
112 */ 69 */
113#ifdef CONFIG_PPC64 70#ifdef CONFIG_PPC64
114extern struct dma_mapping_ops dma_iommu_ops; 71extern struct dma_map_ops dma_iommu_ops;
115#endif 72#endif
116extern struct dma_mapping_ops dma_direct_ops; 73extern struct dma_map_ops dma_direct_ops;
117 74
118static inline struct dma_mapping_ops *get_dma_ops(struct device *dev) 75static inline struct dma_map_ops *get_dma_ops(struct device *dev)
119{ 76{
120 /* We don't handle the NULL dev case for ISA for now. We could 77 /* We don't handle the NULL dev case for ISA for now. We could
121 * do it via an out of line call but it is not needed for now. The 78 * do it via an out of line call but it is not needed for now. The
@@ -128,14 +85,19 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
128 return dev->archdata.dma_ops; 85 return dev->archdata.dma_ops;
129} 86}
130 87
131static inline void set_dma_ops(struct device *dev, struct dma_mapping_ops *ops) 88static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
132{ 89{
133 dev->archdata.dma_ops = ops; 90 dev->archdata.dma_ops = ops;
134} 91}
135 92
93/* this will be removed soon */
94#define flush_write_buffers()
95
96#include <asm-generic/dma-mapping-common.h>
97
136static inline int dma_supported(struct device *dev, u64 mask) 98static inline int dma_supported(struct device *dev, u64 mask)
137{ 99{
138 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 100 struct dma_map_ops *dma_ops = get_dma_ops(dev);
139 101
140 if (unlikely(dma_ops == NULL)) 102 if (unlikely(dma_ops == NULL))
141 return 0; 103 return 0;
@@ -149,7 +111,7 @@ static inline int dma_supported(struct device *dev, u64 mask)
149 111
150static inline int dma_set_mask(struct device *dev, u64 dma_mask) 112static inline int dma_set_mask(struct device *dev, u64 dma_mask)
151{ 113{
152 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 114 struct dma_map_ops *dma_ops = get_dma_ops(dev);
153 115
154 if (unlikely(dma_ops == NULL)) 116 if (unlikely(dma_ops == NULL))
155 return -EIO; 117 return -EIO;
@@ -161,262 +123,40 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
161 return 0; 123 return 0;
162} 124}
163 125
164/*
165 * map_/unmap_single actually call through to map/unmap_page now that all the
166 * dma_mapping_ops have been converted over. We just have to get the page and
167 * offset to pass through to map_page
168 */
169static inline dma_addr_t dma_map_single_attrs(struct device *dev,
170 void *cpu_addr,
171 size_t size,
172 enum dma_data_direction direction,
173 struct dma_attrs *attrs)
174{
175 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
176
177 BUG_ON(!dma_ops);
178
179 return dma_ops->map_page(dev, virt_to_page(cpu_addr),
180 (unsigned long)cpu_addr % PAGE_SIZE, size,
181 direction, attrs);
182}
183
184static inline void dma_unmap_single_attrs(struct device *dev,
185 dma_addr_t dma_addr,
186 size_t size,
187 enum dma_data_direction direction,
188 struct dma_attrs *attrs)
189{
190 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
191
192 BUG_ON(!dma_ops);
193
194 dma_ops->unmap_page(dev, dma_addr, size, direction, attrs);
195}
196
197static inline dma_addr_t dma_map_page_attrs(struct device *dev,
198 struct page *page,
199 unsigned long offset, size_t size,
200 enum dma_data_direction direction,
201 struct dma_attrs *attrs)
202{
203 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
204
205 BUG_ON(!dma_ops);
206
207 return dma_ops->map_page(dev, page, offset, size, direction, attrs);
208}
209
210static inline void dma_unmap_page_attrs(struct device *dev,
211 dma_addr_t dma_address,
212 size_t size,
213 enum dma_data_direction direction,
214 struct dma_attrs *attrs)
215{
216 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
217
218 BUG_ON(!dma_ops);
219
220 dma_ops->unmap_page(dev, dma_address, size, direction, attrs);
221}
222
223static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
224 int nents, enum dma_data_direction direction,
225 struct dma_attrs *attrs)
226{
227 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
228
229 BUG_ON(!dma_ops);
230 return dma_ops->map_sg(dev, sg, nents, direction, attrs);
231}
232
233static inline void dma_unmap_sg_attrs(struct device *dev,
234 struct scatterlist *sg,
235 int nhwentries,
236 enum dma_data_direction direction,
237 struct dma_attrs *attrs)
238{
239 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
240
241 BUG_ON(!dma_ops);
242 dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs);
243}
244
245static inline void *dma_alloc_coherent(struct device *dev, size_t size, 126static inline void *dma_alloc_coherent(struct device *dev, size_t size,
246 dma_addr_t *dma_handle, gfp_t flag) 127 dma_addr_t *dma_handle, gfp_t flag)
247{ 128{
248 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 129 struct dma_map_ops *dma_ops = get_dma_ops(dev);
249 130 void *cpu_addr;
250 BUG_ON(!dma_ops);
251 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
252}
253
254static inline void dma_free_coherent(struct device *dev, size_t size,
255 void *cpu_addr, dma_addr_t dma_handle)
256{
257 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
258
259 BUG_ON(!dma_ops);
260 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
261}
262
263static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
264 size_t size,
265 enum dma_data_direction direction)
266{
267 return dma_map_single_attrs(dev, cpu_addr, size, direction, NULL);
268}
269
270static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
271 size_t size,
272 enum dma_data_direction direction)
273{
274 dma_unmap_single_attrs(dev, dma_addr, size, direction, NULL);
275}
276
277static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
278 unsigned long offset, size_t size,
279 enum dma_data_direction direction)
280{
281 return dma_map_page_attrs(dev, page, offset, size, direction, NULL);
282}
283
284static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
285 size_t size,
286 enum dma_data_direction direction)
287{
288 dma_unmap_page_attrs(dev, dma_address, size, direction, NULL);
289}
290
291static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
292 int nents, enum dma_data_direction direction)
293{
294 return dma_map_sg_attrs(dev, sg, nents, direction, NULL);
295}
296
297static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
298 int nhwentries,
299 enum dma_data_direction direction)
300{
301 dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL);
302}
303
304#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
305static inline void dma_sync_single_for_cpu(struct device *dev,
306 dma_addr_t dma_handle, size_t size,
307 enum dma_data_direction direction)
308{
309 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
310
311 BUG_ON(!dma_ops);
312
313 if (dma_ops->sync_single_range_for_cpu)
314 dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
315 size, direction);
316}
317
318static inline void dma_sync_single_for_device(struct device *dev,
319 dma_addr_t dma_handle, size_t size,
320 enum dma_data_direction direction)
321{
322 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
323
324 BUG_ON(!dma_ops);
325
326 if (dma_ops->sync_single_range_for_device)
327 dma_ops->sync_single_range_for_device(dev, dma_handle,
328 0, size, direction);
329}
330
331static inline void dma_sync_sg_for_cpu(struct device *dev,
332 struct scatterlist *sgl, int nents,
333 enum dma_data_direction direction)
334{
335 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
336 131
337 BUG_ON(!dma_ops); 132 BUG_ON(!dma_ops);
338 133
339 if (dma_ops->sync_sg_for_cpu) 134 cpu_addr = dma_ops->alloc_coherent(dev, size, dma_handle, flag);
340 dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
341}
342
343static inline void dma_sync_sg_for_device(struct device *dev,
344 struct scatterlist *sgl, int nents,
345 enum dma_data_direction direction)
346{
347 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
348
349 BUG_ON(!dma_ops);
350
351 if (dma_ops->sync_sg_for_device)
352 dma_ops->sync_sg_for_device(dev, sgl, nents, direction);
353}
354
355static inline void dma_sync_single_range_for_cpu(struct device *dev,
356 dma_addr_t dma_handle, unsigned long offset, size_t size,
357 enum dma_data_direction direction)
358{
359 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
360 135
361 BUG_ON(!dma_ops); 136 debug_dma_alloc_coherent(dev, size, *dma_handle, cpu_addr);
362 137
363 if (dma_ops->sync_single_range_for_cpu) 138 return cpu_addr;
364 dma_ops->sync_single_range_for_cpu(dev, dma_handle,
365 offset, size, direction);
366} 139}
367 140
368static inline void dma_sync_single_range_for_device(struct device *dev, 141static inline void dma_free_coherent(struct device *dev, size_t size,
369 dma_addr_t dma_handle, unsigned long offset, size_t size, 142 void *cpu_addr, dma_addr_t dma_handle)
370 enum dma_data_direction direction)
371{ 143{
372 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 144 struct dma_map_ops *dma_ops = get_dma_ops(dev);
373 145
374 BUG_ON(!dma_ops); 146 BUG_ON(!dma_ops);
375 147
376 if (dma_ops->sync_single_range_for_device) 148 debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
377 dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
378 size, direction);
379}
380#else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */
381static inline void dma_sync_single_for_cpu(struct device *dev,
382 dma_addr_t dma_handle, size_t size,
383 enum dma_data_direction direction)
384{
385}
386
387static inline void dma_sync_single_for_device(struct device *dev,
388 dma_addr_t dma_handle, size_t size,
389 enum dma_data_direction direction)
390{
391}
392
393static inline void dma_sync_sg_for_cpu(struct device *dev,
394 struct scatterlist *sgl, int nents,
395 enum dma_data_direction direction)
396{
397}
398 149
399static inline void dma_sync_sg_for_device(struct device *dev, 150 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
400 struct scatterlist *sgl, int nents,
401 enum dma_data_direction direction)
402{
403} 151}
404 152
405static inline void dma_sync_single_range_for_cpu(struct device *dev, 153static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
406 dma_addr_t dma_handle, unsigned long offset, size_t size,
407 enum dma_data_direction direction)
408{ 154{
409} 155 struct dma_map_ops *dma_ops = get_dma_ops(dev);
410 156
411static inline void dma_sync_single_range_for_device(struct device *dev, 157 if (dma_ops->mapping_error)
412 dma_addr_t dma_handle, unsigned long offset, size_t size, 158 return dma_ops->mapping_error(dev, dma_addr);
413 enum dma_data_direction direction)
414{
415}
416#endif
417 159
418static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
419{
420#ifdef CONFIG_PPC64 160#ifdef CONFIG_PPC64
421 return (dma_addr == DMA_ERROR_CODE); 161 return (dma_addr == DMA_ERROR_CODE);
422#else 162#else
@@ -426,10 +166,12 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
426 166
427static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) 167static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
428{ 168{
429 struct dma_mapping_ops *ops = get_dma_ops(dev); 169#ifdef CONFIG_SWIOTLB
170 struct dev_archdata *sd = &dev->archdata;
430 171
431 if (ops->addr_needs_map && ops->addr_needs_map(dev, addr, size)) 172 if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr)
432 return 0; 173 return 0;
174#endif
433 175
434 if (!dev->dma_mask) 176 if (!dev->dma_mask)
435 return 0; 177 return 0;
diff --git a/arch/powerpc/include/asm/exception-64e.h b/arch/powerpc/include/asm/exception-64e.h
new file mode 100644
index 000000000000..6d53f311d942
--- /dev/null
+++ b/arch/powerpc/include/asm/exception-64e.h
@@ -0,0 +1,205 @@
1/*
2 * Definitions for use by exception code on Book3-E
3 *
4 * Copyright (C) 2008 Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#ifndef _ASM_POWERPC_EXCEPTION_64E_H
12#define _ASM_POWERPC_EXCEPTION_64E_H
13
14/*
15 * SPRGs usage an other considerations...
16 *
17 * Since TLB miss and other standard exceptions can be interrupted by
18 * critical exceptions which can themselves be interrupted by machine
19 * checks, and since the two later can themselves cause a TLB miss when
20 * hitting the linear mapping for the kernel stacks, we need to be a bit
21 * creative on how we use SPRGs.
22 *
23 * The base idea is that we have one SRPG reserved for critical and one
24 * for machine check interrupts. Those are used to save a GPR that can
25 * then be used to get the PACA, and store as much context as we need
26 * to save in there. That includes saving the SPRGs used by the TLB miss
27 * handler for linear mapping misses and the associated SRR0/1 due to
28 * the above re-entrancy issue.
29 *
30 * So here's the current usage pattern. It's done regardless of which
31 * SPRGs are user-readable though, thus we might have to change some of
32 * this later. In order to do that more easily, we use special constants
33 * for naming them
34 *
35 * WARNING: Some of these SPRGs are user readable. We need to do something
36 * about it as some point by making sure they can't be used to leak kernel
37 * critical data
38 */
39
40
41/* We are out of SPRGs so we save some things in the PACA. The normal
42 * exception frame is smaller than the CRIT or MC one though
43 */
44#define EX_R1 (0 * 8)
45#define EX_CR (1 * 8)
46#define EX_R10 (2 * 8)
47#define EX_R11 (3 * 8)
48#define EX_R14 (4 * 8)
49#define EX_R15 (5 * 8)
50
51/* The TLB miss exception uses different slots */
52
53#define EX_TLB_R10 ( 0 * 8)
54#define EX_TLB_R11 ( 1 * 8)
55#define EX_TLB_R12 ( 2 * 8)
56#define EX_TLB_R13 ( 3 * 8)
57#define EX_TLB_R14 ( 4 * 8)
58#define EX_TLB_R15 ( 5 * 8)
59#define EX_TLB_R16 ( 6 * 8)
60#define EX_TLB_CR ( 7 * 8)
61#define EX_TLB_DEAR ( 8 * 8) /* Level 0 and 2 only */
62#define EX_TLB_ESR ( 9 * 8) /* Level 0 and 2 only */
63#define EX_TLB_SRR0 (10 * 8)
64#define EX_TLB_SRR1 (11 * 8)
65#define EX_TLB_MMUCR0 (12 * 8) /* Level 0 */
66#define EX_TLB_MAS1 (12 * 8) /* Level 0 */
67#define EX_TLB_MAS2 (13 * 8) /* Level 0 */
68#ifdef CONFIG_BOOK3E_MMU_TLB_STATS
69#define EX_TLB_R8 (14 * 8)
70#define EX_TLB_R9 (15 * 8)
71#define EX_TLB_LR (16 * 8)
72#define EX_TLB_SIZE (17 * 8)
73#else
74#define EX_TLB_SIZE (14 * 8)
75#endif
76
77#define START_EXCEPTION(label) \
78 .globl exc_##label##_book3e; \
79exc_##label##_book3e:
80
81/* TLB miss exception prolog
82 *
83 * This prolog handles re-entrancy (up to 3 levels supported in the PACA
84 * though we currently don't test for overflow). It provides you with a
85 * re-entrancy safe working space of r10...r16 and CR with r12 being used
86 * as the exception area pointer in the PACA for that level of re-entrancy
87 * and r13 containing the PACA pointer.
88 *
89 * SRR0 and SRR1 are saved, but DEAR and ESR are not, since they don't apply
90 * as-is for instruction exceptions. It's up to the actual exception code
91 * to save them as well if required.
92 */
93#define TLB_MISS_PROLOG \
94 mtspr SPRN_SPRG_TLB_SCRATCH,r12; \
95 mfspr r12,SPRN_SPRG_TLB_EXFRAME; \
96 std r10,EX_TLB_R10(r12); \
97 mfcr r10; \
98 std r11,EX_TLB_R11(r12); \
99 mfspr r11,SPRN_SPRG_TLB_SCRATCH; \
100 std r13,EX_TLB_R13(r12); \
101 mfspr r13,SPRN_SPRG_PACA; \
102 std r14,EX_TLB_R14(r12); \
103 addi r14,r12,EX_TLB_SIZE; \
104 std r15,EX_TLB_R15(r12); \
105 mfspr r15,SPRN_SRR1; \
106 std r16,EX_TLB_R16(r12); \
107 mfspr r16,SPRN_SRR0; \
108 std r10,EX_TLB_CR(r12); \
109 std r11,EX_TLB_R12(r12); \
110 mtspr SPRN_SPRG_TLB_EXFRAME,r14; \
111 std r15,EX_TLB_SRR1(r12); \
112 std r16,EX_TLB_SRR0(r12); \
113 TLB_MISS_PROLOG_STATS
114
115/* And these are the matching epilogs that restores things
116 *
117 * There are 3 epilogs:
118 *
119 * - SUCCESS : Unwinds one level
120 * - ERROR : restore from level 0 and reset
121 * - ERROR_SPECIAL : restore from current level and reset
122 *
123 * Normal errors use ERROR, that is, they restore the initial fault context
124 * and trigger a fault. However, there is a special case for linear mapping
125 * errors. Those should basically never happen, but if they do happen, we
126 * want the error to point out the context that did that linear mapping
127 * fault, not the initial level 0 (basically, we got a bogus PGF or something
128 * like that). For userland errors on the linear mapping, there is no
129 * difference since those are always level 0 anyway
130 */
131
132#define TLB_MISS_RESTORE(freg) \
133 ld r14,EX_TLB_CR(r12); \
134 ld r10,EX_TLB_R10(r12); \
135 ld r15,EX_TLB_SRR0(r12); \
136 ld r16,EX_TLB_SRR1(r12); \
137 mtspr SPRN_SPRG_TLB_EXFRAME,freg; \
138 ld r11,EX_TLB_R11(r12); \
139 mtcr r14; \
140 ld r13,EX_TLB_R13(r12); \
141 ld r14,EX_TLB_R14(r12); \
142 mtspr SPRN_SRR0,r15; \
143 ld r15,EX_TLB_R15(r12); \
144 mtspr SPRN_SRR1,r16; \
145 TLB_MISS_RESTORE_STATS \
146 ld r16,EX_TLB_R16(r12); \
147 ld r12,EX_TLB_R12(r12); \
148
149#define TLB_MISS_EPILOG_SUCCESS \
150 TLB_MISS_RESTORE(r12)
151
152#define TLB_MISS_EPILOG_ERROR \
153 addi r12,r13,PACA_EXTLB; \
154 TLB_MISS_RESTORE(r12)
155
156#define TLB_MISS_EPILOG_ERROR_SPECIAL \
157 addi r11,r13,PACA_EXTLB; \
158 TLB_MISS_RESTORE(r11)
159
160#ifdef CONFIG_BOOK3E_MMU_TLB_STATS
161#define TLB_MISS_PROLOG_STATS \
162 mflr r10; \
163 std r8,EX_TLB_R8(r12); \
164 std r9,EX_TLB_R9(r12); \
165 std r10,EX_TLB_LR(r12);
166#define TLB_MISS_RESTORE_STATS \
167 ld r16,EX_TLB_LR(r12); \
168 ld r9,EX_TLB_R9(r12); \
169 ld r8,EX_TLB_R8(r12); \
170 mtlr r16;
171#define TLB_MISS_STATS_D(name) \
172 addi r9,r13,MMSTAT_DSTATS+name; \
173 bl .tlb_stat_inc;
174#define TLB_MISS_STATS_I(name) \
175 addi r9,r13,MMSTAT_ISTATS+name; \
176 bl .tlb_stat_inc;
177#define TLB_MISS_STATS_X(name) \
178 ld r8,PACA_EXTLB+EX_TLB_ESR(r13); \
179 cmpdi cr2,r8,-1; \
180 beq cr2,61f; \
181 addi r9,r13,MMSTAT_DSTATS+name; \
182 b 62f; \
18361: addi r9,r13,MMSTAT_ISTATS+name; \
18462: bl .tlb_stat_inc;
185#define TLB_MISS_STATS_SAVE_INFO \
186 std r14,EX_TLB_ESR(r12); /* save ESR */ \
187
188
189#else
190#define TLB_MISS_PROLOG_STATS
191#define TLB_MISS_RESTORE_STATS
192#define TLB_MISS_STATS_D(name)
193#define TLB_MISS_STATS_I(name)
194#define TLB_MISS_STATS_X(name)
195#define TLB_MISS_STATS_Y(name)
196#define TLB_MISS_STATS_SAVE_INFO
197#endif
198
199#define SET_IVOR(vector_number, vector_offset) \
200 li r3,vector_offset@l; \
201 ori r3,r3,interrupt_base_book3e@l; \
202 mtspr SPRN_IVOR##vector_number,r3;
203
204#endif /* _ASM_POWERPC_EXCEPTION_64E_H */
205
diff --git a/arch/powerpc/include/asm/exception.h b/arch/powerpc/include/asm/exception-64s.h
index d3d4534e3c74..a98653b26231 100644
--- a/arch/powerpc/include/asm/exception.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -57,17 +57,16 @@
57 addi reg,reg,(label)-_stext; /* virt addr of handler ... */ 57 addi reg,reg,(label)-_stext; /* virt addr of handler ... */
58 58
59#define EXCEPTION_PROLOG_1(area) \ 59#define EXCEPTION_PROLOG_1(area) \
60 mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \ 60 mfspr r13,SPRN_SPRG_PACA; /* get paca address into r13 */ \
61 std r9,area+EX_R9(r13); /* save r9 - r12 */ \ 61 std r9,area+EX_R9(r13); /* save r9 - r12 */ \
62 std r10,area+EX_R10(r13); \ 62 std r10,area+EX_R10(r13); \
63 std r11,area+EX_R11(r13); \ 63 std r11,area+EX_R11(r13); \
64 std r12,area+EX_R12(r13); \ 64 std r12,area+EX_R12(r13); \
65 mfspr r9,SPRN_SPRG1; \ 65 mfspr r9,SPRN_SPRG_SCRATCH0; \
66 std r9,area+EX_R13(r13); \ 66 std r9,area+EX_R13(r13); \
67 mfcr r9 67 mfcr r9
68 68
69#define EXCEPTION_PROLOG_PSERIES(area, label) \ 69#define EXCEPTION_PROLOG_PSERIES_1(label) \
70 EXCEPTION_PROLOG_1(area); \
71 ld r12,PACAKBASE(r13); /* get high part of &label */ \ 70 ld r12,PACAKBASE(r13); /* get high part of &label */ \
72 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 71 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \
73 mfspr r11,SPRN_SRR0; /* save SRR0 */ \ 72 mfspr r11,SPRN_SRR0; /* save SRR0 */ \
@@ -78,6 +77,10 @@
78 rfid; \ 77 rfid; \
79 b . /* prevent speculative execution */ 78 b . /* prevent speculative execution */
80 79
80#define EXCEPTION_PROLOG_PSERIES(area, label) \
81 EXCEPTION_PROLOG_1(area); \
82 EXCEPTION_PROLOG_PSERIES_1(label);
83
81/* 84/*
82 * The common exception prolog is used for all except a few exceptions 85 * The common exception prolog is used for all except a few exceptions
83 * such as a segment miss on a kernel address. We have to be prepared 86 * such as a segment miss on a kernel address. We have to be prepared
@@ -144,7 +147,7 @@
144 .globl label##_pSeries; \ 147 .globl label##_pSeries; \
145label##_pSeries: \ 148label##_pSeries: \
146 HMT_MEDIUM; \ 149 HMT_MEDIUM; \
147 mtspr SPRN_SPRG1,r13; /* save r13 */ \ 150 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \
148 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) 151 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
149 152
150#define HSTD_EXCEPTION_PSERIES(n, label) \ 153#define HSTD_EXCEPTION_PSERIES(n, label) \
@@ -152,13 +155,13 @@ label##_pSeries: \
152 .globl label##_pSeries; \ 155 .globl label##_pSeries; \
153label##_pSeries: \ 156label##_pSeries: \
154 HMT_MEDIUM; \ 157 HMT_MEDIUM; \
155 mtspr SPRN_SPRG1,r20; /* save r20 */ \ 158 mtspr SPRN_SPRG_SCRATCH0,r20; /* save r20 */ \
156 mfspr r20,SPRN_HSRR0; /* copy HSRR0 to SRR0 */ \ 159 mfspr r20,SPRN_HSRR0; /* copy HSRR0 to SRR0 */ \
157 mtspr SPRN_SRR0,r20; \ 160 mtspr SPRN_SRR0,r20; \
158 mfspr r20,SPRN_HSRR1; /* copy HSRR0 to SRR0 */ \ 161 mfspr r20,SPRN_HSRR1; /* copy HSRR0 to SRR0 */ \
159 mtspr SPRN_SRR1,r20; \ 162 mtspr SPRN_SRR1,r20; \
160 mfspr r20,SPRN_SPRG1; /* restore r20 */ \ 163 mfspr r20,SPRN_SPRG_SCRATCH0; /* restore r20 */ \
161 mtspr SPRN_SPRG1,r13; /* save r13 */ \ 164 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \
162 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) 165 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
163 166
164 167
@@ -167,15 +170,15 @@ label##_pSeries: \
167 .globl label##_pSeries; \ 170 .globl label##_pSeries; \
168label##_pSeries: \ 171label##_pSeries: \
169 HMT_MEDIUM; \ 172 HMT_MEDIUM; \
170 mtspr SPRN_SPRG1,r13; /* save r13 */ \ 173 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \
171 mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \ 174 mfspr r13,SPRN_SPRG_PACA; /* get paca address into r13 */ \
172 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \ 175 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \
173 std r10,PACA_EXGEN+EX_R10(r13); \ 176 std r10,PACA_EXGEN+EX_R10(r13); \
174 lbz r10,PACASOFTIRQEN(r13); \ 177 lbz r10,PACASOFTIRQEN(r13); \
175 mfcr r9; \ 178 mfcr r9; \
176 cmpwi r10,0; \ 179 cmpwi r10,0; \
177 beq masked_interrupt; \ 180 beq masked_interrupt; \
178 mfspr r10,SPRN_SPRG1; \ 181 mfspr r10,SPRN_SPRG_SCRATCH0; \
179 std r10,PACA_EXGEN+EX_R13(r13); \ 182 std r10,PACA_EXGEN+EX_R13(r13); \
180 std r11,PACA_EXGEN+EX_R11(r13); \ 183 std r11,PACA_EXGEN+EX_R11(r13); \
181 std r12,PACA_EXGEN+EX_R12(r13); \ 184 std r12,PACA_EXGEN+EX_R12(r13); \
diff --git a/arch/powerpc/include/asm/hardirq.h b/arch/powerpc/include/asm/hardirq.h
index 288e14d53b7f..fb3c05a0cbbf 100644
--- a/arch/powerpc/include/asm/hardirq.h
+++ b/arch/powerpc/include/asm/hardirq.h
@@ -1,29 +1 @@
1#ifndef _ASM_POWERPC_HARDIRQ_H #include <asm-generic/hardirq.h>
2#define _ASM_POWERPC_HARDIRQ_H
3#ifdef __KERNEL__
4
5#include <asm/irq.h>
6#include <asm/bug.h>
7
8/* The __last_jiffy_stamp field is needed to ensure that no decrementer
9 * interrupt is lost on SMP machines. Since on most CPUs it is in the same
10 * cache line as local_irq_count, it is cheap to access and is also used on UP
11 * for uniformity.
12 */
13typedef struct {
14 unsigned int __softirq_pending; /* set_bit is used on this */
15 unsigned int __last_jiffy_stamp;
16} ____cacheline_aligned irq_cpustat_t;
17
18#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
19
20#define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp)
21
22static inline void ack_bad_irq(int irq)
23{
24 printk(KERN_CRIT "illegal vector %d received!\n", irq);
25 BUG();
26}
27
28#endif /* __KERNEL__ */
29#endif /* _ASM_POWERPC_HARDIRQ_H */
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 8b505eaaa38a..e73d554538dd 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -49,8 +49,13 @@ extern void iseries_handle_interrupts(void);
49#define raw_irqs_disabled() (local_get_flags() == 0) 49#define raw_irqs_disabled() (local_get_flags() == 0)
50#define raw_irqs_disabled_flags(flags) ((flags) == 0) 50#define raw_irqs_disabled_flags(flags) ((flags) == 0)
51 51
52#ifdef CONFIG_PPC_BOOK3E
53#define __hard_irq_enable() __asm__ __volatile__("wrteei 1": : :"memory");
54#define __hard_irq_disable() __asm__ __volatile__("wrteei 0": : :"memory");
55#else
52#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) 56#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
53#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) 57#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
58#endif
54 59
55#define hard_irq_disable() \ 60#define hard_irq_disable() \
56 do { \ 61 do { \
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 7ead7c16fb7c..7464c0daddd1 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -35,16 +35,6 @@
35#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1)) 35#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1))
36#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE) 36#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE)
37 37
38/* Cell page table entries */
39#define CBE_IOPTE_PP_W 0x8000000000000000ul /* protection: write */
40#define CBE_IOPTE_PP_R 0x4000000000000000ul /* protection: read */
41#define CBE_IOPTE_M 0x2000000000000000ul /* coherency required */
42#define CBE_IOPTE_SO_R 0x1000000000000000ul /* ordering: writes */
43#define CBE_IOPTE_SO_RW 0x1800000000000000ul /* ordering: r & w */
44#define CBE_IOPTE_RPN_Mask 0x07fffffffffff000ul /* RPN */
45#define CBE_IOPTE_H 0x0000000000000800ul /* cache hint */
46#define CBE_IOPTE_IOID_Mask 0x00000000000007fful /* ioid */
47
48/* Boot time flags */ 38/* Boot time flags */
49extern int iommu_is_off; 39extern int iommu_is_off;
50extern int iommu_force_on; 40extern int iommu_force_on;
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index 0a5137676e1b..bbcd1aaf3dfd 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -302,7 +302,8 @@ extern void irq_free_virt(unsigned int virq, unsigned int count);
302 302
303/* -- OF helpers -- */ 303/* -- OF helpers -- */
304 304
305/* irq_create_of_mapping - Map a hardware interrupt into linux virq space 305/**
306 * irq_create_of_mapping - Map a hardware interrupt into linux virq space
306 * @controller: Device node of the interrupt controller 307 * @controller: Device node of the interrupt controller
307 * @inspec: Interrupt specifier from the device-tree 308 * @inspec: Interrupt specifier from the device-tree
308 * @intsize: Size of the interrupt specifier from the device-tree 309 * @intsize: Size of the interrupt specifier from the device-tree
@@ -314,8 +315,8 @@ extern void irq_free_virt(unsigned int virq, unsigned int count);
314extern unsigned int irq_create_of_mapping(struct device_node *controller, 315extern unsigned int irq_create_of_mapping(struct device_node *controller,
315 u32 *intspec, unsigned int intsize); 316 u32 *intspec, unsigned int intsize);
316 317
317 318/**
318/* irq_of_parse_and_map - Parse nad Map an interrupt into linux virq space 319 * irq_of_parse_and_map - Parse and Map an interrupt into linux virq space
319 * @device: Device node of the device whose interrupt is to be mapped 320 * @device: Device node of the device whose interrupt is to be mapped
320 * @index: Index of the interrupt to map 321 * @index: Index of the interrupt to map
321 * 322 *
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 11d1fc3a8962..9efa2be78331 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -209,14 +209,14 @@ struct machdep_calls {
209 /* 209 /*
210 * optional PCI "hooks" 210 * optional PCI "hooks"
211 */ 211 */
212 /* Called in indirect_* to avoid touching devices */
213 int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
214
215 /* Called at then very end of pcibios_init() */ 212 /* Called at then very end of pcibios_init() */
216 void (*pcibios_after_init)(void); 213 void (*pcibios_after_init)(void);
217 214
218#endif /* CONFIG_PPC32 */ 215#endif /* CONFIG_PPC32 */
219 216
217 /* Called in indirect_* to avoid touching devices */
218 int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
219
220 /* Called after PPC generic resource fixup to perform 220 /* Called after PPC generic resource fixup to perform
221 machine specific fixups */ 221 machine specific fixups */
222 void (*pcibios_fixup_resources)(struct pci_dev *); 222 void (*pcibios_fixup_resources)(struct pci_dev *);
diff --git a/arch/powerpc/include/asm/mmu-40x.h b/arch/powerpc/include/asm/mmu-40x.h
index 776f415a36aa..34916865eaef 100644
--- a/arch/powerpc/include/asm/mmu-40x.h
+++ b/arch/powerpc/include/asm/mmu-40x.h
@@ -61,4 +61,7 @@ typedef struct {
61 61
62#endif /* !__ASSEMBLY__ */ 62#endif /* !__ASSEMBLY__ */
63 63
64#define mmu_virtual_psize MMU_PAGE_4K
65#define mmu_linear_psize MMU_PAGE_256M
66
64#endif /* _ASM_POWERPC_MMU_40X_H_ */ 67#endif /* _ASM_POWERPC_MMU_40X_H_ */
diff --git a/arch/powerpc/include/asm/mmu-44x.h b/arch/powerpc/include/asm/mmu-44x.h
index 3c86576bfefa..0372669383a8 100644
--- a/arch/powerpc/include/asm/mmu-44x.h
+++ b/arch/powerpc/include/asm/mmu-44x.h
@@ -79,16 +79,22 @@ typedef struct {
79 79
80#if (PAGE_SHIFT == 12) 80#if (PAGE_SHIFT == 12)
81#define PPC44x_TLBE_SIZE PPC44x_TLB_4K 81#define PPC44x_TLBE_SIZE PPC44x_TLB_4K
82#define mmu_virtual_psize MMU_PAGE_4K
82#elif (PAGE_SHIFT == 14) 83#elif (PAGE_SHIFT == 14)
83#define PPC44x_TLBE_SIZE PPC44x_TLB_16K 84#define PPC44x_TLBE_SIZE PPC44x_TLB_16K
85#define mmu_virtual_psize MMU_PAGE_16K
84#elif (PAGE_SHIFT == 16) 86#elif (PAGE_SHIFT == 16)
85#define PPC44x_TLBE_SIZE PPC44x_TLB_64K 87#define PPC44x_TLBE_SIZE PPC44x_TLB_64K
88#define mmu_virtual_psize MMU_PAGE_64K
86#elif (PAGE_SHIFT == 18) 89#elif (PAGE_SHIFT == 18)
87#define PPC44x_TLBE_SIZE PPC44x_TLB_256K 90#define PPC44x_TLBE_SIZE PPC44x_TLB_256K
91#define mmu_virtual_psize MMU_PAGE_256K
88#else 92#else
89#error "Unsupported PAGE_SIZE" 93#error "Unsupported PAGE_SIZE"
90#endif 94#endif
91 95
96#define mmu_linear_psize MMU_PAGE_256M
97
92#define PPC44x_PGD_OFF_SHIFT (32 - PGDIR_SHIFT + PGD_T_LOG2) 98#define PPC44x_PGD_OFF_SHIFT (32 - PGDIR_SHIFT + PGD_T_LOG2)
93#define PPC44x_PGD_OFF_MASK_BIT (PGDIR_SHIFT - PGD_T_LOG2) 99#define PPC44x_PGD_OFF_MASK_BIT (PGDIR_SHIFT - PGD_T_LOG2)
94#define PPC44x_PTE_ADD_SHIFT (32 - PGDIR_SHIFT + PTE_SHIFT + PTE_T_LOG2) 100#define PPC44x_PTE_ADD_SHIFT (32 - PGDIR_SHIFT + PTE_SHIFT + PTE_T_LOG2)
diff --git a/arch/powerpc/include/asm/mmu-8xx.h b/arch/powerpc/include/asm/mmu-8xx.h
index 07865a357848..3d11d3ce79ec 100644
--- a/arch/powerpc/include/asm/mmu-8xx.h
+++ b/arch/powerpc/include/asm/mmu-8xx.h
@@ -143,4 +143,7 @@ typedef struct {
143} mm_context_t; 143} mm_context_t;
144#endif /* !__ASSEMBLY__ */ 144#endif /* !__ASSEMBLY__ */
145 145
146#define mmu_virtual_psize MMU_PAGE_4K
147#define mmu_linear_psize MMU_PAGE_8M
148
146#endif /* _ASM_POWERPC_MMU_8XX_H_ */ 149#endif /* _ASM_POWERPC_MMU_8XX_H_ */
diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
index 7e74cff81d86..74695816205c 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -38,58 +38,140 @@
38#define BOOK3E_PAGESZ_1TB 30 38#define BOOK3E_PAGESZ_1TB 30
39#define BOOK3E_PAGESZ_2TB 31 39#define BOOK3E_PAGESZ_2TB 31
40 40
41#define MAS0_TLBSEL(x) ((x << 28) & 0x30000000) 41/* MAS registers bit definitions */
42#define MAS0_ESEL(x) ((x << 16) & 0x0FFF0000) 42
43#define MAS0_NV(x) ((x) & 0x00000FFF) 43#define MAS0_TLBSEL(x) ((x << 28) & 0x30000000)
44 44#define MAS0_ESEL(x) ((x << 16) & 0x0FFF0000)
45#define MAS1_VALID 0x80000000 45#define MAS0_NV(x) ((x) & 0x00000FFF)
46#define MAS1_IPROT 0x40000000 46#define MAS0_HES 0x00004000
47#define MAS1_TID(x) ((x << 16) & 0x3FFF0000) 47#define MAS0_WQ_ALLWAYS 0x00000000
48#define MAS1_IND 0x00002000 48#define MAS0_WQ_COND 0x00001000
49#define MAS1_TS 0x00001000 49#define MAS0_WQ_CLR_RSRV 0x00002000
50#define MAS1_TSIZE(x) ((x << 7) & 0x00000F80) 50
51 51#define MAS1_VALID 0x80000000
52#define MAS2_EPN 0xFFFFF000 52#define MAS1_IPROT 0x40000000
53#define MAS2_X0 0x00000040 53#define MAS1_TID(x) ((x << 16) & 0x3FFF0000)
54#define MAS2_X1 0x00000020 54#define MAS1_IND 0x00002000
55#define MAS2_W 0x00000010 55#define MAS1_TS 0x00001000
56#define MAS2_I 0x00000008 56#define MAS1_TSIZE_MASK 0x00000f80
57#define MAS2_M 0x00000004 57#define MAS1_TSIZE_SHIFT 7
58#define MAS2_G 0x00000002 58#define MAS1_TSIZE(x) ((x << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
59#define MAS2_E 0x00000001 59
60#define MAS2_EPN 0xFFFFF000
61#define MAS2_X0 0x00000040
62#define MAS2_X1 0x00000020
63#define MAS2_W 0x00000010
64#define MAS2_I 0x00000008
65#define MAS2_M 0x00000004
66#define MAS2_G 0x00000002
67#define MAS2_E 0x00000001
60#define MAS2_EPN_MASK(size) (~0 << (size + 10)) 68#define MAS2_EPN_MASK(size) (~0 << (size + 10))
61#define MAS2_VAL(addr, size, flags) ((addr) & MAS2_EPN_MASK(size) | (flags)) 69#define MAS2_VAL(addr, size, flags) ((addr) & MAS2_EPN_MASK(size) | (flags))
62 70
63#define MAS3_RPN 0xFFFFF000 71#define MAS3_RPN 0xFFFFF000
64#define MAS3_U0 0x00000200 72#define MAS3_U0 0x00000200
65#define MAS3_U1 0x00000100 73#define MAS3_U1 0x00000100
66#define MAS3_U2 0x00000080 74#define MAS3_U2 0x00000080
67#define MAS3_U3 0x00000040 75#define MAS3_U3 0x00000040
68#define MAS3_UX 0x00000020 76#define MAS3_UX 0x00000020
69#define MAS3_SX 0x00000010 77#define MAS3_SX 0x00000010
70#define MAS3_UW 0x00000008 78#define MAS3_UW 0x00000008
71#define MAS3_SW 0x00000004 79#define MAS3_SW 0x00000004
72#define MAS3_UR 0x00000002 80#define MAS3_UR 0x00000002
73#define MAS3_SR 0x00000001 81#define MAS3_SR 0x00000001
74 82#define MAS3_SPSIZE 0x0000003e
75#define MAS4_TLBSELD(x) MAS0_TLBSEL(x) 83#define MAS3_SPSIZE_SHIFT 1
76#define MAS4_INDD 0x00008000 84
77#define MAS4_TSIZED(x) MAS1_TSIZE(x) 85#define MAS4_TLBSELD(x) MAS0_TLBSEL(x)
78#define MAS4_X0D 0x00000040 86#define MAS4_INDD 0x00008000 /* Default IND */
79#define MAS4_X1D 0x00000020 87#define MAS4_TSIZED(x) MAS1_TSIZE(x)
80#define MAS4_WD 0x00000010 88#define MAS4_X0D 0x00000040
81#define MAS4_ID 0x00000008 89#define MAS4_X1D 0x00000020
82#define MAS4_MD 0x00000004 90#define MAS4_WD 0x00000010
83#define MAS4_GD 0x00000002 91#define MAS4_ID 0x00000008
84#define MAS4_ED 0x00000001 92#define MAS4_MD 0x00000004
85 93#define MAS4_GD 0x00000002
86#define MAS6_SPID0 0x3FFF0000 94#define MAS4_ED 0x00000001
87#define MAS6_SPID1 0x00007FFE 95#define MAS4_WIMGED_MASK 0x0000001f /* Default WIMGE */
88#define MAS6_ISIZE(x) MAS1_TSIZE(x) 96#define MAS4_WIMGED_SHIFT 0
89#define MAS6_SAS 0x00000001 97#define MAS4_VLED MAS4_X1D /* Default VLE */
90#define MAS6_SPID MAS6_SPID0 98#define MAS4_ACMD 0x000000c0 /* Default ACM */
91 99#define MAS4_ACMD_SHIFT 6
92#define MAS7_RPN 0xFFFFFFFF 100#define MAS4_TSIZED_MASK 0x00000f80 /* Default TSIZE */
101#define MAS4_TSIZED_SHIFT 7
102
103#define MAS6_SPID0 0x3FFF0000
104#define MAS6_SPID1 0x00007FFE
105#define MAS6_ISIZE(x) MAS1_TSIZE(x)
106#define MAS6_SAS 0x00000001
107#define MAS6_SPID MAS6_SPID0
108#define MAS6_SIND 0x00000002 /* Indirect page */
109#define MAS6_SIND_SHIFT 1
110#define MAS6_SPID_MASK 0x3fff0000
111#define MAS6_SPID_SHIFT 16
112#define MAS6_ISIZE_MASK 0x00000f80
113#define MAS6_ISIZE_SHIFT 7
114
115#define MAS7_RPN 0xFFFFFFFF
116
117/* Bit definitions for MMUCSR0 */
118#define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */
119#define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */
120#define MMUCSR0_TLB2FI 0x00000040 /* TLB2 Flash invalidate */
121#define MMUCSR0_TLB3FI 0x00000020 /* TLB3 Flash invalidate */
122#define MMUCSR0_TLBFI (MMUCSR0_TLB0FI | MMUCSR0_TLB1FI | \
123 MMUCSR0_TLB2FI | MMUCSR0_TLB3FI)
124#define MMUCSR0_TLB0PS 0x00000780 /* TLB0 Page Size */
125#define MMUCSR0_TLB1PS 0x00007800 /* TLB1 Page Size */
126#define MMUCSR0_TLB2PS 0x00078000 /* TLB2 Page Size */
127#define MMUCSR0_TLB3PS 0x00780000 /* TLB3 Page Size */
128
129/* TLBnCFG encoding */
130#define TLBnCFG_N_ENTRY 0x00000fff /* number of entries */
131#define TLBnCFG_HES 0x00002000 /* HW select supported */
132#define TLBnCFG_IPROT 0x00008000 /* IPROT supported */
133#define TLBnCFG_GTWE 0x00010000 /* Guest can write */
134#define TLBnCFG_IND 0x00020000 /* IND entries supported */
135#define TLBnCFG_PT 0x00040000 /* Can load from page table */
136#define TLBnCFG_ASSOC 0xff000000 /* Associativity */
137
138/* TLBnPS encoding */
139#define TLBnPS_4K 0x00000004
140#define TLBnPS_8K 0x00000008
141#define TLBnPS_16K 0x00000010
142#define TLBnPS_32K 0x00000020
143#define TLBnPS_64K 0x00000040
144#define TLBnPS_128K 0x00000080
145#define TLBnPS_256K 0x00000100
146#define TLBnPS_512K 0x00000200
147#define TLBnPS_1M 0x00000400
148#define TLBnPS_2M 0x00000800
149#define TLBnPS_4M 0x00001000
150#define TLBnPS_8M 0x00002000
151#define TLBnPS_16M 0x00004000
152#define TLBnPS_32M 0x00008000
153#define TLBnPS_64M 0x00010000
154#define TLBnPS_128M 0x00020000
155#define TLBnPS_256M 0x00040000
156#define TLBnPS_512M 0x00080000
157#define TLBnPS_1G 0x00100000
158#define TLBnPS_2G 0x00200000
159#define TLBnPS_4G 0x00400000
160#define TLBnPS_8G 0x00800000
161#define TLBnPS_16G 0x01000000
162#define TLBnPS_32G 0x02000000
163#define TLBnPS_64G 0x04000000
164#define TLBnPS_128G 0x08000000
165#define TLBnPS_256G 0x10000000
166
167/* tlbilx action encoding */
168#define TLBILX_T_ALL 0
169#define TLBILX_T_TID 1
170#define TLBILX_T_FULLMATCH 3
171#define TLBILX_T_CLASS0 4
172#define TLBILX_T_CLASS1 5
173#define TLBILX_T_CLASS2 6
174#define TLBILX_T_CLASS3 7
93 175
94#ifndef __ASSEMBLY__ 176#ifndef __ASSEMBLY__
95 177
@@ -100,6 +182,34 @@ typedef struct {
100 unsigned int active; 182 unsigned int active;
101 unsigned long vdso_base; 183 unsigned long vdso_base;
102} mm_context_t; 184} mm_context_t;
185
186/* Page size definitions, common between 32 and 64-bit
187 *
188 * shift : is the "PAGE_SHIFT" value for that page size
189 * penc : is the pte encoding mask
190 *
191 */
192struct mmu_psize_def
193{
194 unsigned int shift; /* number of bits */
195 unsigned int enc; /* PTE encoding */
196};
197extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
198
199/* The page sizes use the same names as 64-bit hash but are
200 * constants
201 */
202#if defined(CONFIG_PPC_4K_PAGES)
203#define mmu_virtual_psize MMU_PAGE_4K
204#elif defined(CONFIG_PPC_64K_PAGES)
205#define mmu_virtual_psize MMU_PAGE_64K
206#else
207#error Unsupported page size
208#endif
209
210extern int mmu_linear_psize;
211extern int mmu_vmemmap_psize;
212
103#endif /* !__ASSEMBLY__ */ 213#endif /* !__ASSEMBLY__ */
104 214
105#endif /* _ASM_POWERPC_MMU_BOOK3E_H_ */ 215#endif /* _ASM_POWERPC_MMU_BOOK3E_H_ */
diff --git a/arch/powerpc/include/asm/mmu-hash32.h b/arch/powerpc/include/asm/mmu-hash32.h
index 16b1a1e77e64..16f513e5cbd7 100644
--- a/arch/powerpc/include/asm/mmu-hash32.h
+++ b/arch/powerpc/include/asm/mmu-hash32.h
@@ -55,21 +55,25 @@ struct ppc_bat {
55 55
56#ifndef __ASSEMBLY__ 56#ifndef __ASSEMBLY__
57 57
58/* Hardware Page Table Entry */ 58/*
59 * Hardware Page Table Entry
60 * Note that the xpn and x bitfields are used only by processors that
61 * support extended addressing; otherwise, those bits are reserved.
62 */
59struct hash_pte { 63struct hash_pte {
60 unsigned long v:1; /* Entry is valid */ 64 unsigned long v:1; /* Entry is valid */
61 unsigned long vsid:24; /* Virtual segment identifier */ 65 unsigned long vsid:24; /* Virtual segment identifier */
62 unsigned long h:1; /* Hash algorithm indicator */ 66 unsigned long h:1; /* Hash algorithm indicator */
63 unsigned long api:6; /* Abbreviated page index */ 67 unsigned long api:6; /* Abbreviated page index */
64 unsigned long rpn:20; /* Real (physical) page number */ 68 unsigned long rpn:20; /* Real (physical) page number */
65 unsigned long :3; /* Unused */ 69 unsigned long xpn:3; /* Real page number bits 0-2, optional */
66 unsigned long r:1; /* Referenced */ 70 unsigned long r:1; /* Referenced */
67 unsigned long c:1; /* Changed */ 71 unsigned long c:1; /* Changed */
68 unsigned long w:1; /* Write-thru cache mode */ 72 unsigned long w:1; /* Write-thru cache mode */
69 unsigned long i:1; /* Cache inhibited */ 73 unsigned long i:1; /* Cache inhibited */
70 unsigned long m:1; /* Memory coherence */ 74 unsigned long m:1; /* Memory coherence */
71 unsigned long g:1; /* Guarded */ 75 unsigned long g:1; /* Guarded */
72 unsigned long :1; /* Unused */ 76 unsigned long x:1; /* Real page number bit 3, optional */
73 unsigned long pp:2; /* Page protection */ 77 unsigned long pp:2; /* Page protection */
74}; 78};
75 79
@@ -80,4 +84,10 @@ typedef struct {
80 84
81#endif /* !__ASSEMBLY__ */ 85#endif /* !__ASSEMBLY__ */
82 86
87/* We happily ignore the smaller BATs on 601, we don't actually use
88 * those definitions on hash32 at the moment anyway
89 */
90#define mmu_virtual_psize MMU_PAGE_4K
91#define mmu_linear_psize MMU_PAGE_256M
92
83#endif /* _ASM_POWERPC_MMU_HASH32_H_ */ 93#endif /* _ASM_POWERPC_MMU_HASH32_H_ */
diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
index 98c104a09961..bebe31c2e907 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -41,6 +41,7 @@ extern char initial_stab[];
41 41
42#define SLB_NUM_BOLTED 3 42#define SLB_NUM_BOLTED 3
43#define SLB_CACHE_ENTRIES 8 43#define SLB_CACHE_ENTRIES 8
44#define SLB_MIN_SIZE 32
44 45
45/* Bits in the SLB ESID word */ 46/* Bits in the SLB ESID word */
46#define SLB_ESID_V ASM_CONST(0x0000000008000000) /* valid */ 47#define SLB_ESID_V ASM_CONST(0x0000000008000000) /* valid */
@@ -139,26 +140,6 @@ struct mmu_psize_def
139#endif /* __ASSEMBLY__ */ 140#endif /* __ASSEMBLY__ */
140 141
141/* 142/*
142 * The kernel use the constants below to index in the page sizes array.
143 * The use of fixed constants for this purpose is better for performances
144 * of the low level hash refill handlers.
145 *
146 * A non supported page size has a "shift" field set to 0
147 *
148 * Any new page size being implemented can get a new entry in here. Whether
149 * the kernel will use it or not is a different matter though. The actual page
150 * size used by hugetlbfs is not defined here and may be made variable
151 */
152
153#define MMU_PAGE_4K 0 /* 4K */
154#define MMU_PAGE_64K 1 /* 64K */
155#define MMU_PAGE_64K_AP 2 /* 64K Admixed (in a 4K segment) */
156#define MMU_PAGE_1M 3 /* 1M */
157#define MMU_PAGE_16M 4 /* 16M */
158#define MMU_PAGE_16G 5 /* 16G */
159#define MMU_PAGE_COUNT 6
160
161/*
162 * Segment sizes. 143 * Segment sizes.
163 * These are the values used by hardware in the B field of 144 * These are the values used by hardware in the B field of
164 * SLB entries and the first dword of MMU hashtable entries. 145 * SLB entries and the first dword of MMU hashtable entries.
@@ -296,6 +277,7 @@ extern void slb_flush_and_rebolt(void);
296extern void stab_initialize(unsigned long stab); 277extern void stab_initialize(unsigned long stab);
297 278
298extern void slb_vmalloc_update(void); 279extern void slb_vmalloc_update(void);
280extern void slb_set_size(u16 size);
299#endif /* __ASSEMBLY__ */ 281#endif /* __ASSEMBLY__ */
300 282
301/* 283/*
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index fb57ded592f9..7ffbb65ff7a9 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -17,6 +17,7 @@
17#define MMU_FTR_TYPE_40x ASM_CONST(0x00000004) 17#define MMU_FTR_TYPE_40x ASM_CONST(0x00000004)
18#define MMU_FTR_TYPE_44x ASM_CONST(0x00000008) 18#define MMU_FTR_TYPE_44x ASM_CONST(0x00000008)
19#define MMU_FTR_TYPE_FSL_E ASM_CONST(0x00000010) 19#define MMU_FTR_TYPE_FSL_E ASM_CONST(0x00000010)
20#define MMU_FTR_TYPE_3E ASM_CONST(0x00000020)
20 21
21/* 22/*
22 * This is individual features 23 * This is individual features
@@ -57,6 +58,15 @@
57 */ 58 */
58#define MMU_FTR_TLBIE_206 ASM_CONST(0x00400000) 59#define MMU_FTR_TLBIE_206 ASM_CONST(0x00400000)
59 60
61/* Enable use of TLB reservation. Processor should support tlbsrx.
62 * instruction and MAS0[WQ].
63 */
64#define MMU_FTR_USE_TLBRSRV ASM_CONST(0x00800000)
65
66/* Use paired MAS registers (MAS7||MAS3, etc.)
67 */
68#define MMU_FTR_USE_PAIRED_MAS ASM_CONST(0x01000000)
69
60#ifndef __ASSEMBLY__ 70#ifndef __ASSEMBLY__
61#include <asm/cputable.h> 71#include <asm/cputable.h>
62 72
@@ -73,6 +83,41 @@ extern void early_init_mmu_secondary(void);
73 83
74#endif /* !__ASSEMBLY__ */ 84#endif /* !__ASSEMBLY__ */
75 85
86/* The kernel use the constants below to index in the page sizes array.
87 * The use of fixed constants for this purpose is better for performances
88 * of the low level hash refill handlers.
89 *
90 * A non supported page size has a "shift" field set to 0
91 *
92 * Any new page size being implemented can get a new entry in here. Whether
93 * the kernel will use it or not is a different matter though. The actual page
94 * size used by hugetlbfs is not defined here and may be made variable
95 *
96 * Note: This array ended up being a false good idea as it's growing to the
97 * point where I wonder if we should replace it with something different,
98 * to think about, feedback welcome. --BenH.
99 */
100
101/* There are #define as they have to be used in assembly
102 *
103 * WARNING: If you change this list, make sure to update the array of
104 * names currently in arch/powerpc/mm/hugetlbpage.c or bad things will
105 * happen
106 */
107#define MMU_PAGE_4K 0
108#define MMU_PAGE_16K 1
109#define MMU_PAGE_64K 2
110#define MMU_PAGE_64K_AP 3 /* "Admixed pages" (hash64 only) */
111#define MMU_PAGE_256K 4
112#define MMU_PAGE_1M 5
113#define MMU_PAGE_8M 6
114#define MMU_PAGE_16M 7
115#define MMU_PAGE_256M 8
116#define MMU_PAGE_1G 9
117#define MMU_PAGE_16G 10
118#define MMU_PAGE_64G 11
119#define MMU_PAGE_COUNT 12
120
76 121
77#if defined(CONFIG_PPC_STD_MMU_64) 122#if defined(CONFIG_PPC_STD_MMU_64)
78/* 64-bit classic hash table MMU */ 123/* 64-bit classic hash table MMU */
@@ -94,5 +139,6 @@ extern void early_init_mmu_secondary(void);
94# include <asm/mmu-8xx.h> 139# include <asm/mmu-8xx.h>
95#endif 140#endif
96 141
142
97#endif /* __KERNEL__ */ 143#endif /* __KERNEL__ */
98#endif /* _ASM_POWERPC_MMU_H_ */ 144#endif /* _ASM_POWERPC_MMU_H_ */
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
index b7063669f972..b34e94d94435 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -14,7 +14,6 @@
14/* 14/*
15 * Most if the context management is out of line 15 * Most if the context management is out of line
16 */ 16 */
17extern void mmu_context_init(void);
18extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm); 17extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
19extern void destroy_context(struct mm_struct *mm); 18extern void destroy_context(struct mm_struct *mm);
20 19
@@ -23,6 +22,12 @@ extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
23extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm); 22extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
24extern void set_context(unsigned long id, pgd_t *pgd); 23extern void set_context(unsigned long id, pgd_t *pgd);
25 24
25#ifdef CONFIG_PPC_BOOK3S_64
26static inline void mmu_context_init(void) { }
27#else
28extern void mmu_context_init(void);
29#endif
30
26/* 31/*
27 * switch_mm is the entry point called from the architecture independent 32 * switch_mm is the entry point called from the architecture independent
28 * code in kernel/sched.c 33 * code in kernel/sched.c
@@ -38,6 +43,10 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
38 tsk->thread.pgdir = next->pgd; 43 tsk->thread.pgdir = next->pgd;
39#endif /* CONFIG_PPC32 */ 44#endif /* CONFIG_PPC32 */
40 45
46 /* 64-bit Book3E keeps track of current PGD in the PACA */
47#ifdef CONFIG_PPC_BOOK3E_64
48 get_paca()->pgd = next->pgd;
49#endif
41 /* Nothing else to do if we aren't actually switching */ 50 /* Nothing else to do if we aren't actually switching */
42 if (prev == next) 51 if (prev == next)
43 return; 52 return;
@@ -84,6 +93,10 @@ static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
84static inline void enter_lazy_tlb(struct mm_struct *mm, 93static inline void enter_lazy_tlb(struct mm_struct *mm,
85 struct task_struct *tsk) 94 struct task_struct *tsk)
86{ 95{
96 /* 64-bit Book3E keeps track of current PGD in the PACA */
97#ifdef CONFIG_PPC_BOOK3E_64
98 get_paca()->pgd = NULL;
99#endif
87} 100}
88 101
89#endif /* __KERNEL__ */ 102#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/nvram.h b/arch/powerpc/include/asm/nvram.h
index efde5ac82f7b..6c587eddee59 100644
--- a/arch/powerpc/include/asm/nvram.h
+++ b/arch/powerpc/include/asm/nvram.h
@@ -107,6 +107,9 @@ extern void pmac_xpram_write(int xpaddr, u8 data);
107/* Synchronize NVRAM */ 107/* Synchronize NVRAM */
108extern void nvram_sync(void); 108extern void nvram_sync(void);
109 109
110/* Determine NVRAM size */
111extern ssize_t nvram_get_size(void);
112
110/* Normal access to NVRAM */ 113/* Normal access to NVRAM */
111extern unsigned char nvram_read_byte(int i); 114extern unsigned char nvram_read_byte(int i);
112extern void nvram_write_byte(unsigned char c, int i); 115extern void nvram_write_byte(unsigned char c, int i);
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index c8a3cbfe02ff..b634456ea893 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -14,9 +14,11 @@
14#define _ASM_POWERPC_PACA_H 14#define _ASM_POWERPC_PACA_H
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16 16
17#include <asm/types.h> 17#include <asm/types.h>
18#include <asm/lppaca.h> 18#include <asm/lppaca.h>
19#include <asm/mmu.h> 19#include <asm/mmu.h>
20#include <asm/page.h>
21#include <asm/exception-64e.h>
20 22
21register struct paca_struct *local_paca asm("r13"); 23register struct paca_struct *local_paca asm("r13");
22 24
@@ -91,6 +93,21 @@ struct paca_struct {
91 u16 slb_cache[SLB_CACHE_ENTRIES]; 93 u16 slb_cache[SLB_CACHE_ENTRIES];
92#endif /* CONFIG_PPC_STD_MMU_64 */ 94#endif /* CONFIG_PPC_STD_MMU_64 */
93 95
96#ifdef CONFIG_PPC_BOOK3E
97 pgd_t *pgd; /* Current PGD */
98 pgd_t *kernel_pgd; /* Kernel PGD */
99 u64 exgen[8] __attribute__((aligned(0x80)));
100 u64 extlb[EX_TLB_SIZE*3] __attribute__((aligned(0x80)));
101 u64 exmc[8]; /* used for machine checks */
102 u64 excrit[8]; /* used for crit interrupts */
103 u64 exdbg[8]; /* used for debug interrupts */
104
105 /* Kernel stack pointers for use by special exceptions */
106 void *mc_kstack;
107 void *crit_kstack;
108 void *dbg_kstack;
109#endif /* CONFIG_PPC_BOOK3E */
110
94 mm_context_t context; 111 mm_context_t context;
95 112
96 /* 113 /*
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 4940662ee87e..ff24254990e1 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -139,7 +139,11 @@ extern phys_addr_t kernstart_addr;
139 * Don't compare things with KERNELBASE or PAGE_OFFSET to test for 139 * Don't compare things with KERNELBASE or PAGE_OFFSET to test for
140 * "kernelness", use is_kernel_addr() - it should do what you want. 140 * "kernelness", use is_kernel_addr() - it should do what you want.
141 */ 141 */
142#ifdef CONFIG_PPC_BOOK3E_64
143#define is_kernel_addr(x) ((x) >= 0x8000000000000000ul)
144#else
142#define is_kernel_addr(x) ((x) >= PAGE_OFFSET) 145#define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
146#endif
143 147
144#ifndef __ASSEMBLY__ 148#ifndef __ASSEMBLY__
145 149
diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index 5817a3b747e5..3f17b83f55a1 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -135,12 +135,22 @@ extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
135#endif /* __ASSEMBLY__ */ 135#endif /* __ASSEMBLY__ */
136#else 136#else
137#define slice_init() 137#define slice_init()
138#ifdef CONFIG_PPC_STD_MMU_64
138#define get_slice_psize(mm, addr) ((mm)->context.user_psize) 139#define get_slice_psize(mm, addr) ((mm)->context.user_psize)
139#define slice_set_user_psize(mm, psize) \ 140#define slice_set_user_psize(mm, psize) \
140do { \ 141do { \
141 (mm)->context.user_psize = (psize); \ 142 (mm)->context.user_psize = (psize); \
142 (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \ 143 (mm)->context.sllp = SLB_VSID_USER | mmu_psize_defs[(psize)].sllp; \
143} while (0) 144} while (0)
145#else /* CONFIG_PPC_STD_MMU_64 */
146#ifdef CONFIG_PPC_64K_PAGES
147#define get_slice_psize(mm, addr) MMU_PAGE_64K
148#else /* CONFIG_PPC_64K_PAGES */
149#define get_slice_psize(mm, addr) MMU_PAGE_4K
150#endif /* !CONFIG_PPC_64K_PAGES */
151#define slice_set_user_psize(mm, psize) do { BUG(); } while(0)
152#endif /* !CONFIG_PPC_STD_MMU_64 */
153
144#define slice_set_range_psize(mm, start, len, psize) \ 154#define slice_set_range_psize(mm, start, len, psize) \
145 slice_set_user_psize((mm), (psize)) 155 slice_set_user_psize((mm), (psize))
146#define slice_mm_new_context(mm) 1 156#define slice_mm_new_context(mm) 1
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 4c61fa0b8d75..76e1f313a58e 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -77,9 +77,7 @@ struct pci_controller {
77 77
78 int first_busno; 78 int first_busno;
79 int last_busno; 79 int last_busno;
80#ifndef CONFIG_PPC64
81 int self_busno; 80 int self_busno;
82#endif
83 81
84 void __iomem *io_base_virt; 82 void __iomem *io_base_virt;
85#ifdef CONFIG_PPC64 83#ifdef CONFIG_PPC64
@@ -104,7 +102,6 @@ struct pci_controller {
104 unsigned int __iomem *cfg_addr; 102 unsigned int __iomem *cfg_addr;
105 void __iomem *cfg_data; 103 void __iomem *cfg_data;
106 104
107#ifndef CONFIG_PPC64
108 /* 105 /*
109 * Used for variants of PCI indirect handling and possible quirks: 106 * Used for variants of PCI indirect handling and possible quirks:
110 * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1 107 * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1
@@ -128,7 +125,6 @@ struct pci_controller {
128#define PPC_INDIRECT_TYPE_BIG_ENDIAN 0x00000010 125#define PPC_INDIRECT_TYPE_BIG_ENDIAN 0x00000010
129#define PPC_INDIRECT_TYPE_BROKEN_MRM 0x00000020 126#define PPC_INDIRECT_TYPE_BROKEN_MRM 0x00000020
130 u32 indirect_type; 127 u32 indirect_type;
131#endif /* !CONFIG_PPC64 */
132 /* Currently, we limit ourselves to 1 IO range and 3 mem 128 /* Currently, we limit ourselves to 1 IO range and 3 mem
133 * ranges since the common pci_bus structure can't handle more 129 * ranges since the common pci_bus structure can't handle more
134 */ 130 */
@@ -146,21 +142,6 @@ struct pci_controller {
146#endif /* CONFIG_PPC64 */ 142#endif /* CONFIG_PPC64 */
147}; 143};
148 144
149#ifndef CONFIG_PPC64
150
151static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
152{
153 return bus->sysdata;
154}
155
156static inline int isa_vaddr_is_ioport(void __iomem *address)
157{
158 /* No specific ISA handling on ppc32 at this stage, it
159 * all goes through PCI
160 */
161 return 0;
162}
163
164/* These are used for config access before all the PCI probing 145/* These are used for config access before all the PCI probing
165 has been done. */ 146 has been done. */
166extern int early_read_config_byte(struct pci_controller *hose, int bus, 147extern int early_read_config_byte(struct pci_controller *hose, int bus,
@@ -182,6 +163,22 @@ extern int early_find_capability(struct pci_controller *hose, int bus,
182extern void setup_indirect_pci(struct pci_controller* hose, 163extern void setup_indirect_pci(struct pci_controller* hose,
183 resource_size_t cfg_addr, 164 resource_size_t cfg_addr,
184 resource_size_t cfg_data, u32 flags); 165 resource_size_t cfg_data, u32 flags);
166
167#ifndef CONFIG_PPC64
168
169static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
170{
171 return bus->sysdata;
172}
173
174static inline int isa_vaddr_is_ioport(void __iomem *address)
175{
176 /* No specific ISA handling on ppc32 at this stage, it
177 * all goes through PCI
178 */
179 return 0;
180}
181
185#else /* CONFIG_PPC64 */ 182#else /* CONFIG_PPC64 */
186 183
187/* 184/*
@@ -284,11 +281,6 @@ static inline int isa_vaddr_is_ioport(void __iomem *address)
284extern int pcibios_unmap_io_space(struct pci_bus *bus); 281extern int pcibios_unmap_io_space(struct pci_bus *bus);
285extern int pcibios_map_io_space(struct pci_bus *bus); 282extern int pcibios_map_io_space(struct pci_bus *bus);
286 283
287/* Return values for ppc_md.pci_probe_mode function */
288#define PCI_PROBE_NONE -1 /* Don't look at this bus at all */
289#define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */
290#define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */
291
292#ifdef CONFIG_NUMA 284#ifdef CONFIG_NUMA
293#define PHB_SET_NODE(PHB, NODE) ((PHB)->node = (NODE)) 285#define PHB_SET_NODE(PHB, NODE) ((PHB)->node = (NODE))
294#else 286#else
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index d9483c504d2d..b5ea626eea2d 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -22,6 +22,11 @@
22 22
23#include <asm-generic/pci-dma-compat.h> 23#include <asm-generic/pci-dma-compat.h>
24 24
25/* Return values for ppc_md.pci_probe_mode function */
26#define PCI_PROBE_NONE -1 /* Don't look at this bus at all */
27#define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */
28#define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */
29
25#define PCIBIOS_MIN_IO 0x1000 30#define PCIBIOS_MIN_IO 0x1000
26#define PCIBIOS_MIN_MEM 0x10000000 31#define PCIBIOS_MIN_MEM 0x10000000
27 32
@@ -40,7 +45,6 @@ struct pci_dev;
40 */ 45 */
41#define pcibios_assign_all_busses() \ 46#define pcibios_assign_all_busses() \
42 (ppc_pci_has_flag(PPC_PCI_REASSIGN_ALL_BUS)) 47 (ppc_pci_has_flag(PPC_PCI_REASSIGN_ALL_BUS))
43#define pcibios_scan_all_fns(a, b) 0
44 48
45static inline void pcibios_set_master(struct pci_dev *dev) 49static inline void pcibios_set_master(struct pci_dev *dev)
46{ 50{
@@ -61,8 +65,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
61} 65}
62 66
63#ifdef CONFIG_PCI 67#ifdef CONFIG_PCI
64extern void set_pci_dma_ops(struct dma_mapping_ops *dma_ops); 68extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
65extern struct dma_mapping_ops *get_pci_dma_ops(void); 69extern struct dma_map_ops *get_pci_dma_ops(void);
66#else /* CONFIG_PCI */ 70#else /* CONFIG_PCI */
67#define set_pci_dma_ops(d) 71#define set_pci_dma_ops(d)
68#define get_pci_dma_ops() NULL 72#define get_pci_dma_ops() NULL
@@ -228,6 +232,8 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
228 232
229extern void pcibios_setup_bus_devices(struct pci_bus *bus); 233extern void pcibios_setup_bus_devices(struct pci_bus *bus);
230extern void pcibios_setup_bus_self(struct pci_bus *bus); 234extern void pcibios_setup_bus_self(struct pci_bus *bus);
235extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
236extern void pcibios_scan_phb(struct pci_controller *hose, void *sysdata);
231 237
232#endif /* __KERNEL__ */ 238#endif /* __KERNEL__ */
233#endif /* __ASM_POWERPC_PCI_H */ 239#endif /* __ASM_POWERPC_PCI_H */
diff --git a/arch/powerpc/include/asm/pgalloc.h b/arch/powerpc/include/asm/pgalloc.h
index 1730e5e298d6..f2e812de7c3c 100644
--- a/arch/powerpc/include/asm/pgalloc.h
+++ b/arch/powerpc/include/asm/pgalloc.h
@@ -4,6 +4,15 @@
4 4
5#include <linux/mm.h> 5#include <linux/mm.h>
6 6
7#ifdef CONFIG_PPC_BOOK3E
8extern void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address);
9#else /* CONFIG_PPC_BOOK3E */
10static inline void tlb_flush_pgtable(struct mmu_gather *tlb,
11 unsigned long address)
12{
13}
14#endif /* !CONFIG_PPC_BOOK3E */
15
7static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) 16static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
8{ 17{
9 free_page((unsigned long)pte); 18 free_page((unsigned long)pte);
@@ -19,7 +28,12 @@ typedef struct pgtable_free {
19 unsigned long val; 28 unsigned long val;
20} pgtable_free_t; 29} pgtable_free_t;
21 30
22#define PGF_CACHENUM_MASK 0x7 31/* This needs to be big enough to allow for MMU_PAGE_COUNT + 2 to be stored
32 * and small enough to fit in the low bits of any naturally aligned page
33 * table cache entry. Arbitrarily set to 0x1f, that should give us some
34 * room to grow
35 */
36#define PGF_CACHENUM_MASK 0x1f
23 37
24static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum, 38static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum,
25 unsigned long mask) 39 unsigned long mask)
@@ -35,19 +49,27 @@ static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum,
35#include <asm/pgalloc-32.h> 49#include <asm/pgalloc-32.h>
36#endif 50#endif
37 51
38extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf);
39
40#ifdef CONFIG_SMP 52#ifdef CONFIG_SMP
41#define __pte_free_tlb(tlb,ptepage,address) \ 53extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf);
42do { \ 54extern void pte_free_finish(void);
43 pgtable_page_dtor(ptepage); \ 55#else /* CONFIG_SMP */
44 pgtable_free_tlb(tlb, pgtable_free_cache(page_address(ptepage), \ 56static inline void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf)
45 PTE_NONCACHE_NUM, PTE_TABLE_SIZE-1)); \ 57{
46} while (0) 58 pgtable_free(pgf);
47#else 59}
48#define __pte_free_tlb(tlb, pte, address) pte_free((tlb)->mm, (pte)) 60static inline void pte_free_finish(void) { }
49#endif 61#endif /* !CONFIG_SMP */
50 62
63static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
64 unsigned long address)
65{
66 pgtable_free_t pgf = pgtable_free_cache(page_address(ptepage),
67 PTE_NONCACHE_NUM,
68 PTE_TABLE_SIZE-1);
69 tlb_flush_pgtable(tlb, address);
70 pgtable_page_dtor(ptepage);
71 pgtable_free_tlb(tlb, pgf);
72}
51 73
52#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
53#endif /* _ASM_POWERPC_PGALLOC_H */ 75#endif /* _ASM_POWERPC_PGALLOC_H */
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
index c9ff9d75990e..55646adfa843 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -111,6 +111,8 @@ extern int icache_44x_need_flush;
111#include <asm/pte-40x.h> 111#include <asm/pte-40x.h>
112#elif defined(CONFIG_44x) 112#elif defined(CONFIG_44x)
113#include <asm/pte-44x.h> 113#include <asm/pte-44x.h>
114#elif defined(CONFIG_FSL_BOOKE) && defined(CONFIG_PTE_64BIT)
115#include <asm/pte-book3e.h>
114#elif defined(CONFIG_FSL_BOOKE) 116#elif defined(CONFIG_FSL_BOOKE)
115#include <asm/pte-fsl-booke.h> 117#include <asm/pte-fsl-booke.h>
116#elif defined(CONFIG_8xx) 118#elif defined(CONFIG_8xx)
@@ -186,7 +188,7 @@ static inline unsigned long pte_update(pte_t *p,
186#endif /* !PTE_ATOMIC_UPDATES */ 188#endif /* !PTE_ATOMIC_UPDATES */
187 189
188#ifdef CONFIG_44x 190#ifdef CONFIG_44x
189 if ((old & _PAGE_USER) && (old & _PAGE_HWEXEC)) 191 if ((old & _PAGE_USER) && (old & _PAGE_EXEC))
190 icache_44x_need_flush = 1; 192 icache_44x_need_flush = 1;
191#endif 193#endif
192 return old; 194 return old;
@@ -217,7 +219,7 @@ static inline unsigned long long pte_update(pte_t *p,
217#endif /* !PTE_ATOMIC_UPDATES */ 219#endif /* !PTE_ATOMIC_UPDATES */
218 220
219#ifdef CONFIG_44x 221#ifdef CONFIG_44x
220 if ((old & _PAGE_USER) && (old & _PAGE_HWEXEC)) 222 if ((old & _PAGE_USER) && (old & _PAGE_EXEC))
221 icache_44x_need_flush = 1; 223 icache_44x_need_flush = 1;
222#endif 224#endif
223 return old; 225 return old;
@@ -267,8 +269,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
267static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) 269static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
268{ 270{
269 unsigned long bits = pte_val(entry) & 271 unsigned long bits = pte_val(entry) &
270 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | 272 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
271 _PAGE_HWEXEC | _PAGE_EXEC);
272 pte_update(ptep, 0, bits); 273 pte_update(ptep, 0, bits);
273} 274}
274 275
diff --git a/arch/powerpc/include/asm/pgtable-ppc64-64k.h b/arch/powerpc/include/asm/pgtable-ppc64-64k.h
index 6cc085b945a5..90533ddcd703 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64-64k.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64-64k.h
@@ -10,10 +10,10 @@
10#define PGD_INDEX_SIZE 4 10#define PGD_INDEX_SIZE 4
11 11
12#ifndef __ASSEMBLY__ 12#ifndef __ASSEMBLY__
13
14#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE) 13#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE)
15#define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE) 14#define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE)
16#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE) 15#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
16#endif /* __ASSEMBLY__ */
17 17
18#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE) 18#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)
19#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE) 19#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
@@ -32,8 +32,6 @@
32#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 32#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
33#define PGDIR_MASK (~(PGDIR_SIZE-1)) 33#define PGDIR_MASK (~(PGDIR_SIZE-1))
34 34
35#endif /* __ASSEMBLY__ */
36
37/* Bits to mask out from a PMD to get to the PTE page */ 35/* Bits to mask out from a PMD to get to the PTE page */
38#define PMD_MASKED_BITS 0x1ff 36#define PMD_MASKED_BITS 0x1ff
39/* Bits to mask out from a PGD/PUD to get to the PMD page */ 37/* Bits to mask out from a PGD/PUD to get to the PMD page */
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
index 8cd083c61503..806abe7a3fa5 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -5,11 +5,6 @@
5 * the ppc64 hashed page table. 5 * the ppc64 hashed page table.
6 */ 6 */
7 7
8#ifndef __ASSEMBLY__
9#include <linux/stddef.h>
10#include <asm/tlbflush.h>
11#endif /* __ASSEMBLY__ */
12
13#ifdef CONFIG_PPC_64K_PAGES 8#ifdef CONFIG_PPC_64K_PAGES
14#include <asm/pgtable-ppc64-64k.h> 9#include <asm/pgtable-ppc64-64k.h>
15#else 10#else
@@ -38,26 +33,47 @@
38#endif 33#endif
39 34
40/* 35/*
41 * Define the address range of the vmalloc VM area. 36 * Define the address range of the kernel non-linear virtual area
37 */
38
39#ifdef CONFIG_PPC_BOOK3E
40#define KERN_VIRT_START ASM_CONST(0x8000000000000000)
41#else
42#define KERN_VIRT_START ASM_CONST(0xD000000000000000)
43#endif
44#define KERN_VIRT_SIZE PGTABLE_RANGE
45
46/*
47 * The vmalloc space starts at the beginning of that region, and
48 * occupies half of it on hash CPUs and a quarter of it on Book3E
49 * (we keep a quarter for the virtual memmap)
42 */ 50 */
43#define VMALLOC_START ASM_CONST(0xD000000000000000) 51#define VMALLOC_START KERN_VIRT_START
44#define VMALLOC_SIZE (PGTABLE_RANGE >> 1) 52#ifdef CONFIG_PPC_BOOK3E
45#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE) 53#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 2)
54#else
55#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
56#endif
57#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE)
46 58
47/* 59/*
48 * Define the address ranges for MMIO and IO space : 60 * The second half of the kernel virtual space is used for IO mappings,
61 * it's itself carved into the PIO region (ISA and PHB IO space) and
62 * the ioremap space
49 * 63 *
50 * ISA_IO_BASE = VMALLOC_END, 64K reserved area 64 * ISA_IO_BASE = KERN_IO_START, 64K reserved area
51 * PHB_IO_BASE = ISA_IO_BASE + 64K to ISA_IO_BASE + 2G, PHB IO spaces 65 * PHB_IO_BASE = ISA_IO_BASE + 64K to ISA_IO_BASE + 2G, PHB IO spaces
52 * IOREMAP_BASE = ISA_IO_BASE + 2G to VMALLOC_START + PGTABLE_RANGE 66 * IOREMAP_BASE = ISA_IO_BASE + 2G to VMALLOC_START + PGTABLE_RANGE
53 */ 67 */
68#define KERN_IO_START (KERN_VIRT_START + (KERN_VIRT_SIZE >> 1))
54#define FULL_IO_SIZE 0x80000000ul 69#define FULL_IO_SIZE 0x80000000ul
55#define ISA_IO_BASE (VMALLOC_END) 70#define ISA_IO_BASE (KERN_IO_START)
56#define ISA_IO_END (VMALLOC_END + 0x10000ul) 71#define ISA_IO_END (KERN_IO_START + 0x10000ul)
57#define PHB_IO_BASE (ISA_IO_END) 72#define PHB_IO_BASE (ISA_IO_END)
58#define PHB_IO_END (VMALLOC_END + FULL_IO_SIZE) 73#define PHB_IO_END (KERN_IO_START + FULL_IO_SIZE)
59#define IOREMAP_BASE (PHB_IO_END) 74#define IOREMAP_BASE (PHB_IO_END)
60#define IOREMAP_END (VMALLOC_START + PGTABLE_RANGE) 75#define IOREMAP_END (KERN_VIRT_START + KERN_VIRT_SIZE)
76
61 77
62/* 78/*
63 * Region IDs 79 * Region IDs
@@ -68,23 +84,32 @@
68 84
69#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START)) 85#define VMALLOC_REGION_ID (REGION_ID(VMALLOC_START))
70#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET)) 86#define KERNEL_REGION_ID (REGION_ID(PAGE_OFFSET))
71#define VMEMMAP_REGION_ID (0xfUL) 87#define VMEMMAP_REGION_ID (0xfUL) /* Server only */
72#define USER_REGION_ID (0UL) 88#define USER_REGION_ID (0UL)
73 89
74/* 90/*
75 * Defines the address of the vmemap area, in its own region 91 * Defines the address of the vmemap area, in its own region on
92 * hash table CPUs and after the vmalloc space on Book3E
76 */ 93 */
94#ifdef CONFIG_PPC_BOOK3E
95#define VMEMMAP_BASE VMALLOC_END
96#define VMEMMAP_END KERN_IO_START
97#else
77#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT) 98#define VMEMMAP_BASE (VMEMMAP_REGION_ID << REGION_SHIFT)
99#endif
78#define vmemmap ((struct page *)VMEMMAP_BASE) 100#define vmemmap ((struct page *)VMEMMAP_BASE)
79 101
80 102
81/* 103/*
82 * Include the PTE bits definitions 104 * Include the PTE bits definitions
83 */ 105 */
106#ifdef CONFIG_PPC_BOOK3S
84#include <asm/pte-hash64.h> 107#include <asm/pte-hash64.h>
108#else
109#include <asm/pte-book3e.h>
110#endif
85#include <asm/pte-common.h> 111#include <asm/pte-common.h>
86 112
87
88#ifdef CONFIG_PPC_MM_SLICES 113#ifdef CONFIG_PPC_MM_SLICES
89#define HAVE_ARCH_UNMAPPED_AREA 114#define HAVE_ARCH_UNMAPPED_AREA
90#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN 115#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
@@ -92,6 +117,9 @@
92 117
93#ifndef __ASSEMBLY__ 118#ifndef __ASSEMBLY__
94 119
120#include <linux/stddef.h>
121#include <asm/tlbflush.h>
122
95/* 123/*
96 * This is the default implementation of various PTE accessors, it's 124 * This is the default implementation of various PTE accessors, it's
97 * used in all cases except Book3S with 64K pages where we have a 125 * used in all cases except Book3S with 64K pages where we have a
@@ -285,8 +313,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
285static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) 313static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
286{ 314{
287 unsigned long bits = pte_val(entry) & 315 unsigned long bits = pte_val(entry) &
288 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | 316 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
289 _PAGE_EXEC | _PAGE_HWEXEC);
290 317
291#ifdef PTE_ATOMIC_UPDATES 318#ifdef PTE_ATOMIC_UPDATES
292 unsigned long old, tmp; 319 unsigned long old, tmp;
diff --git a/arch/powerpc/include/asm/pmc.h b/arch/powerpc/include/asm/pmc.h
index d6a616a1b3ea..ccc68b50d05d 100644
--- a/arch/powerpc/include/asm/pmc.h
+++ b/arch/powerpc/include/asm/pmc.h
@@ -27,10 +27,22 @@ extern perf_irq_t perf_irq;
27 27
28int reserve_pmc_hardware(perf_irq_t new_perf_irq); 28int reserve_pmc_hardware(perf_irq_t new_perf_irq);
29void release_pmc_hardware(void); 29void release_pmc_hardware(void);
30void ppc_enable_pmcs(void);
30 31
31#ifdef CONFIG_PPC64 32#ifdef CONFIG_PPC64
32void power4_enable_pmcs(void); 33#include <asm/lppaca.h>
33void pasemi_enable_pmcs(void); 34
35static inline void ppc_set_pmu_inuse(int inuse)
36{
37 get_lppaca()->pmcregs_in_use = inuse;
38}
39
40extern void power4_enable_pmcs(void);
41
42#else /* CONFIG_PPC64 */
43
44static inline void ppc_set_pmu_inuse(int inuse) { }
45
34#endif 46#endif
35 47
36#endif /* __KERNEL__ */ 48#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index b74f16d45cb4..ef9aa84cac5a 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -48,6 +48,8 @@
48#define PPC_INST_TLBIE 0x7c000264 48#define PPC_INST_TLBIE 0x7c000264
49#define PPC_INST_TLBILX 0x7c000024 49#define PPC_INST_TLBILX 0x7c000024
50#define PPC_INST_WAIT 0x7c00007c 50#define PPC_INST_WAIT 0x7c00007c
51#define PPC_INST_TLBIVAX 0x7c000624
52#define PPC_INST_TLBSRX_DOT 0x7c0006a5
51 53
52/* macros to insert fields into opcodes */ 54/* macros to insert fields into opcodes */
53#define __PPC_RA(a) (((a) & 0x1f) << 16) 55#define __PPC_RA(a) (((a) & 0x1f) << 16)
@@ -76,6 +78,10 @@
76 __PPC_WC(w)) 78 __PPC_WC(w))
77#define PPC_TLBIE(lp,a) stringify_in_c(.long PPC_INST_TLBIE | \ 79#define PPC_TLBIE(lp,a) stringify_in_c(.long PPC_INST_TLBIE | \
78 __PPC_RB(a) | __PPC_RS(lp)) 80 __PPC_RB(a) | __PPC_RS(lp))
81#define PPC_TLBSRX_DOT(a,b) stringify_in_c(.long PPC_INST_TLBSRX_DOT | \
82 __PPC_RA(a) | __PPC_RB(b))
83#define PPC_TLBIVAX(a,b) stringify_in_c(.long PPC_INST_TLBIVAX | \
84 __PPC_RA(a) | __PPC_RB(b))
79 85
80/* 86/*
81 * Define what the VSX XX1 form instructions will look like, then add 87 * Define what the VSX XX1 form instructions will look like, then add
diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h
index 854ab713f56c..2828f9d0f66d 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -39,7 +39,6 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre,
39 39
40extern void pci_devs_phb_init(void); 40extern void pci_devs_phb_init(void);
41extern void pci_devs_phb_init_dynamic(struct pci_controller *phb); 41extern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
42extern void scan_phb(struct pci_controller *hose);
43 42
44/* From rtas_pci.h */ 43/* From rtas_pci.h */
45extern void init_pci_config_tokens (void); 44extern void init_pci_config_tokens (void);
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index f9729529c20d..498fe09263d3 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -98,13 +98,13 @@ END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
98#define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base) 98#define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base)
99#define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base) 99#define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base)
100 100
101#define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,b,base 101#define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,base,b
102#define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base) 102#define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base)
103#define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base) 103#define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base)
104#define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base) 104#define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base)
105#define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base) 105#define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base)
106#define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base) 106#define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base)
107#define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,b,base 107#define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,base,b
108#define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base) 108#define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base)
109#define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base) 109#define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base)
110#define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base) 110#define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base)
@@ -112,26 +112,26 @@ END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
112#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base) 112#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base)
113 113
114/* Save the lower 32 VSRs in the thread VSR region */ 114/* Save the lower 32 VSRs in the thread VSR region */
115#define SAVE_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); STXVD2X(n,b,base) 115#define SAVE_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); STXVD2X(n,base,b)
116#define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base) 116#define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base)
117#define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base) 117#define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base)
118#define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base) 118#define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base)
119#define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base) 119#define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base)
120#define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base) 120#define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base)
121#define REST_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); LXVD2X(n,b,base) 121#define REST_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); LXVD2X(n,base,b)
122#define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base) 122#define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base)
123#define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base) 123#define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base)
124#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base) 124#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base)
125#define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base) 125#define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base)
126#define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base) 126#define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base)
127/* Save the upper 32 VSRs (32-63) in the thread VSX region (0-31) */ 127/* Save the upper 32 VSRs (32-63) in the thread VSX region (0-31) */
128#define SAVE_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); STXVD2X(n+32,b,base) 128#define SAVE_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); STXVD2X(n+32,base,b)
129#define SAVE_2VSRSU(n,b,base) SAVE_VSRU(n,b,base); SAVE_VSRU(n+1,b,base) 129#define SAVE_2VSRSU(n,b,base) SAVE_VSRU(n,b,base); SAVE_VSRU(n+1,b,base)
130#define SAVE_4VSRSU(n,b,base) SAVE_2VSRSU(n,b,base); SAVE_2VSRSU(n+2,b,base) 130#define SAVE_4VSRSU(n,b,base) SAVE_2VSRSU(n,b,base); SAVE_2VSRSU(n+2,b,base)
131#define SAVE_8VSRSU(n,b,base) SAVE_4VSRSU(n,b,base); SAVE_4VSRSU(n+4,b,base) 131#define SAVE_8VSRSU(n,b,base) SAVE_4VSRSU(n,b,base); SAVE_4VSRSU(n+4,b,base)
132#define SAVE_16VSRSU(n,b,base) SAVE_8VSRSU(n,b,base); SAVE_8VSRSU(n+8,b,base) 132#define SAVE_16VSRSU(n,b,base) SAVE_8VSRSU(n,b,base); SAVE_8VSRSU(n+8,b,base)
133#define SAVE_32VSRSU(n,b,base) SAVE_16VSRSU(n,b,base); SAVE_16VSRSU(n+16,b,base) 133#define SAVE_32VSRSU(n,b,base) SAVE_16VSRSU(n,b,base); SAVE_16VSRSU(n+16,b,base)
134#define REST_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,b,base) 134#define REST_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,base,b)
135#define REST_2VSRSU(n,b,base) REST_VSRU(n,b,base); REST_VSRU(n+1,b,base) 135#define REST_2VSRSU(n,b,base) REST_VSRU(n,b,base); REST_VSRU(n+1,b,base)
136#define REST_4VSRSU(n,b,base) REST_2VSRSU(n,b,base); REST_2VSRSU(n+2,b,base) 136#define REST_4VSRSU(n,b,base) REST_2VSRSU(n,b,base); REST_2VSRSU(n+2,b,base)
137#define REST_8VSRSU(n,b,base) REST_4VSRSU(n,b,base); REST_4VSRSU(n+4,b,base) 137#define REST_8VSRSU(n,b,base) REST_4VSRSU(n,b,base); REST_4VSRSU(n+4,b,base)
@@ -375,8 +375,15 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
375#define PPC440EP_ERR42 375#define PPC440EP_ERR42
376#endif 376#endif
377 377
378 378/*
379#if defined(CONFIG_BOOKE) 379 * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
380 * keep the address intact to be compatible with code shared with
381 * 32-bit classic.
382 *
383 * On the other hand, I find it useful to have them behave as expected
384 * by their name (ie always do the addition) on 64-bit BookE
385 */
386#if defined(CONFIG_BOOKE) && !defined(CONFIG_PPC64)
380#define toreal(rd) 387#define toreal(rd)
381#define fromreal(rd) 388#define fromreal(rd)
382 389
@@ -426,10 +433,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
426 .previous 433 .previous
427#endif 434#endif
428 435
429#ifdef CONFIG_PPC64 436#ifdef CONFIG_PPC_BOOK3S_64
430#define RFI rfid 437#define RFI rfid
431#define MTMSRD(r) mtmsrd r 438#define MTMSRD(r) mtmsrd r
432
433#else 439#else
434#define FIX_SRR1(ra, rb) 440#define FIX_SRR1(ra, rb)
435#ifndef CONFIG_40x 441#ifndef CONFIG_40x
diff --git a/arch/powerpc/include/asm/pte-40x.h b/arch/powerpc/include/asm/pte-40x.h
index 07630faae029..6c3e1f4378d4 100644
--- a/arch/powerpc/include/asm/pte-40x.h
+++ b/arch/powerpc/include/asm/pte-40x.h
@@ -46,7 +46,7 @@
46#define _PAGE_RW 0x040 /* software: Writes permitted */ 46#define _PAGE_RW 0x040 /* software: Writes permitted */
47#define _PAGE_DIRTY 0x080 /* software: dirty page */ 47#define _PAGE_DIRTY 0x080 /* software: dirty page */
48#define _PAGE_HWWRITE 0x100 /* hardware: Dirty & RW, set in exception */ 48#define _PAGE_HWWRITE 0x100 /* hardware: Dirty & RW, set in exception */
49#define _PAGE_HWEXEC 0x200 /* hardware: EX permission */ 49#define _PAGE_EXEC 0x200 /* hardware: EX permission */
50#define _PAGE_ACCESSED 0x400 /* software: R: page referenced */ 50#define _PAGE_ACCESSED 0x400 /* software: R: page referenced */
51 51
52#define _PMD_PRESENT 0x400 /* PMD points to page of PTEs */ 52#define _PMD_PRESENT 0x400 /* PMD points to page of PTEs */
diff --git a/arch/powerpc/include/asm/pte-44x.h b/arch/powerpc/include/asm/pte-44x.h
index 37e98bcf83e0..4192b9bad901 100644
--- a/arch/powerpc/include/asm/pte-44x.h
+++ b/arch/powerpc/include/asm/pte-44x.h
@@ -78,7 +78,7 @@
78#define _PAGE_PRESENT 0x00000001 /* S: PTE valid */ 78#define _PAGE_PRESENT 0x00000001 /* S: PTE valid */
79#define _PAGE_RW 0x00000002 /* S: Write permission */ 79#define _PAGE_RW 0x00000002 /* S: Write permission */
80#define _PAGE_FILE 0x00000004 /* S: nonlinear file mapping */ 80#define _PAGE_FILE 0x00000004 /* S: nonlinear file mapping */
81#define _PAGE_HWEXEC 0x00000004 /* H: Execute permission */ 81#define _PAGE_EXEC 0x00000004 /* H: Execute permission */
82#define _PAGE_ACCESSED 0x00000008 /* S: Page referenced */ 82#define _PAGE_ACCESSED 0x00000008 /* S: Page referenced */
83#define _PAGE_DIRTY 0x00000010 /* S: Page dirty */ 83#define _PAGE_DIRTY 0x00000010 /* S: Page dirty */
84#define _PAGE_SPECIAL 0x00000020 /* S: Special page */ 84#define _PAGE_SPECIAL 0x00000020 /* S: Special page */
diff --git a/arch/powerpc/include/asm/pte-8xx.h b/arch/powerpc/include/asm/pte-8xx.h
index 8c6e31251034..94e979718dcf 100644
--- a/arch/powerpc/include/asm/pte-8xx.h
+++ b/arch/powerpc/include/asm/pte-8xx.h
@@ -36,7 +36,6 @@
36/* These five software bits must be masked out when the entry is loaded 36/* These five software bits must be masked out when the entry is loaded
37 * into the TLB. 37 * into the TLB.
38 */ 38 */
39#define _PAGE_EXEC 0x0008 /* software: i-cache coherency required */
40#define _PAGE_GUARDED 0x0010 /* software: guarded access */ 39#define _PAGE_GUARDED 0x0010 /* software: guarded access */
41#define _PAGE_DIRTY 0x0020 /* software: page changed */ 40#define _PAGE_DIRTY 0x0020 /* software: page changed */
42#define _PAGE_RW 0x0040 /* software: user write access allowed */ 41#define _PAGE_RW 0x0040 /* software: user write access allowed */
diff --git a/arch/powerpc/include/asm/pte-book3e.h b/arch/powerpc/include/asm/pte-book3e.h
new file mode 100644
index 000000000000..082d515930a2
--- /dev/null
+++ b/arch/powerpc/include/asm/pte-book3e.h
@@ -0,0 +1,84 @@
1#ifndef _ASM_POWERPC_PTE_BOOK3E_H
2#define _ASM_POWERPC_PTE_BOOK3E_H
3#ifdef __KERNEL__
4
5/* PTE bit definitions for processors compliant to the Book3E
6 * architecture 2.06 or later. The position of the PTE bits
7 * matches the HW definition of the optional Embedded Page Table
8 * category.
9 */
10
11/* Architected bits */
12#define _PAGE_PRESENT 0x000001 /* software: pte contains a translation */
13#define _PAGE_FILE 0x000002 /* (!present only) software: pte holds file offset */
14#define _PAGE_SW1 0x000002
15#define _PAGE_BAP_SR 0x000004
16#define _PAGE_BAP_UR 0x000008
17#define _PAGE_BAP_SW 0x000010
18#define _PAGE_BAP_UW 0x000020
19#define _PAGE_BAP_SX 0x000040
20#define _PAGE_BAP_UX 0x000080
21#define _PAGE_PSIZE_MSK 0x000f00
22#define _PAGE_PSIZE_4K 0x000200
23#define _PAGE_PSIZE_8K 0x000300
24#define _PAGE_PSIZE_16K 0x000400
25#define _PAGE_PSIZE_32K 0x000500
26#define _PAGE_PSIZE_64K 0x000600
27#define _PAGE_PSIZE_128K 0x000700
28#define _PAGE_PSIZE_256K 0x000800
29#define _PAGE_PSIZE_512K 0x000900
30#define _PAGE_PSIZE_1M 0x000a00
31#define _PAGE_PSIZE_2M 0x000b00
32#define _PAGE_PSIZE_4M 0x000c00
33#define _PAGE_PSIZE_8M 0x000d00
34#define _PAGE_PSIZE_16M 0x000e00
35#define _PAGE_PSIZE_32M 0x000f00
36#define _PAGE_DIRTY 0x001000 /* C: page changed */
37#define _PAGE_SW0 0x002000
38#define _PAGE_U3 0x004000
39#define _PAGE_U2 0x008000
40#define _PAGE_U1 0x010000
41#define _PAGE_U0 0x020000
42#define _PAGE_ACCESSED 0x040000
43#define _PAGE_LENDIAN 0x080000
44#define _PAGE_GUARDED 0x100000
45#define _PAGE_COHERENT 0x200000 /* M: enforce memory coherence */
46#define _PAGE_NO_CACHE 0x400000 /* I: cache inhibit */
47#define _PAGE_WRITETHRU 0x800000 /* W: cache write-through */
48
49/* "Higher level" linux bit combinations */
50#define _PAGE_EXEC _PAGE_BAP_UX /* .. and was cache cleaned */
51#define _PAGE_RW (_PAGE_BAP_SW | _PAGE_BAP_UW) /* User write permission */
52#define _PAGE_KERNEL_RW (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY)
53#define _PAGE_KERNEL_RO (_PAGE_BAP_SR)
54#define _PAGE_KERNEL_RWX (_PAGE_BAP_SW | _PAGE_BAP_SR | _PAGE_DIRTY | _PAGE_BAP_SX)
55#define _PAGE_KERNEL_ROX (_PAGE_BAP_SR | _PAGE_BAP_SX)
56#define _PAGE_USER (_PAGE_BAP_UR | _PAGE_BAP_SR) /* Can be read */
57
58#define _PAGE_HASHPTE 0
59#define _PAGE_BUSY 0
60
61#define _PAGE_SPECIAL _PAGE_SW0
62
63/* Flags to be preserved on PTE modifications */
64#define _PAGE_HPTEFLAGS _PAGE_BUSY
65
66/* Base page size */
67#ifdef CONFIG_PPC_64K_PAGES
68#define _PAGE_PSIZE _PAGE_PSIZE_64K
69#define PTE_RPN_SHIFT (28)
70#else
71#define _PAGE_PSIZE _PAGE_PSIZE_4K
72#define PTE_RPN_SHIFT (24)
73#endif
74
75/* On 32-bit, we never clear the top part of the PTE */
76#ifdef CONFIG_PPC32
77#define _PTE_NONE_MASK 0xffffffff00000000ULL
78#define _PMD_PRESENT 0
79#define _PMD_PRESENT_MASK (PAGE_MASK)
80#define _PMD_BAD (~PAGE_MASK)
81#endif
82
83#endif /* __KERNEL__ */
84#endif /* _ASM_POWERPC_PTE_FSL_BOOKE_H */
diff --git a/arch/powerpc/include/asm/pte-common.h b/arch/powerpc/include/asm/pte-common.h
index a7e210b6b48c..c3b65076a263 100644
--- a/arch/powerpc/include/asm/pte-common.h
+++ b/arch/powerpc/include/asm/pte-common.h
@@ -13,9 +13,6 @@
13#ifndef _PAGE_HWWRITE 13#ifndef _PAGE_HWWRITE
14#define _PAGE_HWWRITE 0 14#define _PAGE_HWWRITE 0
15#endif 15#endif
16#ifndef _PAGE_HWEXEC
17#define _PAGE_HWEXEC 0
18#endif
19#ifndef _PAGE_EXEC 16#ifndef _PAGE_EXEC
20#define _PAGE_EXEC 0 17#define _PAGE_EXEC 0
21#endif 18#endif
@@ -34,6 +31,9 @@
34#ifndef _PAGE_4K_PFN 31#ifndef _PAGE_4K_PFN
35#define _PAGE_4K_PFN 0 32#define _PAGE_4K_PFN 0
36#endif 33#endif
34#ifndef _PAGE_SAO
35#define _PAGE_SAO 0
36#endif
37#ifndef _PAGE_PSIZE 37#ifndef _PAGE_PSIZE
38#define _PAGE_PSIZE 0 38#define _PAGE_PSIZE 0
39#endif 39#endif
@@ -45,10 +45,16 @@
45#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE() 45#define PMD_PAGE_SIZE(pmd) bad_call_to_PMD_PAGE_SIZE()
46#endif 46#endif
47#ifndef _PAGE_KERNEL_RO 47#ifndef _PAGE_KERNEL_RO
48#define _PAGE_KERNEL_RO 0 48#define _PAGE_KERNEL_RO 0
49#endif
50#ifndef _PAGE_KERNEL_ROX
51#define _PAGE_KERNEL_ROX (_PAGE_EXEC)
49#endif 52#endif
50#ifndef _PAGE_KERNEL_RW 53#ifndef _PAGE_KERNEL_RW
51#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE) 54#define _PAGE_KERNEL_RW (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
55#endif
56#ifndef _PAGE_KERNEL_RWX
57#define _PAGE_KERNEL_RWX (_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE | _PAGE_EXEC)
52#endif 58#endif
53#ifndef _PAGE_HPTEFLAGS 59#ifndef _PAGE_HPTEFLAGS
54#define _PAGE_HPTEFLAGS _PAGE_HASHPTE 60#define _PAGE_HPTEFLAGS _PAGE_HASHPTE
@@ -93,8 +99,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
93#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \ 99#define PAGE_PROT_BITS (_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
94 _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \ 100 _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \
95 _PAGE_USER | _PAGE_ACCESSED | \ 101 _PAGE_USER | _PAGE_ACCESSED | \
96 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \ 102 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | _PAGE_EXEC)
97 _PAGE_EXEC | _PAGE_HWEXEC)
98 103
99/* 104/*
100 * We define 2 sets of base prot bits, one for basic pages (ie, 105 * We define 2 sets of base prot bits, one for basic pages (ie,
@@ -151,11 +156,9 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
151 _PAGE_NO_CACHE) 156 _PAGE_NO_CACHE)
152#define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \ 157#define PAGE_KERNEL_NCG __pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
153 _PAGE_NO_CACHE | _PAGE_GUARDED) 158 _PAGE_NO_CACHE | _PAGE_GUARDED)
154#define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC | \ 159#define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RWX)
155 _PAGE_HWEXEC)
156#define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO) 160#define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
157#define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC | \ 161#define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_ROX)
158 _PAGE_HWEXEC)
159 162
160/* Protection used for kernel text. We want the debuggers to be able to 163/* Protection used for kernel text. We want the debuggers to be able to
161 * set breakpoints anywhere, so don't write protect the kernel text 164 * set breakpoints anywhere, so don't write protect the kernel text
diff --git a/arch/powerpc/include/asm/pte-fsl-booke.h b/arch/powerpc/include/asm/pte-fsl-booke.h
index 10820f58acf5..2c12be5f677a 100644
--- a/arch/powerpc/include/asm/pte-fsl-booke.h
+++ b/arch/powerpc/include/asm/pte-fsl-booke.h
@@ -23,7 +23,7 @@
23#define _PAGE_FILE 0x00002 /* S: when !present: nonlinear file mapping */ 23#define _PAGE_FILE 0x00002 /* S: when !present: nonlinear file mapping */
24#define _PAGE_RW 0x00004 /* S: Write permission (SW) */ 24#define _PAGE_RW 0x00004 /* S: Write permission (SW) */
25#define _PAGE_DIRTY 0x00008 /* S: Page dirty */ 25#define _PAGE_DIRTY 0x00008 /* S: Page dirty */
26#define _PAGE_HWEXEC 0x00010 /* H: SX permission */ 26#define _PAGE_EXEC 0x00010 /* H: SX permission */
27#define _PAGE_ACCESSED 0x00020 /* S: Page referenced */ 27#define _PAGE_ACCESSED 0x00020 /* S: Page referenced */
28 28
29#define _PAGE_ENDIAN 0x00040 /* H: E bit */ 29#define _PAGE_ENDIAN 0x00040 /* H: E bit */
@@ -33,13 +33,6 @@
33#define _PAGE_WRITETHRU 0x00400 /* H: W bit */ 33#define _PAGE_WRITETHRU 0x00400 /* H: W bit */
34#define _PAGE_SPECIAL 0x00800 /* S: Special page */ 34#define _PAGE_SPECIAL 0x00800 /* S: Special page */
35 35
36#ifdef CONFIG_PTE_64BIT
37/* ERPN in a PTE never gets cleared, ignore it */
38#define _PTE_NONE_MASK 0xffffffffffff0000ULL
39/* We extend the size of the PTE flags area when using 64-bit PTEs */
40#define PTE_RPN_SHIFT (PAGE_SHIFT + 8)
41#endif
42
43#define _PMD_PRESENT 0 36#define _PMD_PRESENT 0
44#define _PMD_PRESENT_MASK (PAGE_MASK) 37#define _PMD_PRESENT_MASK (PAGE_MASK)
45#define _PMD_BAD (~PAGE_MASK) 38#define _PMD_BAD (~PAGE_MASK)
diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
index 16e571c7f9ef..4aad4132d0a8 100644
--- a/arch/powerpc/include/asm/pte-hash32.h
+++ b/arch/powerpc/include/asm/pte-hash32.h
@@ -26,7 +26,6 @@
26#define _PAGE_WRITETHRU 0x040 /* W: cache write-through */ 26#define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
27#define _PAGE_DIRTY 0x080 /* C: page changed */ 27#define _PAGE_DIRTY 0x080 /* C: page changed */
28#define _PAGE_ACCESSED 0x100 /* R: page referenced */ 28#define _PAGE_ACCESSED 0x100 /* R: page referenced */
29#define _PAGE_EXEC 0x200 /* software: i-cache coherency required */
30#define _PAGE_RW 0x400 /* software: user write access allowed */ 29#define _PAGE_RW 0x400 /* software: user write access allowed */
31#define _PAGE_SPECIAL 0x800 /* software: Special page */ 30#define _PAGE_SPECIAL 0x800 /* software: Special page */
32 31
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 1170267736d3..6315edc205d8 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -98,19 +98,15 @@
98#define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */ 98#define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */
99#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */ 99#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */
100 100
101#ifdef CONFIG_PPC64 101#if defined(CONFIG_PPC_BOOK3S_64)
102/* Server variant */
102#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV 103#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV
103#define MSR_KERNEL MSR_ | MSR_SF 104#define MSR_KERNEL MSR_ | MSR_SF
104
105#define MSR_USER32 MSR_ | MSR_PR | MSR_EE 105#define MSR_USER32 MSR_ | MSR_PR | MSR_EE
106#define MSR_USER64 MSR_USER32 | MSR_SF 106#define MSR_USER64 MSR_USER32 | MSR_SF
107 107#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_8xx)
108#else /* 32-bit */
109/* Default MSR for kernel mode. */ 108/* Default MSR for kernel mode. */
110#ifndef MSR_KERNEL /* reg_booke.h also defines this */
111#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR) 109#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR)
112#endif
113
114#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) 110#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
115#endif 111#endif
116 112
@@ -646,6 +642,137 @@
646#endif 642#endif
647 643
648/* 644/*
645 * SPRG usage:
646 *
647 * All 64-bit:
648 * - SPRG1 stores PACA pointer
649 *
650 * 64-bit server:
651 * - SPRG0 unused (reserved for HV on Power4)
652 * - SPRG2 scratch for exception vectors
653 * - SPRG3 unused (user visible)
654 *
655 * 64-bit embedded
656 * - SPRG0 generic exception scratch
657 * - SPRG2 TLB exception stack
658 * - SPRG3 unused (user visible)
659 * - SPRG4 unused (user visible)
660 * - SPRG6 TLB miss scratch (user visible, sorry !)
661 * - SPRG7 critical exception scratch
662 * - SPRG8 machine check exception scratch
663 * - SPRG9 debug exception scratch
664 *
665 * All 32-bit:
666 * - SPRG3 current thread_info pointer
667 * (virtual on BookE, physical on others)
668 *
669 * 32-bit classic:
670 * - SPRG0 scratch for exception vectors
671 * - SPRG1 scratch for exception vectors
672 * - SPRG2 indicator that we are in RTAS
673 * - SPRG4 (603 only) pseudo TLB LRU data
674 *
675 * 32-bit 40x:
676 * - SPRG0 scratch for exception vectors
677 * - SPRG1 scratch for exception vectors
678 * - SPRG2 scratch for exception vectors
679 * - SPRG4 scratch for exception vectors (not 403)
680 * - SPRG5 scratch for exception vectors (not 403)
681 * - SPRG6 scratch for exception vectors (not 403)
682 * - SPRG7 scratch for exception vectors (not 403)
683 *
684 * 32-bit 440 and FSL BookE:
685 * - SPRG0 scratch for exception vectors
686 * - SPRG1 scratch for exception vectors (*)
687 * - SPRG2 scratch for crit interrupts handler
688 * - SPRG4 scratch for exception vectors
689 * - SPRG5 scratch for exception vectors
690 * - SPRG6 scratch for machine check handler
691 * - SPRG7 scratch for exception vectors
692 * - SPRG9 scratch for debug vectors (e500 only)
693 *
694 * Additionally, BookE separates "read" and "write"
695 * of those registers. That allows to use the userspace
696 * readable variant for reads, which can avoid a fault
697 * with KVM type virtualization.
698 *
699 * (*) Under KVM, the host SPRG1 is used to point to
700 * the current VCPU data structure
701 *
702 * 32-bit 8xx:
703 * - SPRG0 scratch for exception vectors
704 * - SPRG1 scratch for exception vectors
705 * - SPRG2 apparently unused but initialized
706 *
707 */
708#ifdef CONFIG_PPC64
709#define SPRN_SPRG_PACA SPRN_SPRG1
710#else
711#define SPRN_SPRG_THREAD SPRN_SPRG3
712#endif
713
714#ifdef CONFIG_PPC_BOOK3S_64
715#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2
716#endif
717
718#ifdef CONFIG_PPC_BOOK3E_64
719#define SPRN_SPRG_MC_SCRATCH SPRN_SPRG8
720#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG7
721#define SPRN_SPRG_DBG_SCRATCH SPRN_SPRG9
722#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2
723#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6
724#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0
725#endif
726
727#ifdef CONFIG_PPC_BOOK3S_32
728#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
729#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
730#define SPRN_SPRG_RTAS SPRN_SPRG2
731#define SPRN_SPRG_603_LRU SPRN_SPRG4
732#endif
733
734#ifdef CONFIG_40x
735#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
736#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
737#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2
738#define SPRN_SPRG_SCRATCH3 SPRN_SPRG4
739#define SPRN_SPRG_SCRATCH4 SPRN_SPRG5
740#define SPRN_SPRG_SCRATCH5 SPRN_SPRG6
741#define SPRN_SPRG_SCRATCH6 SPRN_SPRG7
742#endif
743
744#ifdef CONFIG_BOOKE
745#define SPRN_SPRG_RSCRATCH0 SPRN_SPRG0
746#define SPRN_SPRG_WSCRATCH0 SPRN_SPRG0
747#define SPRN_SPRG_RSCRATCH1 SPRN_SPRG1
748#define SPRN_SPRG_WSCRATCH1 SPRN_SPRG1
749#define SPRN_SPRG_RSCRATCH_CRIT SPRN_SPRG2
750#define SPRN_SPRG_WSCRATCH_CRIT SPRN_SPRG2
751#define SPRN_SPRG_RSCRATCH2 SPRN_SPRG4R
752#define SPRN_SPRG_WSCRATCH2 SPRN_SPRG4W
753#define SPRN_SPRG_RSCRATCH3 SPRN_SPRG5R
754#define SPRN_SPRG_WSCRATCH3 SPRN_SPRG5W
755#define SPRN_SPRG_RSCRATCH_MC SPRN_SPRG6R
756#define SPRN_SPRG_WSCRATCH_MC SPRN_SPRG6W
757#define SPRN_SPRG_RSCRATCH4 SPRN_SPRG7R
758#define SPRN_SPRG_WSCRATCH4 SPRN_SPRG7W
759#ifdef CONFIG_E200
760#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG6R
761#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG6W
762#else
763#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG9
764#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG9
765#endif
766#define SPRN_SPRG_RVCPU SPRN_SPRG1
767#define SPRN_SPRG_WVCPU SPRN_SPRG1
768#endif
769
770#ifdef CONFIG_8xx
771#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0
772#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
773#endif
774
775/*
649 * An mtfsf instruction with the L bit set. On CPUs that support this a 776 * An mtfsf instruction with the L bit set. On CPUs that support this a
650 * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored. 777 * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored.
651 * 778 *
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h
index 6bcf364cbb2f..3bf783505528 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -18,18 +18,26 @@
18#define MSR_IS MSR_IR /* Instruction Space */ 18#define MSR_IS MSR_IR /* Instruction Space */
19#define MSR_DS MSR_DR /* Data Space */ 19#define MSR_DS MSR_DR /* Data Space */
20#define MSR_PMM (1<<2) /* Performance monitor mark bit */ 20#define MSR_PMM (1<<2) /* Performance monitor mark bit */
21#define MSR_CM (1<<31) /* Computation Mode (0=32-bit, 1=64-bit) */
21 22
22/* Default MSR for kernel mode. */ 23#if defined(CONFIG_PPC_BOOK3E_64)
23#if defined (CONFIG_40x) 24#define MSR_ MSR_ME | MSR_CE
25#define MSR_KERNEL MSR_ | MSR_CM
26#define MSR_USER32 MSR_ | MSR_PR | MSR_EE
27#define MSR_USER64 MSR_USER32 | MSR_CM
28#elif defined (CONFIG_40x)
24#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE) 29#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)
25#elif defined(CONFIG_BOOKE) 30#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
31#else
26#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_CE) 32#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_CE)
33#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
27#endif 34#endif
28 35
29/* Special Purpose Registers (SPRNs)*/ 36/* Special Purpose Registers (SPRNs)*/
30#define SPRN_DECAR 0x036 /* Decrementer Auto Reload Register */ 37#define SPRN_DECAR 0x036 /* Decrementer Auto Reload Register */
31#define SPRN_IVPR 0x03F /* Interrupt Vector Prefix Register */ 38#define SPRN_IVPR 0x03F /* Interrupt Vector Prefix Register */
32#define SPRN_USPRG0 0x100 /* User Special Purpose Register General 0 */ 39#define SPRN_USPRG0 0x100 /* User Special Purpose Register General 0 */
40#define SPRN_SPRG3R 0x103 /* Special Purpose Register General 3 Read */
33#define SPRN_SPRG4R 0x104 /* Special Purpose Register General 4 Read */ 41#define SPRN_SPRG4R 0x104 /* Special Purpose Register General 4 Read */
34#define SPRN_SPRG5R 0x105 /* Special Purpose Register General 5 Read */ 42#define SPRN_SPRG5R 0x105 /* Special Purpose Register General 5 Read */
35#define SPRN_SPRG6R 0x106 /* Special Purpose Register General 6 Read */ 43#define SPRN_SPRG6R 0x106 /* Special Purpose Register General 6 Read */
@@ -38,11 +46,18 @@
38#define SPRN_SPRG5W 0x115 /* Special Purpose Register General 5 Write */ 46#define SPRN_SPRG5W 0x115 /* Special Purpose Register General 5 Write */
39#define SPRN_SPRG6W 0x116 /* Special Purpose Register General 6 Write */ 47#define SPRN_SPRG6W 0x116 /* Special Purpose Register General 6 Write */
40#define SPRN_SPRG7W 0x117 /* Special Purpose Register General 7 Write */ 48#define SPRN_SPRG7W 0x117 /* Special Purpose Register General 7 Write */
49#define SPRN_EPCR 0x133 /* Embedded Processor Control Register */
41#define SPRN_DBCR2 0x136 /* Debug Control Register 2 */ 50#define SPRN_DBCR2 0x136 /* Debug Control Register 2 */
42#define SPRN_IAC3 0x13A /* Instruction Address Compare 3 */ 51#define SPRN_IAC3 0x13A /* Instruction Address Compare 3 */
43#define SPRN_IAC4 0x13B /* Instruction Address Compare 4 */ 52#define SPRN_IAC4 0x13B /* Instruction Address Compare 4 */
44#define SPRN_DVC1 0x13E /* Data Value Compare Register 1 */ 53#define SPRN_DVC1 0x13E /* Data Value Compare Register 1 */
45#define SPRN_DVC2 0x13F /* Data Value Compare Register 2 */ 54#define SPRN_DVC2 0x13F /* Data Value Compare Register 2 */
55#define SPRN_MAS8 0x155 /* MMU Assist Register 8 */
56#define SPRN_TLB0PS 0x158 /* TLB 0 Page Size Register */
57#define SPRN_MAS5_MAS6 0x15c /* MMU Assist Register 5 || 6 */
58#define SPRN_MAS8_MAS1 0x15d /* MMU Assist Register 8 || 1 */
59#define SPRN_MAS7_MAS3 0x174 /* MMU Assist Register 7 || 3 */
60#define SPRN_MAS0_MAS1 0x175 /* MMU Assist Register 0 || 1 */
46#define SPRN_IVOR0 0x190 /* Interrupt Vector Offset Register 0 */ 61#define SPRN_IVOR0 0x190 /* Interrupt Vector Offset Register 0 */
47#define SPRN_IVOR1 0x191 /* Interrupt Vector Offset Register 1 */ 62#define SPRN_IVOR1 0x191 /* Interrupt Vector Offset Register 1 */
48#define SPRN_IVOR2 0x192 /* Interrupt Vector Offset Register 2 */ 63#define SPRN_IVOR2 0x192 /* Interrupt Vector Offset Register 2 */
@@ -93,6 +108,8 @@
93#define SPRN_PID2 0x27A /* Process ID Register 2 */ 108#define SPRN_PID2 0x27A /* Process ID Register 2 */
94#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */ 109#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */
95#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */ 110#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */
111#define SPRN_TLB2CFG 0x2B2 /* TLB 2 Config Register */
112#define SPRN_TLB3CFG 0x2B3 /* TLB 3 Config Register */
96#define SPRN_EPR 0x2BE /* External Proxy Register */ 113#define SPRN_EPR 0x2BE /* External Proxy Register */
97#define SPRN_CCR1 0x378 /* Core Configuration Register 1 */ 114#define SPRN_CCR1 0x378 /* Core Configuration Register 1 */
98#define SPRN_ZPR 0x3B0 /* Zone Protection Register (40x) */ 115#define SPRN_ZPR 0x3B0 /* Zone Protection Register (40x) */
@@ -415,16 +432,31 @@
415#define L2CSR0_L2LOA 0x00000080 /* L2 Cache Lock Overflow Allocate */ 432#define L2CSR0_L2LOA 0x00000080 /* L2 Cache Lock Overflow Allocate */
416#define L2CSR0_L2LO 0x00000020 /* L2 Cache Lock Overflow */ 433#define L2CSR0_L2LO 0x00000020 /* L2 Cache Lock Overflow */
417 434
418/* Bit definitions for MMUCSR0 */
419#define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */
420#define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */
421#define MMUCSR0_TLB2FI 0x00000040 /* TLB2 Flash invalidate */
422#define MMUCSR0_TLB3FI 0x00000020 /* TLB3 Flash invalidate */
423
424/* Bit definitions for SGR. */ 435/* Bit definitions for SGR. */
425#define SGR_NORMAL 0 /* Speculative fetching allowed. */ 436#define SGR_NORMAL 0 /* Speculative fetching allowed. */
426#define SGR_GUARDED 1 /* Speculative fetching disallowed. */ 437#define SGR_GUARDED 1 /* Speculative fetching disallowed. */
427 438
439/* Bit definitions for EPCR */
440#define SPRN_EPCR_EXTGS 0x80000000 /* External Input interrupt
441 * directed to Guest state */
442#define SPRN_EPCR_DTLBGS 0x40000000 /* Data TLB Error interrupt
443 * directed to guest state */
444#define SPRN_EPCR_ITLBGS 0x20000000 /* Instr. TLB error interrupt
445 * directed to guest state */
446#define SPRN_EPCR_DSIGS 0x10000000 /* Data Storage interrupt
447 * directed to guest state */
448#define SPRN_EPCR_ISIGS 0x08000000 /* Instr. Storage interrupt
449 * directed to guest state */
450#define SPRN_EPCR_DUVD 0x04000000 /* Disable Hypervisor Debug */
451#define SPRN_EPCR_ICM 0x02000000 /* Interrupt computation mode
452 * (copied to MSR:CM on intr) */
453#define SPRN_EPCR_GICM 0x01000000 /* Guest Interrupt Comp. mode */
454#define SPRN_EPCR_DGTMI 0x00800000 /* Disable TLB Guest Management
455 * instructions */
456#define SPRN_EPCR_DMIUH 0x00400000 /* Disable MAS Interrupt updates
457 * for hypervisor */
458
459
428/* 460/*
429 * The IBM-403 is an even more odd special case, as it is much 461 * The IBM-403 is an even more odd special case, as it is much
430 * older than the IBM-405 series. We put these down here incase someone 462 * older than the IBM-405 series. We put these down here incase someone
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index 817fac0a0714..dae19342f0b9 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -1,6 +1,6 @@
1#ifndef _ASM_POWERPC_SETUP_H 1#ifndef _ASM_POWERPC_SETUP_H
2#define _ASM_POWERPC_SETUP_H 2#define _ASM_POWERPC_SETUP_H
3 3
4#define COMMAND_LINE_SIZE 512 4#include <asm-generic/setup.h>
5 5
6#endif /* _ASM_POWERPC_SETUP_H */ 6#endif /* _ASM_POWERPC_SETUP_H */
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index c25f73d1d842..c0d3b8af9319 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -148,6 +148,16 @@ extern struct smp_ops_t *smp_ops;
148extern void arch_send_call_function_single_ipi(int cpu); 148extern void arch_send_call_function_single_ipi(int cpu);
149extern void arch_send_call_function_ipi(cpumask_t mask); 149extern void arch_send_call_function_ipi(cpumask_t mask);
150 150
151/* Definitions relative to the secondary CPU spin loop
152 * and entry point. Not all of them exist on both 32 and
153 * 64-bit but defining them all here doesn't harm
154 */
155extern void generic_secondary_smp_init(void);
156extern void generic_secondary_thread_init(void);
157extern unsigned long __secondary_hold_spinloop;
158extern unsigned long __secondary_hold_acknowledge;
159extern char __secondary_hold;
160
151#endif /* __ASSEMBLY__ */ 161#endif /* __ASSEMBLY__ */
152 162
153#endif /* __KERNEL__ */ 163#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 30891d6e2bc1..8979d4cd3d70 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,15 +13,13 @@
13 13
14#include <linux/swiotlb.h> 14#include <linux/swiotlb.h>
15 15
16extern struct dma_mapping_ops swiotlb_dma_ops; 16extern struct dma_map_ops swiotlb_dma_ops;
17extern struct dma_mapping_ops swiotlb_pci_dma_ops;
18
19int swiotlb_arch_address_needs_mapping(struct device *, dma_addr_t,
20 size_t size);
21 17
22static inline void dma_mark_clean(void *addr, size_t size) {} 18static inline void dma_mark_clean(void *addr, size_t size) {}
23 19
24extern unsigned int ppc_swiotlb_enable; 20extern unsigned int ppc_swiotlb_enable;
25int __init swiotlb_setup_bus_notifier(void); 21int __init swiotlb_setup_bus_notifier(void);
26 22
23extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev);
24
27#endif /* __ASM_SWIOTLB_H */ 25#endif /* __ASM_SWIOTLB_H */
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 370600ca2765..ed24bd92fe49 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -95,8 +95,8 @@ SYSCALL(reboot)
95SYSX(sys_ni_syscall,compat_sys_old_readdir,sys_old_readdir) 95SYSX(sys_ni_syscall,compat_sys_old_readdir,sys_old_readdir)
96SYSCALL_SPU(mmap) 96SYSCALL_SPU(mmap)
97SYSCALL_SPU(munmap) 97SYSCALL_SPU(munmap)
98SYSCALL_SPU(truncate) 98COMPAT_SYS_SPU(truncate)
99SYSCALL_SPU(ftruncate) 99COMPAT_SYS_SPU(ftruncate)
100SYSCALL_SPU(fchmod) 100SYSCALL_SPU(fchmod)
101SYSCALL_SPU(fchown) 101SYSCALL_SPU(fchown)
102COMPAT_SYS_SPU(getpriority) 102COMPAT_SYS_SPU(getpriority)
diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h
index e20ff7541f36..e2b428b0f7ba 100644
--- a/arch/powerpc/include/asm/tlb.h
+++ b/arch/powerpc/include/asm/tlb.h
@@ -25,57 +25,25 @@
25 25
26#include <linux/pagemap.h> 26#include <linux/pagemap.h>
27 27
28struct mmu_gather;
29
30#define tlb_start_vma(tlb, vma) do { } while (0) 28#define tlb_start_vma(tlb, vma) do { } while (0)
31#define tlb_end_vma(tlb, vma) do { } while (0) 29#define tlb_end_vma(tlb, vma) do { } while (0)
32 30
33#if !defined(CONFIG_PPC_STD_MMU)
34
35#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
36
37#elif defined(__powerpc64__)
38
39extern void pte_free_finish(void);
40
41static inline void tlb_flush(struct mmu_gather *tlb)
42{
43 struct ppc64_tlb_batch *tlbbatch = &__get_cpu_var(ppc64_tlb_batch);
44
45 /* If there's a TLB batch pending, then we must flush it because the
46 * pages are going to be freed and we really don't want to have a CPU
47 * access a freed page because it has a stale TLB
48 */
49 if (tlbbatch->index)
50 __flush_tlb_pending(tlbbatch);
51
52 pte_free_finish();
53}
54
55#else
56
57extern void tlb_flush(struct mmu_gather *tlb); 31extern void tlb_flush(struct mmu_gather *tlb);
58 32
59#endif
60
61/* Get the generic bits... */ 33/* Get the generic bits... */
62#include <asm-generic/tlb.h> 34#include <asm-generic/tlb.h>
63 35
64#if !defined(CONFIG_PPC_STD_MMU) || defined(__powerpc64__)
65
66#define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
67
68#else
69extern void flush_hash_entry(struct mm_struct *mm, pte_t *ptep, 36extern void flush_hash_entry(struct mm_struct *mm, pte_t *ptep,
70 unsigned long address); 37 unsigned long address);
71 38
72static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, 39static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,
73 unsigned long address) 40 unsigned long address)
74{ 41{
42#ifdef CONFIG_PPC_STD_MMU_32
75 if (pte_val(*ptep) & _PAGE_HASHPTE) 43 if (pte_val(*ptep) & _PAGE_HASHPTE)
76 flush_hash_entry(tlb->mm, ptep, address); 44 flush_hash_entry(tlb->mm, ptep, address);
45#endif
77} 46}
78 47
79#endif
80#endif /* __KERNEL__ */ 48#endif /* __KERNEL__ */
81#endif /* __ASM_POWERPC_TLB_H */ 49#endif /* __ASM_POWERPC_TLB_H */
diff --git a/arch/powerpc/include/asm/tlbflush.h b/arch/powerpc/include/asm/tlbflush.h
index abbe3419d1dd..d50a380b2b6f 100644
--- a/arch/powerpc/include/asm/tlbflush.h
+++ b/arch/powerpc/include/asm/tlbflush.h
@@ -6,7 +6,7 @@
6 * 6 *
7 * - flush_tlb_mm(mm) flushes the specified mm context TLB's 7 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
8 * - flush_tlb_page(vma, vmaddr) flushes one page 8 * - flush_tlb_page(vma, vmaddr) flushes one page
9 * - local_flush_tlb_mm(mm) flushes the specified mm context on 9 * - local_flush_tlb_mm(mm, full) flushes the specified mm context on
10 * the local processor 10 * the local processor
11 * - local_flush_tlb_page(vma, vmaddr) flushes one page on the local processor 11 * - local_flush_tlb_page(vma, vmaddr) flushes one page on the local processor
12 * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB 12 * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB
@@ -29,7 +29,8 @@
29 * specific tlbie's 29 * specific tlbie's
30 */ 30 */
31 31
32#include <linux/mm.h> 32struct vm_area_struct;
33struct mm_struct;
33 34
34#define MMU_NO_CONTEXT ((unsigned int)-1) 35#define MMU_NO_CONTEXT ((unsigned int)-1)
35 36
@@ -40,12 +41,18 @@ extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
40extern void local_flush_tlb_mm(struct mm_struct *mm); 41extern void local_flush_tlb_mm(struct mm_struct *mm);
41extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr); 42extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
42 43
44extern void __local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
45 int tsize, int ind);
46
43#ifdef CONFIG_SMP 47#ifdef CONFIG_SMP
44extern void flush_tlb_mm(struct mm_struct *mm); 48extern void flush_tlb_mm(struct mm_struct *mm);
45extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr); 49extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
50extern void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
51 int tsize, int ind);
46#else 52#else
47#define flush_tlb_mm(mm) local_flush_tlb_mm(mm) 53#define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
48#define flush_tlb_page(vma,addr) local_flush_tlb_page(vma,addr) 54#define flush_tlb_page(vma,addr) local_flush_tlb_page(vma,addr)
55#define __flush_tlb_page(mm,addr,p,i) __local_flush_tlb_page(mm,addr,p,i)
49#endif 56#endif
50#define flush_tlb_page_nohash(vma,addr) flush_tlb_page(vma,addr) 57#define flush_tlb_page_nohash(vma,addr) flush_tlb_page(vma,addr)
51 58
diff --git a/arch/powerpc/include/asm/vdso.h b/arch/powerpc/include/asm/vdso.h
index 26fc449bd989..dc0419b66f17 100644
--- a/arch/powerpc/include/asm/vdso.h
+++ b/arch/powerpc/include/asm/vdso.h
@@ -7,9 +7,8 @@
7#define VDSO32_LBASE 0x100000 7#define VDSO32_LBASE 0x100000
8#define VDSO64_LBASE 0x100000 8#define VDSO64_LBASE 0x100000
9 9
10/* Default map addresses */ 10/* Default map addresses for 32bit vDSO */
11#define VDSO32_MBASE VDSO32_LBASE 11#define VDSO32_MBASE VDSO32_LBASE
12#define VDSO64_MBASE VDSO64_LBASE
13 12
14#define VDSO_VERSION_STRING LINUX_2.6.15 13#define VDSO_VERSION_STRING LINUX_2.6.15
15 14
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 9619285f64e8..569f79ccd310 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -33,10 +33,10 @@ obj-y := cputable.o ptrace.o syscalls.o \
33obj-y += vdso32/ 33obj-y += vdso32/
34obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ 34obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
35 signal_64.o ptrace32.o \ 35 signal_64.o ptrace32.o \
36 paca.o cpu_setup_ppc970.o \ 36 paca.o nvram_64.o firmware.o
37 cpu_setup_pa6t.o \ 37obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o
38 firmware.o nvram_64.o
39obj64-$(CONFIG_RELOCATABLE) += reloc_64.o 38obj64-$(CONFIG_RELOCATABLE) += reloc_64.o
39obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o
40obj-$(CONFIG_PPC64) += vdso64/ 40obj-$(CONFIG_PPC64) += vdso64/
41obj-$(CONFIG_ALTIVEC) += vecemu.o 41obj-$(CONFIG_ALTIVEC) += vecemu.o
42obj-$(CONFIG_PPC_970_NAP) += idle_power4.o 42obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
@@ -63,8 +63,8 @@ obj-$(CONFIG_MODULES) += module.o module_$(CONFIG_WORD_SIZE).o
63obj-$(CONFIG_44x) += cpu_setup_44x.o 63obj-$(CONFIG_44x) += cpu_setup_44x.o
64obj-$(CONFIG_FSL_BOOKE) += cpu_setup_fsl_booke.o dbell.o 64obj-$(CONFIG_FSL_BOOKE) += cpu_setup_fsl_booke.o dbell.o
65 65
66extra-$(CONFIG_PPC_STD_MMU) := head_32.o 66extra-y := head_$(CONFIG_WORD_SIZE).o
67extra-$(CONFIG_PPC64) := head_64.o 67extra-$(CONFIG_PPC_BOOK3E_32) := head_new_booke.o
68extra-$(CONFIG_40x) := head_40x.o 68extra-$(CONFIG_40x) := head_40x.o
69extra-$(CONFIG_44x) := head_44x.o 69extra-$(CONFIG_44x) := head_44x.o
70extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o 70extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o
@@ -88,7 +88,7 @@ obj-$(CONFIG_SWIOTLB) += dma-swiotlb.o
88 88
89pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o 89pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o
90obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \ 90obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \
91 pci-common.o 91 pci-common.o pci_of_scan.o
92obj-$(CONFIG_PCI_MSI) += msi.o 92obj-$(CONFIG_PCI_MSI) += msi.o
93obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o \ 93obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o \
94 machine_kexec_$(CONFIG_WORD_SIZE).o 94 machine_kexec_$(CONFIG_WORD_SIZE).o
@@ -115,6 +115,13 @@ ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),)
115obj-y += ppc_save_regs.o 115obj-y += ppc_save_regs.o
116endif 116endif
117 117
118# Disable GCOV in odd or sensitive code
119GCOV_PROFILE_prom_init.o := n
120GCOV_PROFILE_ftrace.o := n
121GCOV_PROFILE_machine_kexec_64.o := n
122GCOV_PROFILE_machine_kexec_32.o := n
123GCOV_PROFILE_kprobes.o := n
124
118extra-$(CONFIG_PPC_FPU) += fpu.o 125extra-$(CONFIG_PPC_FPU) += fpu.o
119extra-$(CONFIG_ALTIVEC) += vector.o 126extra-$(CONFIG_ALTIVEC) += vector.o
120extra-$(CONFIG_PPC64) += entry_64.o 127extra-$(CONFIG_PPC64) += entry_64.o
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 197b15646eeb..f0df285f0f87 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -52,9 +52,11 @@
52#include <linux/kvm_host.h> 52#include <linux/kvm_host.h>
53#endif 53#endif
54 54
55#ifdef CONFIG_PPC32
55#if defined(CONFIG_BOOKE) || defined(CONFIG_40x) 56#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
56#include "head_booke.h" 57#include "head_booke.h"
57#endif 58#endif
59#endif
58 60
59#if defined(CONFIG_FSL_BOOKE) 61#if defined(CONFIG_FSL_BOOKE)
60#include "../mm/mmu_decl.h" 62#include "../mm/mmu_decl.h"
@@ -140,6 +142,20 @@ int main(void)
140 context.high_slices_psize)); 142 context.high_slices_psize));
141 DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def)); 143 DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def));
142#endif /* CONFIG_PPC_MM_SLICES */ 144#endif /* CONFIG_PPC_MM_SLICES */
145
146#ifdef CONFIG_PPC_BOOK3E
147 DEFINE(PACAPGD, offsetof(struct paca_struct, pgd));
148 DEFINE(PACA_KERNELPGD, offsetof(struct paca_struct, kernel_pgd));
149 DEFINE(PACA_EXGEN, offsetof(struct paca_struct, exgen));
150 DEFINE(PACA_EXTLB, offsetof(struct paca_struct, extlb));
151 DEFINE(PACA_EXMC, offsetof(struct paca_struct, exmc));
152 DEFINE(PACA_EXCRIT, offsetof(struct paca_struct, excrit));
153 DEFINE(PACA_EXDBG, offsetof(struct paca_struct, exdbg));
154 DEFINE(PACA_MC_STACK, offsetof(struct paca_struct, mc_kstack));
155 DEFINE(PACA_CRIT_STACK, offsetof(struct paca_struct, crit_kstack));
156 DEFINE(PACA_DBG_STACK, offsetof(struct paca_struct, dbg_kstack));
157#endif /* CONFIG_PPC_BOOK3E */
158
143#ifdef CONFIG_PPC_STD_MMU_64 159#ifdef CONFIG_PPC_STD_MMU_64
144 DEFINE(PACASTABREAL, offsetof(struct paca_struct, stab_real)); 160 DEFINE(PACASTABREAL, offsetof(struct paca_struct, stab_real));
145 DEFINE(PACASTABVIRT, offsetof(struct paca_struct, stab_addr)); 161 DEFINE(PACASTABVIRT, offsetof(struct paca_struct, stab_addr));
@@ -262,6 +278,7 @@ int main(void)
262 DEFINE(_SRR1, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs)+8); 278 DEFINE(_SRR1, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs)+8);
263#endif /* CONFIG_PPC64 */ 279#endif /* CONFIG_PPC64 */
264 280
281#if defined(CONFIG_PPC32)
265#if defined(CONFIG_BOOKE) || defined(CONFIG_40x) 282#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
266 DEFINE(EXC_LVL_SIZE, STACK_EXC_LVL_FRAME_SIZE); 283 DEFINE(EXC_LVL_SIZE, STACK_EXC_LVL_FRAME_SIZE);
267 DEFINE(MAS0, STACK_INT_FRAME_SIZE+offsetof(struct exception_regs, mas0)); 284 DEFINE(MAS0, STACK_INT_FRAME_SIZE+offsetof(struct exception_regs, mas0));
@@ -280,7 +297,7 @@ int main(void)
280 DEFINE(_DSRR1, STACK_INT_FRAME_SIZE+offsetof(struct exception_regs, dsrr1)); 297 DEFINE(_DSRR1, STACK_INT_FRAME_SIZE+offsetof(struct exception_regs, dsrr1));
281 DEFINE(SAVED_KSP_LIMIT, STACK_INT_FRAME_SIZE+offsetof(struct exception_regs, saved_ksp_limit)); 298 DEFINE(SAVED_KSP_LIMIT, STACK_INT_FRAME_SIZE+offsetof(struct exception_regs, saved_ksp_limit));
282#endif 299#endif
283 300#endif
284 DEFINE(CLONE_VM, CLONE_VM); 301 DEFINE(CLONE_VM, CLONE_VM);
285 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED); 302 DEFINE(CLONE_UNTRACED, CLONE_UNTRACED);
286 303
diff --git a/arch/powerpc/kernel/cpu_setup_6xx.S b/arch/powerpc/kernel/cpu_setup_6xx.S
index 1e9949e68856..55cba4a8a959 100644
--- a/arch/powerpc/kernel/cpu_setup_6xx.S
+++ b/arch/powerpc/kernel/cpu_setup_6xx.S
@@ -21,7 +21,7 @@ _GLOBAL(__setup_cpu_603)
21 mflr r4 21 mflr r4
22BEGIN_MMU_FTR_SECTION 22BEGIN_MMU_FTR_SECTION
23 li r10,0 23 li r10,0
24 mtspr SPRN_SPRG4,r10 /* init SW LRU tracking */ 24 mtspr SPRN_SPRG_603_LRU,r10 /* init SW LRU tracking */
25END_MMU_FTR_SECTION_IFSET(MMU_FTR_NEED_DTLB_SW_LRU) 25END_MMU_FTR_SECTION_IFSET(MMU_FTR_NEED_DTLB_SW_LRU)
26BEGIN_FTR_SECTION 26BEGIN_FTR_SECTION
27 bl __init_fpu_registers 27 bl __init_fpu_registers
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 4a24a2fc4574..0b9c9135922e 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -89,11 +89,15 @@ extern void __restore_cpu_power7(void);
89#define COMMON_USER_PA6T (COMMON_USER_PPC64 | PPC_FEATURE_PA6T |\ 89#define COMMON_USER_PA6T (COMMON_USER_PPC64 | PPC_FEATURE_PA6T |\
90 PPC_FEATURE_TRUE_LE | \ 90 PPC_FEATURE_TRUE_LE | \
91 PPC_FEATURE_HAS_ALTIVEC_COMP) 91 PPC_FEATURE_HAS_ALTIVEC_COMP)
92#ifdef CONFIG_PPC_BOOK3E_64
93#define COMMON_USER_BOOKE (COMMON_USER_PPC64 | PPC_FEATURE_BOOKE)
94#else
92#define COMMON_USER_BOOKE (PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU | \ 95#define COMMON_USER_BOOKE (PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU | \
93 PPC_FEATURE_BOOKE) 96 PPC_FEATURE_BOOKE)
97#endif
94 98
95static struct cpu_spec __initdata cpu_specs[] = { 99static struct cpu_spec __initdata cpu_specs[] = {
96#ifdef CONFIG_PPC64 100#ifdef CONFIG_PPC_BOOK3S_64
97 { /* Power3 */ 101 { /* Power3 */
98 .pvr_mask = 0xffff0000, 102 .pvr_mask = 0xffff0000,
99 .pvr_value = 0x00400000, 103 .pvr_value = 0x00400000,
@@ -508,7 +512,8 @@ static struct cpu_spec __initdata cpu_specs[] = {
508 .machine_check = machine_check_generic, 512 .machine_check = machine_check_generic,
509 .platform = "power4", 513 .platform = "power4",
510 } 514 }
511#endif /* CONFIG_PPC64 */ 515#endif /* CONFIG_PPC_BOOK3S_64 */
516
512#ifdef CONFIG_PPC32 517#ifdef CONFIG_PPC32
513#if CLASSIC_PPC 518#if CLASSIC_PPC
514 { /* 601 */ 519 { /* 601 */
@@ -1630,7 +1635,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
1630 .platform = "ppc440", 1635 .platform = "ppc440",
1631 }, 1636 },
1632 { /* 460EX */ 1637 { /* 460EX */
1633 .pvr_mask = 0xffff0002, 1638 .pvr_mask = 0xffff0006,
1634 .pvr_value = 0x13020002, 1639 .pvr_value = 0x13020002,
1635 .cpu_name = "460EX", 1640 .cpu_name = "460EX",
1636 .cpu_features = CPU_FTRS_440x6, 1641 .cpu_features = CPU_FTRS_440x6,
@@ -1642,8 +1647,21 @@ static struct cpu_spec __initdata cpu_specs[] = {
1642 .machine_check = machine_check_440A, 1647 .machine_check = machine_check_440A,
1643 .platform = "ppc440", 1648 .platform = "ppc440",
1644 }, 1649 },
1650 { /* 460EX Rev B */
1651 .pvr_mask = 0xffff0007,
1652 .pvr_value = 0x13020004,
1653 .cpu_name = "460EX Rev. B",
1654 .cpu_features = CPU_FTRS_440x6,
1655 .cpu_user_features = COMMON_USER_BOOKE | PPC_FEATURE_HAS_FPU,
1656 .mmu_features = MMU_FTR_TYPE_44x,
1657 .icache_bsize = 32,
1658 .dcache_bsize = 32,
1659 .cpu_setup = __setup_cpu_460ex,
1660 .machine_check = machine_check_440A,
1661 .platform = "ppc440",
1662 },
1645 { /* 460GT */ 1663 { /* 460GT */
1646 .pvr_mask = 0xffff0002, 1664 .pvr_mask = 0xffff0006,
1647 .pvr_value = 0x13020000, 1665 .pvr_value = 0x13020000,
1648 .cpu_name = "460GT", 1666 .cpu_name = "460GT",
1649 .cpu_features = CPU_FTRS_440x6, 1667 .cpu_features = CPU_FTRS_440x6,
@@ -1655,6 +1673,19 @@ static struct cpu_spec __initdata cpu_specs[] = {
1655 .machine_check = machine_check_440A, 1673 .machine_check = machine_check_440A,
1656 .platform = "ppc440", 1674 .platform = "ppc440",
1657 }, 1675 },
1676 { /* 460GT Rev B */
1677 .pvr_mask = 0xffff0007,
1678 .pvr_value = 0x13020005,
1679 .cpu_name = "460GT Rev. B",
1680 .cpu_features = CPU_FTRS_440x6,
1681 .cpu_user_features = COMMON_USER_BOOKE | PPC_FEATURE_HAS_FPU,
1682 .mmu_features = MMU_FTR_TYPE_44x,
1683 .icache_bsize = 32,
1684 .dcache_bsize = 32,
1685 .cpu_setup = __setup_cpu_460gt,
1686 .machine_check = machine_check_440A,
1687 .platform = "ppc440",
1688 },
1658 { /* 460SX */ 1689 { /* 460SX */
1659 .pvr_mask = 0xffffff00, 1690 .pvr_mask = 0xffffff00,
1660 .pvr_value = 0x13541800, 1691 .pvr_value = 0x13541800,
@@ -1797,6 +1828,29 @@ static struct cpu_spec __initdata cpu_specs[] = {
1797 } 1828 }
1798#endif /* CONFIG_E500 */ 1829#endif /* CONFIG_E500 */
1799#endif /* CONFIG_PPC32 */ 1830#endif /* CONFIG_PPC32 */
1831
1832#ifdef CONFIG_PPC_BOOK3E_64
1833 { /* This is a default entry to get going, to be replaced by
1834 * a real one at some stage
1835 */
1836#define CPU_FTRS_BASE_BOOK3E (CPU_FTR_USE_TB | \
1837 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_SMT | \
1838 CPU_FTR_NODSISRALIGN | CPU_FTR_NOEXECUTE)
1839 .pvr_mask = 0x00000000,
1840 .pvr_value = 0x00000000,
1841 .cpu_name = "Book3E",
1842 .cpu_features = CPU_FTRS_BASE_BOOK3E,
1843 .cpu_user_features = COMMON_USER_PPC64,
1844 .mmu_features = MMU_FTR_TYPE_3E | MMU_FTR_USE_TLBILX |
1845 MMU_FTR_USE_TLBIVAX_BCAST |
1846 MMU_FTR_LOCK_BCAST_INVAL,
1847 .icache_bsize = 64,
1848 .dcache_bsize = 64,
1849 .num_pmcs = 0,
1850 .machine_check = machine_check_generic,
1851 .platform = "power6",
1852 },
1853#endif
1800}; 1854};
1801 1855
1802static struct cpu_spec the_cpu_spec; 1856static struct cpu_spec the_cpu_spec;
diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 2983adac8cc3..87ddb3fb948c 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
89 return 1; 89 return 1;
90} 90}
91 91
92struct dma_mapping_ops dma_iommu_ops = { 92struct dma_map_ops dma_iommu_ops = {
93 .alloc_coherent = dma_iommu_alloc_coherent, 93 .alloc_coherent = dma_iommu_alloc_coherent,
94 .free_coherent = dma_iommu_free_coherent, 94 .free_coherent = dma_iommu_free_coherent,
95 .map_sg = dma_iommu_map_sg, 95 .map_sg = dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e8a57de85bcf..e96cbbd9b449 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -25,33 +25,13 @@ int swiotlb __read_mostly;
25unsigned int ppc_swiotlb_enable; 25unsigned int ppc_swiotlb_enable;
26 26
27/* 27/*
28 * Determine if an address is reachable by a pci device, or if we must bounce.
29 */
30static int
31swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size)
32{
33 dma_addr_t max;
34 struct pci_controller *hose;
35 struct pci_dev *pdev = to_pci_dev(hwdev);
36
37 hose = pci_bus_to_host(pdev->bus);
38 max = hose->dma_window_base_cur + hose->dma_window_size;
39
40 /* check that we're within mapped pci window space */
41 if ((addr + size > max) | (addr < hose->dma_window_base_cur))
42 return 1;
43
44 return 0;
45}
46
47/*
48 * At the moment, all platforms that use this code only require 28 * At the moment, all platforms that use this code only require
49 * swiotlb to be used if we're operating on HIGHMEM. Since 29 * swiotlb to be used if we're operating on HIGHMEM. Since
50 * we don't ever call anything other than map_sg, unmap_sg, 30 * we don't ever call anything other than map_sg, unmap_sg,
51 * map_page, and unmap_page on highmem, use normal dma_ops 31 * map_page, and unmap_page on highmem, use normal dma_ops
52 * for everything else. 32 * for everything else.
53 */ 33 */
54struct dma_mapping_ops swiotlb_dma_ops = { 34struct dma_map_ops swiotlb_dma_ops = {
55 .alloc_coherent = dma_direct_alloc_coherent, 35 .alloc_coherent = dma_direct_alloc_coherent,
56 .free_coherent = dma_direct_free_coherent, 36 .free_coherent = dma_direct_free_coherent,
57 .map_sg = swiotlb_map_sg_attrs, 37 .map_sg = swiotlb_map_sg_attrs,
@@ -62,33 +42,34 @@ struct dma_mapping_ops swiotlb_dma_ops = {
62 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, 42 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
63 .sync_single_range_for_device = swiotlb_sync_single_range_for_device, 43 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
64 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, 44 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
65 .sync_sg_for_device = swiotlb_sync_sg_for_device 45 .sync_sg_for_device = swiotlb_sync_sg_for_device,
46 .mapping_error = swiotlb_dma_mapping_error,
66}; 47};
67 48
68struct dma_mapping_ops swiotlb_pci_dma_ops = { 49void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
69 .alloc_coherent = dma_direct_alloc_coherent, 50{
70 .free_coherent = dma_direct_free_coherent, 51 struct pci_controller *hose;
71 .map_sg = swiotlb_map_sg_attrs, 52 struct dev_archdata *sd;
72 .unmap_sg = swiotlb_unmap_sg_attrs, 53
73 .dma_supported = swiotlb_dma_supported, 54 hose = pci_bus_to_host(pdev->bus);
74 .map_page = swiotlb_map_page, 55 sd = &pdev->dev.archdata;
75 .unmap_page = swiotlb_unmap_page, 56 sd->max_direct_dma_addr =
76 .addr_needs_map = swiotlb_pci_addr_needs_map, 57 hose->dma_window_base_cur + hose->dma_window_size;
77 .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, 58}
78 .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
79 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
80 .sync_sg_for_device = swiotlb_sync_sg_for_device
81};
82 59
83static int ppc_swiotlb_bus_notify(struct notifier_block *nb, 60static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
84 unsigned long action, void *data) 61 unsigned long action, void *data)
85{ 62{
86 struct device *dev = data; 63 struct device *dev = data;
64 struct dev_archdata *sd;
87 65
88 /* We are only intereted in device addition */ 66 /* We are only intereted in device addition */
89 if (action != BUS_NOTIFY_ADD_DEVICE) 67 if (action != BUS_NOTIFY_ADD_DEVICE)
90 return 0; 68 return 0;
91 69
70 sd = &dev->archdata;
71 sd->max_direct_dma_addr = 0;
72
92 /* May need to bounce if the device can't address all of DRAM */ 73 /* May need to bounce if the device can't address all of DRAM */
93 if (dma_get_mask(dev) < lmb_end_of_DRAM()) 74 if (dma_get_mask(dev) < lmb_end_of_DRAM())
94 set_dma_ops(dev, &swiotlb_dma_ops); 75 set_dma_ops(dev, &swiotlb_dma_ops);
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index ccf129d47d84..21b784d7e7d0 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/device.h> 8#include <linux/device.h>
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10#include <linux/dma-debug.h>
10#include <linux/lmb.h> 11#include <linux/lmb.h>
11#include <asm/bug.h> 12#include <asm/bug.h>
12#include <asm/abs_addr.h> 13#include <asm/abs_addr.h>
@@ -140,7 +141,7 @@ static inline void dma_direct_sync_single_range(struct device *dev,
140} 141}
141#endif 142#endif
142 143
143struct dma_mapping_ops dma_direct_ops = { 144struct dma_map_ops dma_direct_ops = {
144 .alloc_coherent = dma_direct_alloc_coherent, 145 .alloc_coherent = dma_direct_alloc_coherent,
145 .free_coherent = dma_direct_free_coherent, 146 .free_coherent = dma_direct_free_coherent,
146 .map_sg = dma_direct_map_sg, 147 .map_sg = dma_direct_map_sg,
@@ -156,3 +157,13 @@ struct dma_mapping_ops dma_direct_ops = {
156#endif 157#endif
157}; 158};
158EXPORT_SYMBOL(dma_direct_ops); 159EXPORT_SYMBOL(dma_direct_ops);
160
161#define PREALLOC_DMA_DEBUG_ENTRIES (1 << 16)
162
163static int __init dma_init(void)
164{
165 dma_debug_init(PREALLOC_DMA_DEBUG_ENTRIES);
166
167 return 0;
168}
169fs_initcall(dma_init);
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 3cadba60a4b6..1175a8539e6c 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -88,7 +88,7 @@ crit_transfer_to_handler:
88 mfspr r0,SPRN_SRR1 88 mfspr r0,SPRN_SRR1
89 stw r0,_SRR1(r11) 89 stw r0,_SRR1(r11)
90 90
91 mfspr r8,SPRN_SPRG3 91 mfspr r8,SPRN_SPRG_THREAD
92 lwz r0,KSP_LIMIT(r8) 92 lwz r0,KSP_LIMIT(r8)
93 stw r0,SAVED_KSP_LIMIT(r11) 93 stw r0,SAVED_KSP_LIMIT(r11)
94 rlwimi r0,r1,0,0,(31-THREAD_SHIFT) 94 rlwimi r0,r1,0,0,(31-THREAD_SHIFT)
@@ -108,7 +108,7 @@ crit_transfer_to_handler:
108 mfspr r0,SPRN_SRR1 108 mfspr r0,SPRN_SRR1
109 stw r0,crit_srr1@l(0) 109 stw r0,crit_srr1@l(0)
110 110
111 mfspr r8,SPRN_SPRG3 111 mfspr r8,SPRN_SPRG_THREAD
112 lwz r0,KSP_LIMIT(r8) 112 lwz r0,KSP_LIMIT(r8)
113 stw r0,saved_ksp_limit@l(0) 113 stw r0,saved_ksp_limit@l(0)
114 rlwimi r0,r1,0,0,(31-THREAD_SHIFT) 114 rlwimi r0,r1,0,0,(31-THREAD_SHIFT)
@@ -138,7 +138,7 @@ transfer_to_handler:
138 mfspr r2,SPRN_XER 138 mfspr r2,SPRN_XER
139 stw r12,_CTR(r11) 139 stw r12,_CTR(r11)
140 stw r2,_XER(r11) 140 stw r2,_XER(r11)
141 mfspr r12,SPRN_SPRG3 141 mfspr r12,SPRN_SPRG_THREAD
142 addi r2,r12,-THREAD 142 addi r2,r12,-THREAD
143 tovirt(r2,r2) /* set r2 to current */ 143 tovirt(r2,r2) /* set r2 to current */
144 beq 2f /* if from user, fix up THREAD.regs */ 144 beq 2f /* if from user, fix up THREAD.regs */
@@ -680,7 +680,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_SPE)
680 680
681 tophys(r0,r4) 681 tophys(r0,r4)
682 CLR_TOP32(r0) 682 CLR_TOP32(r0)
683 mtspr SPRN_SPRG3,r0 /* Update current THREAD phys addr */ 683 mtspr SPRN_SPRG_THREAD,r0 /* Update current THREAD phys addr */
684 lwz r1,KSP(r4) /* Load new stack pointer */ 684 lwz r1,KSP(r4) /* Load new stack pointer */
685 685
686 /* save the old current 'last' for return value */ 686 /* save the old current 'last' for return value */
@@ -1057,7 +1057,7 @@ exc_exit_restart_end:
1057#ifdef CONFIG_40x 1057#ifdef CONFIG_40x
1058 .globl ret_from_crit_exc 1058 .globl ret_from_crit_exc
1059ret_from_crit_exc: 1059ret_from_crit_exc:
1060 mfspr r9,SPRN_SPRG3 1060 mfspr r9,SPRN_SPRG_THREAD
1061 lis r10,saved_ksp_limit@ha; 1061 lis r10,saved_ksp_limit@ha;
1062 lwz r10,saved_ksp_limit@l(r10); 1062 lwz r10,saved_ksp_limit@l(r10);
1063 tovirt(r9,r9); 1063 tovirt(r9,r9);
@@ -1074,7 +1074,7 @@ ret_from_crit_exc:
1074#ifdef CONFIG_BOOKE 1074#ifdef CONFIG_BOOKE
1075 .globl ret_from_crit_exc 1075 .globl ret_from_crit_exc
1076ret_from_crit_exc: 1076ret_from_crit_exc:
1077 mfspr r9,SPRN_SPRG3 1077 mfspr r9,SPRN_SPRG_THREAD
1078 lwz r10,SAVED_KSP_LIMIT(r1) 1078 lwz r10,SAVED_KSP_LIMIT(r1)
1079 stw r10,KSP_LIMIT(r9) 1079 stw r10,KSP_LIMIT(r9)
1080 RESTORE_xSRR(SRR0,SRR1); 1080 RESTORE_xSRR(SRR0,SRR1);
@@ -1083,7 +1083,7 @@ ret_from_crit_exc:
1083 1083
1084 .globl ret_from_debug_exc 1084 .globl ret_from_debug_exc
1085ret_from_debug_exc: 1085ret_from_debug_exc:
1086 mfspr r9,SPRN_SPRG3 1086 mfspr r9,SPRN_SPRG_THREAD
1087 lwz r10,SAVED_KSP_LIMIT(r1) 1087 lwz r10,SAVED_KSP_LIMIT(r1)
1088 stw r10,KSP_LIMIT(r9) 1088 stw r10,KSP_LIMIT(r9)
1089 lwz r9,THREAD_INFO-THREAD(r9) 1089 lwz r9,THREAD_INFO-THREAD(r9)
@@ -1097,7 +1097,7 @@ ret_from_debug_exc:
1097 1097
1098 .globl ret_from_mcheck_exc 1098 .globl ret_from_mcheck_exc
1099ret_from_mcheck_exc: 1099ret_from_mcheck_exc:
1100 mfspr r9,SPRN_SPRG3 1100 mfspr r9,SPRN_SPRG_THREAD
1101 lwz r10,SAVED_KSP_LIMIT(r1) 1101 lwz r10,SAVED_KSP_LIMIT(r1)
1102 stw r10,KSP_LIMIT(r9) 1102 stw r10,KSP_LIMIT(r9)
1103 RESTORE_xSRR(SRR0,SRR1); 1103 RESTORE_xSRR(SRR0,SRR1);
@@ -1255,7 +1255,7 @@ _GLOBAL(enter_rtas)
1255 MTMSRD(r0) /* don't get trashed */ 1255 MTMSRD(r0) /* don't get trashed */
1256 li r9,MSR_KERNEL & ~(MSR_IR|MSR_DR) 1256 li r9,MSR_KERNEL & ~(MSR_IR|MSR_DR)
1257 mtlr r6 1257 mtlr r6
1258 mtspr SPRN_SPRG2,r7 1258 mtspr SPRN_SPRG_RTAS,r7
1259 mtspr SPRN_SRR0,r8 1259 mtspr SPRN_SRR0,r8
1260 mtspr SPRN_SRR1,r9 1260 mtspr SPRN_SRR1,r9
1261 RFI 1261 RFI
@@ -1265,7 +1265,7 @@ _GLOBAL(enter_rtas)
1265 FIX_SRR1(r9,r0) 1265 FIX_SRR1(r9,r0)
1266 addi r1,r1,INT_FRAME_SIZE 1266 addi r1,r1,INT_FRAME_SIZE
1267 li r0,0 1267 li r0,0
1268 mtspr SPRN_SPRG2,r0 1268 mtspr SPRN_SPRG_RTAS,r0
1269 mtspr SPRN_SRR0,r8 1269 mtspr SPRN_SRR0,r8
1270 mtspr SPRN_SRR1,r9 1270 mtspr SPRN_SRR1,r9
1271 RFI /* return to caller */ 1271 RFI /* return to caller */
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 43e073477c34..66bcda34a6bb 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -120,9 +120,15 @@ BEGIN_FW_FTR_SECTION
1202: 1202:
121END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 121END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
122#endif /* CONFIG_PPC_ISERIES */ 122#endif /* CONFIG_PPC_ISERIES */
123
124 /* Hard enable interrupts */
125#ifdef CONFIG_PPC_BOOK3E
126 wrteei 1
127#else
123 mfmsr r11 128 mfmsr r11
124 ori r11,r11,MSR_EE 129 ori r11,r11,MSR_EE
125 mtmsrd r11,1 130 mtmsrd r11,1
131#endif /* CONFIG_PPC_BOOK3E */
126 132
127#ifdef SHOW_SYSCALLS 133#ifdef SHOW_SYSCALLS
128 bl .do_show_syscall 134 bl .do_show_syscall
@@ -168,15 +174,25 @@ syscall_exit:
168#endif 174#endif
169 clrrdi r12,r1,THREAD_SHIFT 175 clrrdi r12,r1,THREAD_SHIFT
170 176
171 /* disable interrupts so current_thread_info()->flags can't change,
172 and so that we don't get interrupted after loading SRR0/1. */
173 ld r8,_MSR(r1) 177 ld r8,_MSR(r1)
178#ifdef CONFIG_PPC_BOOK3S
179 /* No MSR:RI on BookE */
174 andi. r10,r8,MSR_RI 180 andi. r10,r8,MSR_RI
175 beq- unrecov_restore 181 beq- unrecov_restore
182#endif
183
184 /* Disable interrupts so current_thread_info()->flags can't change,
185 * and so that we don't get interrupted after loading SRR0/1.
186 */
187#ifdef CONFIG_PPC_BOOK3E
188 wrteei 0
189#else
176 mfmsr r10 190 mfmsr r10
177 rldicl r10,r10,48,1 191 rldicl r10,r10,48,1
178 rotldi r10,r10,16 192 rotldi r10,r10,16
179 mtmsrd r10,1 193 mtmsrd r10,1
194#endif /* CONFIG_PPC_BOOK3E */
195
180 ld r9,TI_FLAGS(r12) 196 ld r9,TI_FLAGS(r12)
181 li r11,-_LAST_ERRNO 197 li r11,-_LAST_ERRNO
182 andi. r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) 198 andi. r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
@@ -194,9 +210,13 @@ syscall_error_cont:
194 * userspace and we take an exception after restoring r13, 210 * userspace and we take an exception after restoring r13,
195 * we end up corrupting the userspace r13 value. 211 * we end up corrupting the userspace r13 value.
196 */ 212 */
213#ifdef CONFIG_PPC_BOOK3S
214 /* No MSR:RI on BookE */
197 li r12,MSR_RI 215 li r12,MSR_RI
198 andc r11,r10,r12 216 andc r11,r10,r12
199 mtmsrd r11,1 /* clear MSR.RI */ 217 mtmsrd r11,1 /* clear MSR.RI */
218#endif /* CONFIG_PPC_BOOK3S */
219
200 beq- 1f 220 beq- 1f
201 ACCOUNT_CPU_USER_EXIT(r11, r12) 221 ACCOUNT_CPU_USER_EXIT(r11, r12)
202 ld r13,GPR13(r1) /* only restore r13 if returning to usermode */ 222 ld r13,GPR13(r1) /* only restore r13 if returning to usermode */
@@ -206,7 +226,7 @@ syscall_error_cont:
206 mtcr r5 226 mtcr r5
207 mtspr SPRN_SRR0,r7 227 mtspr SPRN_SRR0,r7
208 mtspr SPRN_SRR1,r8 228 mtspr SPRN_SRR1,r8
209 rfid 229 RFI
210 b . /* prevent speculative execution */ 230 b . /* prevent speculative execution */
211 231
212syscall_error: 232syscall_error:
@@ -276,9 +296,13 @@ syscall_exit_work:
276 beq .ret_from_except_lite 296 beq .ret_from_except_lite
277 297
278 /* Re-enable interrupts */ 298 /* Re-enable interrupts */
299#ifdef CONFIG_PPC_BOOK3E
300 wrteei 1
301#else
279 mfmsr r10 302 mfmsr r10
280 ori r10,r10,MSR_EE 303 ori r10,r10,MSR_EE
281 mtmsrd r10,1 304 mtmsrd r10,1
305#endif /* CONFIG_PPC_BOOK3E */
282 306
283 bl .save_nvgprs 307 bl .save_nvgprs
284 addi r3,r1,STACK_FRAME_OVERHEAD 308 addi r3,r1,STACK_FRAME_OVERHEAD
@@ -380,7 +404,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
380 and. r0,r0,r22 404 and. r0,r0,r22
381 beq+ 1f 405 beq+ 1f
382 andc r22,r22,r0 406 andc r22,r22,r0
383 mtmsrd r22 407 MTMSRD(r22)
384 isync 408 isync
3851: std r20,_NIP(r1) 4091: std r20,_NIP(r1)
386 mfcr r23 410 mfcr r23
@@ -399,6 +423,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
399 std r6,PACACURRENT(r13) /* Set new 'current' */ 423 std r6,PACACURRENT(r13) /* Set new 'current' */
400 424
401 ld r8,KSP(r4) /* new stack pointer */ 425 ld r8,KSP(r4) /* new stack pointer */
426#ifdef CONFIG_PPC_BOOK3S
402BEGIN_FTR_SECTION 427BEGIN_FTR_SECTION
403 BEGIN_FTR_SECTION_NESTED(95) 428 BEGIN_FTR_SECTION_NESTED(95)
404 clrrdi r6,r8,28 /* get its ESID */ 429 clrrdi r6,r8,28 /* get its ESID */
@@ -445,8 +470,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_1T_SEGMENT)
445 slbie r6 /* Workaround POWER5 < DD2.1 issue */ 470 slbie r6 /* Workaround POWER5 < DD2.1 issue */
446 slbmte r7,r0 471 slbmte r7,r0
447 isync 472 isync
448
4492: 4732:
474#endif /* !CONFIG_PPC_BOOK3S */
475
450 clrrdi r7,r8,THREAD_SHIFT /* base of new stack */ 476 clrrdi r7,r8,THREAD_SHIFT /* base of new stack */
451 /* Note: this uses SWITCH_FRAME_SIZE rather than INT_FRAME_SIZE 477 /* Note: this uses SWITCH_FRAME_SIZE rather than INT_FRAME_SIZE
452 because we don't need to leave the 288-byte ABI gap at the 478 because we don't need to leave the 288-byte ABI gap at the
@@ -490,10 +516,14 @@ _GLOBAL(ret_from_except_lite)
490 * can't change between when we test it and when we return 516 * can't change between when we test it and when we return
491 * from the interrupt. 517 * from the interrupt.
492 */ 518 */
519#ifdef CONFIG_PPC_BOOK3E
520 wrteei 0
521#else
493 mfmsr r10 /* Get current interrupt state */ 522 mfmsr r10 /* Get current interrupt state */
494 rldicl r9,r10,48,1 /* clear MSR_EE */ 523 rldicl r9,r10,48,1 /* clear MSR_EE */
495 rotldi r9,r9,16 524 rotldi r9,r9,16
496 mtmsrd r9,1 /* Update machine state */ 525 mtmsrd r9,1 /* Update machine state */
526#endif /* CONFIG_PPC_BOOK3E */
497 527
498#ifdef CONFIG_PREEMPT 528#ifdef CONFIG_PREEMPT
499 clrrdi r9,r1,THREAD_SHIFT /* current_thread_info() */ 529 clrrdi r9,r1,THREAD_SHIFT /* current_thread_info() */
@@ -540,6 +570,9 @@ ALT_FW_FTR_SECTION_END_IFCLR(FW_FEATURE_ISERIES)
540 rldicl r4,r3,49,63 /* r0 = (r3 >> 15) & 1 */ 570 rldicl r4,r3,49,63 /* r0 = (r3 >> 15) & 1 */
541 stb r4,PACAHARDIRQEN(r13) 571 stb r4,PACAHARDIRQEN(r13)
542 572
573#ifdef CONFIG_PPC_BOOK3E
574 b .exception_return_book3e
575#else
543 ld r4,_CTR(r1) 576 ld r4,_CTR(r1)
544 ld r0,_LINK(r1) 577 ld r0,_LINK(r1)
545 mtctr r4 578 mtctr r4
@@ -588,6 +621,8 @@ ALT_FW_FTR_SECTION_END_IFCLR(FW_FEATURE_ISERIES)
588 rfid 621 rfid
589 b . /* prevent speculative execution */ 622 b . /* prevent speculative execution */
590 623
624#endif /* CONFIG_PPC_BOOK3E */
625
591iseries_check_pending_irqs: 626iseries_check_pending_irqs:
592#ifdef CONFIG_PPC_ISERIES 627#ifdef CONFIG_PPC_ISERIES
593 ld r5,SOFTE(r1) 628 ld r5,SOFTE(r1)
@@ -638,6 +673,11 @@ do_work:
638 li r0,1 673 li r0,1
639 stb r0,PACASOFTIRQEN(r13) 674 stb r0,PACASOFTIRQEN(r13)
640 stb r0,PACAHARDIRQEN(r13) 675 stb r0,PACAHARDIRQEN(r13)
676#ifdef CONFIG_PPC_BOOK3E
677 wrteei 1
678 bl .preempt_schedule
679 wrteei 0
680#else
641 ori r10,r10,MSR_EE 681 ori r10,r10,MSR_EE
642 mtmsrd r10,1 /* reenable interrupts */ 682 mtmsrd r10,1 /* reenable interrupts */
643 bl .preempt_schedule 683 bl .preempt_schedule
@@ -646,6 +686,7 @@ do_work:
646 rldicl r10,r10,48,1 /* disable interrupts again */ 686 rldicl r10,r10,48,1 /* disable interrupts again */
647 rotldi r10,r10,16 687 rotldi r10,r10,16
648 mtmsrd r10,1 688 mtmsrd r10,1
689#endif /* CONFIG_PPC_BOOK3E */
649 ld r4,TI_FLAGS(r9) 690 ld r4,TI_FLAGS(r9)
650 andi. r0,r4,_TIF_NEED_RESCHED 691 andi. r0,r4,_TIF_NEED_RESCHED
651 bne 1b 692 bne 1b
@@ -654,8 +695,12 @@ do_work:
654user_work: 695user_work:
655#endif 696#endif
656 /* Enable interrupts */ 697 /* Enable interrupts */
698#ifdef CONFIG_PPC_BOOK3E
699 wrteei 1
700#else
657 ori r10,r10,MSR_EE 701 ori r10,r10,MSR_EE
658 mtmsrd r10,1 702 mtmsrd r10,1
703#endif /* CONFIG_PPC_BOOK3E */
659 704
660 andi. r0,r4,_TIF_NEED_RESCHED 705 andi. r0,r4,_TIF_NEED_RESCHED
661 beq 1f 706 beq 1f
@@ -762,7 +807,7 @@ _GLOBAL(enter_rtas)
762 807
763_STATIC(rtas_return_loc) 808_STATIC(rtas_return_loc)
764 /* relocation is off at this point */ 809 /* relocation is off at this point */
765 mfspr r4,SPRN_SPRG3 /* Get PACA */ 810 mfspr r4,SPRN_SPRG_PACA /* Get PACA */
766 clrldi r4,r4,2 /* convert to realmode address */ 811 clrldi r4,r4,2 /* convert to realmode address */
767 812
768 bcl 20,31,$+4 813 bcl 20,31,$+4
@@ -793,7 +838,7 @@ _STATIC(rtas_restore_regs)
793 REST_8GPRS(14, r1) /* Restore the non-volatiles */ 838 REST_8GPRS(14, r1) /* Restore the non-volatiles */
794 REST_10GPRS(22, r1) /* ditto */ 839 REST_10GPRS(22, r1) /* ditto */
795 840
796 mfspr r13,SPRN_SPRG3 841 mfspr r13,SPRN_SPRG_PACA
797 842
798 ld r4,_CCR(r1) 843 ld r4,_CCR(r1)
799 mtcr r4 844 mtcr r4
@@ -823,33 +868,24 @@ _GLOBAL(enter_prom)
823 * of all registers that it saves. We therefore save those registers 868 * of all registers that it saves. We therefore save those registers
824 * PROM might touch to the stack. (r0, r3-r13 are caller saved) 869 * PROM might touch to the stack. (r0, r3-r13 are caller saved)
825 */ 870 */
826 SAVE_8GPRS(2, r1) 871 SAVE_GPR(2, r1)
827 SAVE_GPR(13, r1) 872 SAVE_GPR(13, r1)
828 SAVE_8GPRS(14, r1) 873 SAVE_8GPRS(14, r1)
829 SAVE_10GPRS(22, r1) 874 SAVE_10GPRS(22, r1)
830 mfcr r4 875 mfcr r10
831 std r4,_CCR(r1)
832 mfctr r5
833 std r5,_CTR(r1)
834 mfspr r6,SPRN_XER
835 std r6,_XER(r1)
836 mfdar r7
837 std r7,_DAR(r1)
838 mfdsisr r8
839 std r8,_DSISR(r1)
840 mfsrr0 r9
841 std r9,_SRR0(r1)
842 mfsrr1 r10
843 std r10,_SRR1(r1)
844 mfmsr r11 876 mfmsr r11
877 std r10,_CCR(r1)
845 std r11,_MSR(r1) 878 std r11,_MSR(r1)
846 879
847 /* Get the PROM entrypoint */ 880 /* Get the PROM entrypoint */
848 ld r0,GPR4(r1) 881 mtlr r4
849 mtlr r0
850 882
851 /* Switch MSR to 32 bits mode 883 /* Switch MSR to 32 bits mode
852 */ 884 */
885#ifdef CONFIG_PPC_BOOK3E
886 rlwinm r11,r11,0,1,31
887 mtmsr r11
888#else /* CONFIG_PPC_BOOK3E */
853 mfmsr r11 889 mfmsr r11
854 li r12,1 890 li r12,1
855 rldicr r12,r12,MSR_SF_LG,(63-MSR_SF_LG) 891 rldicr r12,r12,MSR_SF_LG,(63-MSR_SF_LG)
@@ -858,10 +894,10 @@ _GLOBAL(enter_prom)
858 rldicr r12,r12,MSR_ISF_LG,(63-MSR_ISF_LG) 894 rldicr r12,r12,MSR_ISF_LG,(63-MSR_ISF_LG)
859 andc r11,r11,r12 895 andc r11,r11,r12
860 mtmsrd r11 896 mtmsrd r11
897#endif /* CONFIG_PPC_BOOK3E */
861 isync 898 isync
862 899
863 /* Restore arguments & enter PROM here... */ 900 /* Enter PROM here... */
864 ld r3,GPR3(r1)
865 blrl 901 blrl
866 902
867 /* Just make sure that r1 top 32 bits didn't get 903 /* Just make sure that r1 top 32 bits didn't get
@@ -871,7 +907,7 @@ _GLOBAL(enter_prom)
871 907
872 /* Restore the MSR (back to 64 bits) */ 908 /* Restore the MSR (back to 64 bits) */
873 ld r0,_MSR(r1) 909 ld r0,_MSR(r1)
874 mtmsrd r0 910 MTMSRD(r0)
875 isync 911 isync
876 912
877 /* Restore other registers */ 913 /* Restore other registers */
@@ -881,18 +917,6 @@ _GLOBAL(enter_prom)
881 REST_10GPRS(22, r1) 917 REST_10GPRS(22, r1)
882 ld r4,_CCR(r1) 918 ld r4,_CCR(r1)
883 mtcr r4 919 mtcr r4
884 ld r5,_CTR(r1)
885 mtctr r5
886 ld r6,_XER(r1)
887 mtspr SPRN_XER,r6
888 ld r7,_DAR(r1)
889 mtdar r7
890 ld r8,_DSISR(r1)
891 mtdsisr r8
892 ld r9,_SRR0(r1)
893 mtsrr0 r9
894 ld r10,_SRR1(r1)
895 mtsrr1 r10
896 920
897 addi r1,r1,PROM_FRAME_SIZE 921 addi r1,r1,PROM_FRAME_SIZE
898 ld r0,16(r1) 922 ld r0,16(r1)
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
new file mode 100644
index 000000000000..9048f96237f6
--- /dev/null
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -0,0 +1,1001 @@
1/*
2 * Boot code and exception vectors for Book3E processors
3 *
4 * Copyright (C) 2007 Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/threads.h>
13#include <asm/reg.h>
14#include <asm/page.h>
15#include <asm/ppc_asm.h>
16#include <asm/asm-offsets.h>
17#include <asm/cputable.h>
18#include <asm/setup.h>
19#include <asm/thread_info.h>
20#include <asm/reg.h>
21#include <asm/exception-64e.h>
22#include <asm/bug.h>
23#include <asm/irqflags.h>
24#include <asm/ptrace.h>
25#include <asm/ppc-opcode.h>
26#include <asm/mmu.h>
27
28/* XXX This will ultimately add space for a special exception save
29 * structure used to save things like SRR0/SRR1, SPRGs, MAS, etc...
30 * when taking special interrupts. For now we don't support that,
31 * special interrupts from within a non-standard level will probably
32 * blow you up
33 */
34#define SPECIAL_EXC_FRAME_SIZE INT_FRAME_SIZE
35
36/* Exception prolog code for all exceptions */
37#define EXCEPTION_PROLOG(n, type, addition) \
38 mtspr SPRN_SPRG_##type##_SCRATCH,r13; /* get spare registers */ \
39 mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \
40 std r10,PACA_EX##type+EX_R10(r13); \
41 std r11,PACA_EX##type+EX_R11(r13); \
42 mfcr r10; /* save CR */ \
43 addition; /* additional code for that exc. */ \
44 std r1,PACA_EX##type+EX_R1(r13); /* save old r1 in the PACA */ \
45 stw r10,PACA_EX##type+EX_CR(r13); /* save old CR in the PACA */ \
46 mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \
47 type##_SET_KSTACK; /* get special stack if necessary */\
48 andi. r10,r11,MSR_PR; /* save stack pointer */ \
49 beq 1f; /* branch around if supervisor */ \
50 ld r1,PACAKSAVE(r13); /* get kernel stack coming from usr */\
511: cmpdi cr1,r1,0; /* check if SP makes sense */ \
52 bge- cr1,exc_##n##_bad_stack;/* bad stack (TODO: out of line) */ \
53 mfspr r10,SPRN_##type##_SRR0; /* read SRR0 before touching stack */
54
55/* Exception type-specific macros */
56#define GEN_SET_KSTACK \
57 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */
58#define SPRN_GEN_SRR0 SPRN_SRR0
59#define SPRN_GEN_SRR1 SPRN_SRR1
60
61#define CRIT_SET_KSTACK \
62 ld r1,PACA_CRIT_STACK(r13); \
63 subi r1,r1,SPECIAL_EXC_FRAME_SIZE;
64#define SPRN_CRIT_SRR0 SPRN_CSRR0
65#define SPRN_CRIT_SRR1 SPRN_CSRR1
66
67#define DBG_SET_KSTACK \
68 ld r1,PACA_DBG_STACK(r13); \
69 subi r1,r1,SPECIAL_EXC_FRAME_SIZE;
70#define SPRN_DBG_SRR0 SPRN_DSRR0
71#define SPRN_DBG_SRR1 SPRN_DSRR1
72
73#define MC_SET_KSTACK \
74 ld r1,PACA_MC_STACK(r13); \
75 subi r1,r1,SPECIAL_EXC_FRAME_SIZE;
76#define SPRN_MC_SRR0 SPRN_MCSRR0
77#define SPRN_MC_SRR1 SPRN_MCSRR1
78
79#define NORMAL_EXCEPTION_PROLOG(n, addition) \
80 EXCEPTION_PROLOG(n, GEN, addition##_GEN)
81
82#define CRIT_EXCEPTION_PROLOG(n, addition) \
83 EXCEPTION_PROLOG(n, CRIT, addition##_CRIT)
84
85#define DBG_EXCEPTION_PROLOG(n, addition) \
86 EXCEPTION_PROLOG(n, DBG, addition##_DBG)
87
88#define MC_EXCEPTION_PROLOG(n, addition) \
89 EXCEPTION_PROLOG(n, MC, addition##_MC)
90
91
92/* Variants of the "addition" argument for the prolog
93 */
94#define PROLOG_ADDITION_NONE_GEN
95#define PROLOG_ADDITION_NONE_CRIT
96#define PROLOG_ADDITION_NONE_DBG
97#define PROLOG_ADDITION_NONE_MC
98
99#define PROLOG_ADDITION_MASKABLE_GEN \
100 lbz r11,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \
101 cmpwi cr0,r11,0; /* yes -> go out of line */ \
102 beq masked_interrupt_book3e;
103
104#define PROLOG_ADDITION_2REGS_GEN \
105 std r14,PACA_EXGEN+EX_R14(r13); \
106 std r15,PACA_EXGEN+EX_R15(r13)
107
108#define PROLOG_ADDITION_1REG_GEN \
109 std r14,PACA_EXGEN+EX_R14(r13);
110
111#define PROLOG_ADDITION_2REGS_CRIT \
112 std r14,PACA_EXCRIT+EX_R14(r13); \
113 std r15,PACA_EXCRIT+EX_R15(r13)
114
115#define PROLOG_ADDITION_2REGS_DBG \
116 std r14,PACA_EXDBG+EX_R14(r13); \
117 std r15,PACA_EXDBG+EX_R15(r13)
118
119#define PROLOG_ADDITION_2REGS_MC \
120 std r14,PACA_EXMC+EX_R14(r13); \
121 std r15,PACA_EXMC+EX_R15(r13)
122
123/* Core exception code for all exceptions except TLB misses.
124 * XXX: Needs to make SPRN_SPRG_GEN depend on exception type
125 */
126#define EXCEPTION_COMMON(n, excf, ints) \
127 std r0,GPR0(r1); /* save r0 in stackframe */ \
128 std r2,GPR2(r1); /* save r2 in stackframe */ \
129 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \
130 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
131 std r9,GPR9(r1); /* save r9 in stackframe */ \
132 std r10,_NIP(r1); /* save SRR0 to stackframe */ \
133 std r11,_MSR(r1); /* save SRR1 to stackframe */ \
134 ACCOUNT_CPU_USER_ENTRY(r10,r11);/* accounting (uses cr0+eq) */ \
135 ld r3,excf+EX_R10(r13); /* get back r10 */ \
136 ld r4,excf+EX_R11(r13); /* get back r11 */ \
137 mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 */ \
138 std r12,GPR12(r1); /* save r12 in stackframe */ \
139 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \
140 mflr r6; /* save LR in stackframe */ \
141 mfctr r7; /* save CTR in stackframe */ \
142 mfspr r8,SPRN_XER; /* save XER in stackframe */ \
143 ld r9,excf+EX_R1(r13); /* load orig r1 back from PACA */ \
144 lwz r10,excf+EX_CR(r13); /* load orig CR back from PACA */ \
145 lbz r11,PACASOFTIRQEN(r13); /* get current IRQ softe */ \
146 ld r12,exception_marker@toc(r2); \
147 li r0,0; \
148 std r3,GPR10(r1); /* save r10 to stackframe */ \
149 std r4,GPR11(r1); /* save r11 to stackframe */ \
150 std r5,GPR13(r1); /* save it to stackframe */ \
151 std r6,_LINK(r1); \
152 std r7,_CTR(r1); \
153 std r8,_XER(r1); \
154 li r3,(n)+1; /* indicate partial regs in trap */ \
155 std r9,0(r1); /* store stack frame back link */ \
156 std r10,_CCR(r1); /* store orig CR in stackframe */ \
157 std r9,GPR1(r1); /* store stack frame back link */ \
158 std r11,SOFTE(r1); /* and save it to stackframe */ \
159 std r12,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ \
160 std r3,_TRAP(r1); /* set trap number */ \
161 std r0,RESULT(r1); /* clear regs->result */ \
162 ints;
163
164/* Variants for the "ints" argument */
165#define INTS_KEEP
166#define INTS_DISABLE_SOFT \
167 stb r0,PACASOFTIRQEN(r13); /* mark interrupts soft-disabled */ \
168 TRACE_DISABLE_INTS;
169#define INTS_DISABLE_HARD \
170 stb r0,PACAHARDIRQEN(r13); /* and hard disabled */
171#define INTS_DISABLE_ALL \
172 INTS_DISABLE_SOFT \
173 INTS_DISABLE_HARD
174
175/* This is called by exceptions that used INTS_KEEP (that is did not clear
176 * neither soft nor hard IRQ indicators in the PACA. This will restore MSR:EE
177 * to it's previous value
178 *
179 * XXX In the long run, we may want to open-code it in order to separate the
180 * load from the wrtee, thus limiting the latency caused by the dependency
181 * but at this point, I'll favor code clarity until we have a near to final
182 * implementation
183 */
184#define INTS_RESTORE_HARD \
185 ld r11,_MSR(r1); \
186 wrtee r11;
187
188/* XXX FIXME: Restore r14/r15 when necessary */
189#define BAD_STACK_TRAMPOLINE(n) \
190exc_##n##_bad_stack: \
191 li r1,(n); /* get exception number */ \
192 sth r1,PACA_TRAP_SAVE(r13); /* store trap */ \
193 b bad_stack_book3e; /* bad stack error */
194
195#define EXCEPTION_STUB(loc, label) \
196 . = interrupt_base_book3e + loc; \
197 nop; /* To make debug interrupts happy */ \
198 b exc_##label##_book3e;
199
200#define ACK_NONE(r)
201#define ACK_DEC(r) \
202 lis r,TSR_DIS@h; \
203 mtspr SPRN_TSR,r
204#define ACK_FIT(r) \
205 lis r,TSR_FIS@h; \
206 mtspr SPRN_TSR,r
207
208#define MASKABLE_EXCEPTION(trapnum, label, hdlr, ack) \
209 START_EXCEPTION(label); \
210 NORMAL_EXCEPTION_PROLOG(trapnum, PROLOG_ADDITION_MASKABLE) \
211 EXCEPTION_COMMON(trapnum, PACA_EXGEN, INTS_DISABLE_ALL) \
212 ack(r8); \
213 addi r3,r1,STACK_FRAME_OVERHEAD; \
214 bl hdlr; \
215 b .ret_from_except_lite;
216
217/* This value is used to mark exception frames on the stack. */
218 .section ".toc","aw"
219exception_marker:
220 .tc ID_EXC_MARKER[TC],STACK_FRAME_REGS_MARKER
221
222
223/*
224 * And here we have the exception vectors !
225 */
226
227 .text
228 .balign 0x1000
229 .globl interrupt_base_book3e
230interrupt_base_book3e: /* fake trap */
231 /* Note: If real debug exceptions are supported by the HW, the vector
232 * below will have to be patched up to point to an appropriate handler
233 */
234 EXCEPTION_STUB(0x000, machine_check) /* 0x0200 */
235 EXCEPTION_STUB(0x020, critical_input) /* 0x0580 */
236 EXCEPTION_STUB(0x040, debug_crit) /* 0x0d00 */
237 EXCEPTION_STUB(0x060, data_storage) /* 0x0300 */
238 EXCEPTION_STUB(0x080, instruction_storage) /* 0x0400 */
239 EXCEPTION_STUB(0x0a0, external_input) /* 0x0500 */
240 EXCEPTION_STUB(0x0c0, alignment) /* 0x0600 */
241 EXCEPTION_STUB(0x0e0, program) /* 0x0700 */
242 EXCEPTION_STUB(0x100, fp_unavailable) /* 0x0800 */
243 EXCEPTION_STUB(0x120, system_call) /* 0x0c00 */
244 EXCEPTION_STUB(0x140, ap_unavailable) /* 0x0f20 */
245 EXCEPTION_STUB(0x160, decrementer) /* 0x0900 */
246 EXCEPTION_STUB(0x180, fixed_interval) /* 0x0980 */
247 EXCEPTION_STUB(0x1a0, watchdog) /* 0x09f0 */
248 EXCEPTION_STUB(0x1c0, data_tlb_miss)
249 EXCEPTION_STUB(0x1e0, instruction_tlb_miss)
250
251#if 0
252 EXCEPTION_STUB(0x280, processor_doorbell)
253 EXCEPTION_STUB(0x220, processor_doorbell_crit)
254#endif
255 .globl interrupt_end_book3e
256interrupt_end_book3e:
257
258/* Critical Input Interrupt */
259 START_EXCEPTION(critical_input);
260 CRIT_EXCEPTION_PROLOG(0x100, PROLOG_ADDITION_NONE)
261// EXCEPTION_COMMON(0x100, PACA_EXCRIT, INTS_DISABLE_ALL)
262// bl special_reg_save_crit
263// addi r3,r1,STACK_FRAME_OVERHEAD
264// bl .critical_exception
265// b ret_from_crit_except
266 b .
267
268/* Machine Check Interrupt */
269 START_EXCEPTION(machine_check);
270 CRIT_EXCEPTION_PROLOG(0x200, PROLOG_ADDITION_NONE)
271// EXCEPTION_COMMON(0x200, PACA_EXMC, INTS_DISABLE_ALL)
272// bl special_reg_save_mc
273// addi r3,r1,STACK_FRAME_OVERHEAD
274// bl .machine_check_exception
275// b ret_from_mc_except
276 b .
277
278/* Data Storage Interrupt */
279 START_EXCEPTION(data_storage)
280 NORMAL_EXCEPTION_PROLOG(0x300, PROLOG_ADDITION_2REGS)
281 mfspr r14,SPRN_DEAR
282 mfspr r15,SPRN_ESR
283 EXCEPTION_COMMON(0x300, PACA_EXGEN, INTS_KEEP)
284 b storage_fault_common
285
286/* Instruction Storage Interrupt */
287 START_EXCEPTION(instruction_storage);
288 NORMAL_EXCEPTION_PROLOG(0x400, PROLOG_ADDITION_2REGS)
289 li r15,0
290 mr r14,r10
291 EXCEPTION_COMMON(0x400, PACA_EXGEN, INTS_KEEP)
292 b storage_fault_common
293
294/* External Input Interrupt */
295 MASKABLE_EXCEPTION(0x500, external_input, .do_IRQ, ACK_NONE)
296
297/* Alignment */
298 START_EXCEPTION(alignment);
299 NORMAL_EXCEPTION_PROLOG(0x600, PROLOG_ADDITION_2REGS)
300 mfspr r14,SPRN_DEAR
301 mfspr r15,SPRN_ESR
302 EXCEPTION_COMMON(0x600, PACA_EXGEN, INTS_KEEP)
303 b alignment_more /* no room, go out of line */
304
305/* Program Interrupt */
306 START_EXCEPTION(program);
307 NORMAL_EXCEPTION_PROLOG(0x700, PROLOG_ADDITION_1REG)
308 mfspr r14,SPRN_ESR
309 EXCEPTION_COMMON(0x700, PACA_EXGEN, INTS_DISABLE_SOFT)
310 std r14,_DSISR(r1)
311 addi r3,r1,STACK_FRAME_OVERHEAD
312 ld r14,PACA_EXGEN+EX_R14(r13)
313 bl .save_nvgprs
314 INTS_RESTORE_HARD
315 bl .program_check_exception
316 b .ret_from_except
317
318/* Floating Point Unavailable Interrupt */
319 START_EXCEPTION(fp_unavailable);
320 NORMAL_EXCEPTION_PROLOG(0x800, PROLOG_ADDITION_NONE)
321 /* we can probably do a shorter exception entry for that one... */
322 EXCEPTION_COMMON(0x800, PACA_EXGEN, INTS_KEEP)
323 bne 1f /* if from user, just load it up */
324 bl .save_nvgprs
325 addi r3,r1,STACK_FRAME_OVERHEAD
326 INTS_RESTORE_HARD
327 bl .kernel_fp_unavailable_exception
328 BUG_OPCODE
3291: ld r12,_MSR(r1)
330 bl .load_up_fpu
331 b fast_exception_return
332
333/* Decrementer Interrupt */
334 MASKABLE_EXCEPTION(0x900, decrementer, .timer_interrupt, ACK_DEC)
335
336/* Fixed Interval Timer Interrupt */
337 MASKABLE_EXCEPTION(0x980, fixed_interval, .unknown_exception, ACK_FIT)
338
339/* Watchdog Timer Interrupt */
340 START_EXCEPTION(watchdog);
341 CRIT_EXCEPTION_PROLOG(0x9f0, PROLOG_ADDITION_NONE)
342// EXCEPTION_COMMON(0x9f0, PACA_EXCRIT, INTS_DISABLE_ALL)
343// bl special_reg_save_crit
344// addi r3,r1,STACK_FRAME_OVERHEAD
345// bl .unknown_exception
346// b ret_from_crit_except
347 b .
348
349/* System Call Interrupt */
350 START_EXCEPTION(system_call)
351 mr r9,r13 /* keep a copy of userland r13 */
352 mfspr r11,SPRN_SRR0 /* get return address */
353 mfspr r12,SPRN_SRR1 /* get previous MSR */
354 mfspr r13,SPRN_SPRG_PACA /* get our PACA */
355 b system_call_common
356
357/* Auxillary Processor Unavailable Interrupt */
358 START_EXCEPTION(ap_unavailable);
359 NORMAL_EXCEPTION_PROLOG(0xf20, PROLOG_ADDITION_NONE)
360 EXCEPTION_COMMON(0xf20, PACA_EXGEN, INTS_KEEP)
361 addi r3,r1,STACK_FRAME_OVERHEAD
362 bl .save_nvgprs
363 INTS_RESTORE_HARD
364 bl .unknown_exception
365 b .ret_from_except
366
367/* Debug exception as a critical interrupt*/
368 START_EXCEPTION(debug_crit);
369 CRIT_EXCEPTION_PROLOG(0xd00, PROLOG_ADDITION_2REGS)
370
371 /*
372 * If there is a single step or branch-taken exception in an
373 * exception entry sequence, it was probably meant to apply to
374 * the code where the exception occurred (since exception entry
375 * doesn't turn off DE automatically). We simulate the effect
376 * of turning off DE on entry to an exception handler by turning
377 * off DE in the CSRR1 value and clearing the debug status.
378 */
379
380 mfspr r14,SPRN_DBSR /* check single-step/branch taken */
381 andis. r15,r14,DBSR_IC@h
382 beq+ 1f
383
384 LOAD_REG_IMMEDIATE(r14,interrupt_base_book3e)
385 LOAD_REG_IMMEDIATE(r15,interrupt_end_book3e)
386 cmpld cr0,r10,r14
387 cmpld cr1,r10,r15
388 blt+ cr0,1f
389 bge+ cr1,1f
390
391 /* here it looks like we got an inappropriate debug exception. */
392 lis r14,DBSR_IC@h /* clear the IC event */
393 rlwinm r11,r11,0,~MSR_DE /* clear DE in the CSRR1 value */
394 mtspr SPRN_DBSR,r14
395 mtspr SPRN_CSRR1,r11
396 lwz r10,PACA_EXCRIT+EX_CR(r13) /* restore registers */
397 ld r1,PACA_EXCRIT+EX_R1(r13)
398 ld r14,PACA_EXCRIT+EX_R14(r13)
399 ld r15,PACA_EXCRIT+EX_R15(r13)
400 mtcr r10
401 ld r10,PACA_EXCRIT+EX_R10(r13) /* restore registers */
402 ld r11,PACA_EXCRIT+EX_R11(r13)
403 mfspr r13,SPRN_SPRG_CRIT_SCRATCH
404 rfci
405
406 /* Normal debug exception */
407 /* XXX We only handle coming from userspace for now since we can't
408 * quite save properly an interrupted kernel state yet
409 */
4101: andi. r14,r11,MSR_PR; /* check for userspace again */
411 beq kernel_dbg_exc; /* if from kernel mode */
412
413 /* Now we mash up things to make it look like we are coming on a
414 * normal exception
415 */
416 mfspr r15,SPRN_SPRG_CRIT_SCRATCH
417 mtspr SPRN_SPRG_GEN_SCRATCH,r15
418 mfspr r14,SPRN_DBSR
419 EXCEPTION_COMMON(0xd00, PACA_EXCRIT, INTS_DISABLE_ALL)
420 std r14,_DSISR(r1)
421 addi r3,r1,STACK_FRAME_OVERHEAD
422 mr r4,r14
423 ld r14,PACA_EXCRIT+EX_R14(r13)
424 ld r15,PACA_EXCRIT+EX_R15(r13)
425 bl .save_nvgprs
426 bl .DebugException
427 b .ret_from_except
428
429kernel_dbg_exc:
430 b . /* NYI */
431
432
433/*
434 * An interrupt came in while soft-disabled; clear EE in SRR1,
435 * clear paca->hard_enabled and return.
436 */
437masked_interrupt_book3e:
438 mtcr r10
439 stb r11,PACAHARDIRQEN(r13)
440 mfspr r10,SPRN_SRR1
441 rldicl r11,r10,48,1 /* clear MSR_EE */
442 rotldi r10,r11,16
443 mtspr SPRN_SRR1,r10
444 ld r10,PACA_EXGEN+EX_R10(r13); /* restore registers */
445 ld r11,PACA_EXGEN+EX_R11(r13);
446 mfspr r13,SPRN_SPRG_GEN_SCRATCH;
447 rfi
448 b .
449
450/*
451 * This is called from 0x300 and 0x400 handlers after the prologs with
452 * r14 and r15 containing the fault address and error code, with the
453 * original values stashed away in the PACA
454 */
455storage_fault_common:
456 std r14,_DAR(r1)
457 std r15,_DSISR(r1)
458 addi r3,r1,STACK_FRAME_OVERHEAD
459 mr r4,r14
460 mr r5,r15
461 ld r14,PACA_EXGEN+EX_R14(r13)
462 ld r15,PACA_EXGEN+EX_R15(r13)
463 INTS_RESTORE_HARD
464 bl .do_page_fault
465 cmpdi r3,0
466 bne- 1f
467 b .ret_from_except_lite
4681: bl .save_nvgprs
469 mr r5,r3
470 addi r3,r1,STACK_FRAME_OVERHEAD
471 ld r4,_DAR(r1)
472 bl .bad_page_fault
473 b .ret_from_except
474
475/*
476 * Alignment exception doesn't fit entirely in the 0x100 bytes so it
477 * continues here.
478 */
479alignment_more:
480 std r14,_DAR(r1)
481 std r15,_DSISR(r1)
482 addi r3,r1,STACK_FRAME_OVERHEAD
483 ld r14,PACA_EXGEN+EX_R14(r13)
484 ld r15,PACA_EXGEN+EX_R15(r13)
485 bl .save_nvgprs
486 INTS_RESTORE_HARD
487 bl .alignment_exception
488 b .ret_from_except
489
490/*
491 * We branch here from entry_64.S for the last stage of the exception
492 * return code path. MSR:EE is expected to be off at that point
493 */
494_GLOBAL(exception_return_book3e)
495 b 1f
496
497/* This is the return from load_up_fpu fast path which could do with
498 * less GPR restores in fact, but for now we have a single return path
499 */
500 .globl fast_exception_return
501fast_exception_return:
502 wrteei 0
5031: mr r0,r13
504 ld r10,_MSR(r1)
505 REST_4GPRS(2, r1)
506 andi. r6,r10,MSR_PR
507 REST_2GPRS(6, r1)
508 beq 1f
509 ACCOUNT_CPU_USER_EXIT(r10, r11)
510 ld r0,GPR13(r1)
511
5121: stdcx. r0,0,r1 /* to clear the reservation */
513
514 ld r8,_CCR(r1)
515 ld r9,_LINK(r1)
516 ld r10,_CTR(r1)
517 ld r11,_XER(r1)
518 mtcr r8
519 mtlr r9
520 mtctr r10
521 mtxer r11
522 REST_2GPRS(8, r1)
523 ld r10,GPR10(r1)
524 ld r11,GPR11(r1)
525 ld r12,GPR12(r1)
526 mtspr SPRN_SPRG_GEN_SCRATCH,r0
527
528 std r10,PACA_EXGEN+EX_R10(r13);
529 std r11,PACA_EXGEN+EX_R11(r13);
530 ld r10,_NIP(r1)
531 ld r11,_MSR(r1)
532 ld r0,GPR0(r1)
533 ld r1,GPR1(r1)
534 mtspr SPRN_SRR0,r10
535 mtspr SPRN_SRR1,r11
536 ld r10,PACA_EXGEN+EX_R10(r13)
537 ld r11,PACA_EXGEN+EX_R11(r13)
538 mfspr r13,SPRN_SPRG_GEN_SCRATCH
539 rfi
540
541/*
542 * Trampolines used when spotting a bad kernel stack pointer in
543 * the exception entry code.
544 *
545 * TODO: move some bits like SRR0 read to trampoline, pass PACA
546 * index around, etc... to handle crit & mcheck
547 */
548BAD_STACK_TRAMPOLINE(0x000)
549BAD_STACK_TRAMPOLINE(0x100)
550BAD_STACK_TRAMPOLINE(0x200)
551BAD_STACK_TRAMPOLINE(0x300)
552BAD_STACK_TRAMPOLINE(0x400)
553BAD_STACK_TRAMPOLINE(0x500)
554BAD_STACK_TRAMPOLINE(0x600)
555BAD_STACK_TRAMPOLINE(0x700)
556BAD_STACK_TRAMPOLINE(0x800)
557BAD_STACK_TRAMPOLINE(0x900)
558BAD_STACK_TRAMPOLINE(0x980)
559BAD_STACK_TRAMPOLINE(0x9f0)
560BAD_STACK_TRAMPOLINE(0xa00)
561BAD_STACK_TRAMPOLINE(0xb00)
562BAD_STACK_TRAMPOLINE(0xc00)
563BAD_STACK_TRAMPOLINE(0xd00)
564BAD_STACK_TRAMPOLINE(0xe00)
565BAD_STACK_TRAMPOLINE(0xf00)
566BAD_STACK_TRAMPOLINE(0xf20)
567
568 .globl bad_stack_book3e
569bad_stack_book3e:
570 /* XXX: Needs to make SPRN_SPRG_GEN depend on exception type */
571 mfspr r10,SPRN_SRR0; /* read SRR0 before touching stack */
572 ld r1,PACAEMERGSP(r13)
573 subi r1,r1,64+INT_FRAME_SIZE
574 std r10,_NIP(r1)
575 std r11,_MSR(r1)
576 ld r10,PACA_EXGEN+EX_R1(r13) /* FIXME for crit & mcheck */
577 lwz r11,PACA_EXGEN+EX_CR(r13) /* FIXME for crit & mcheck */
578 std r10,GPR1(r1)
579 std r11,_CCR(r1)
580 mfspr r10,SPRN_DEAR
581 mfspr r11,SPRN_ESR
582 std r10,_DAR(r1)
583 std r11,_DSISR(r1)
584 std r0,GPR0(r1); /* save r0 in stackframe */ \
585 std r2,GPR2(r1); /* save r2 in stackframe */ \
586 SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \
587 SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
588 std r9,GPR9(r1); /* save r9 in stackframe */ \
589 ld r3,PACA_EXGEN+EX_R10(r13);/* get back r10 */ \
590 ld r4,PACA_EXGEN+EX_R11(r13);/* get back r11 */ \
591 mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 XXX can be wrong */ \
592 std r3,GPR10(r1); /* save r10 to stackframe */ \
593 std r4,GPR11(r1); /* save r11 to stackframe */ \
594 std r12,GPR12(r1); /* save r12 in stackframe */ \
595 std r5,GPR13(r1); /* save it to stackframe */ \
596 mflr r10
597 mfctr r11
598 mfxer r12
599 std r10,_LINK(r1)
600 std r11,_CTR(r1)
601 std r12,_XER(r1)
602 SAVE_10GPRS(14,r1)
603 SAVE_8GPRS(24,r1)
604 lhz r12,PACA_TRAP_SAVE(r13)
605 std r12,_TRAP(r1)
606 addi r11,r1,INT_FRAME_SIZE
607 std r11,0(r1)
608 li r12,0
609 std r12,0(r11)
610 ld r2,PACATOC(r13)
6111: addi r3,r1,STACK_FRAME_OVERHEAD
612 bl .kernel_bad_stack
613 b 1b
614
615/*
616 * Setup the initial TLB for a core. This current implementation
617 * assume that whatever we are running off will not conflict with
618 * the new mapping at PAGE_OFFSET.
619 */
620_GLOBAL(initial_tlb_book3e)
621
622 /* Look for the first TLB with IPROT set */
623 mfspr r4,SPRN_TLB0CFG
624 andi. r3,r4,TLBnCFG_IPROT
625 lis r3,MAS0_TLBSEL(0)@h
626 bne found_iprot
627
628 mfspr r4,SPRN_TLB1CFG
629 andi. r3,r4,TLBnCFG_IPROT
630 lis r3,MAS0_TLBSEL(1)@h
631 bne found_iprot
632
633 mfspr r4,SPRN_TLB2CFG
634 andi. r3,r4,TLBnCFG_IPROT
635 lis r3,MAS0_TLBSEL(2)@h
636 bne found_iprot
637
638 lis r3,MAS0_TLBSEL(3)@h
639 mfspr r4,SPRN_TLB3CFG
640 /* fall through */
641
642found_iprot:
643 andi. r5,r4,TLBnCFG_HES
644 bne have_hes
645
646 mflr r8 /* save LR */
647/* 1. Find the index of the entry we're executing in
648 *
649 * r3 = MAS0_TLBSEL (for the iprot array)
650 * r4 = SPRN_TLBnCFG
651 */
652 bl invstr /* Find our address */
653invstr: mflr r6 /* Make it accessible */
654 mfmsr r7
655 rlwinm r5,r7,27,31,31 /* extract MSR[IS] */
656 mfspr r7,SPRN_PID
657 slwi r7,r7,16
658 or r7,r7,r5
659 mtspr SPRN_MAS6,r7
660 tlbsx 0,r6 /* search MSR[IS], SPID=PID */
661
662 mfspr r3,SPRN_MAS0
663 rlwinm r5,r3,16,20,31 /* Extract MAS0(Entry) */
664
665 mfspr r7,SPRN_MAS1 /* Insure IPROT set */
666 oris r7,r7,MAS1_IPROT@h
667 mtspr SPRN_MAS1,r7
668 tlbwe
669
670/* 2. Invalidate all entries except the entry we're executing in
671 *
672 * r3 = MAS0 w/TLBSEL & ESEL for the entry we are running in
673 * r4 = SPRN_TLBnCFG
674 * r5 = ESEL of entry we are running in
675 */
676 andi. r4,r4,TLBnCFG_N_ENTRY /* Extract # entries */
677 li r6,0 /* Set Entry counter to 0 */
6781: mr r7,r3 /* Set MAS0(TLBSEL) */
679 rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */
680 mtspr SPRN_MAS0,r7
681 tlbre
682 mfspr r7,SPRN_MAS1
683 rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */
684 cmpw r5,r6
685 beq skpinv /* Dont update the current execution TLB */
686 mtspr SPRN_MAS1,r7
687 tlbwe
688 isync
689skpinv: addi r6,r6,1 /* Increment */
690 cmpw r6,r4 /* Are we done? */
691 bne 1b /* If not, repeat */
692
693 /* Invalidate all TLBs */
694 PPC_TLBILX_ALL(0,0)
695 sync
696 isync
697
698/* 3. Setup a temp mapping and jump to it
699 *
700 * r3 = MAS0 w/TLBSEL & ESEL for the entry we are running in
701 * r5 = ESEL of entry we are running in
702 */
703 andi. r7,r5,0x1 /* Find an entry not used and is non-zero */
704 addi r7,r7,0x1
705 mr r4,r3 /* Set MAS0(TLBSEL) = 1 */
706 mtspr SPRN_MAS0,r4
707 tlbre
708
709 rlwimi r4,r7,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r7) */
710 mtspr SPRN_MAS0,r4
711
712 mfspr r7,SPRN_MAS1
713 xori r6,r7,MAS1_TS /* Setup TMP mapping in the other Address space */
714 mtspr SPRN_MAS1,r6
715
716 tlbwe
717
718 mfmsr r6
719 xori r6,r6,MSR_IS
720 mtspr SPRN_SRR1,r6
721 bl 1f /* Find our address */
7221: mflr r6
723 addi r6,r6,(2f - 1b)
724 mtspr SPRN_SRR0,r6
725 rfi
7262:
727
728/* 4. Clear out PIDs & Search info
729 *
730 * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in
731 * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
732 * r5 = MAS3
733 */
734 li r6,0
735 mtspr SPRN_MAS6,r6
736 mtspr SPRN_PID,r6
737
738/* 5. Invalidate mapping we started in
739 *
740 * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in
741 * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
742 * r5 = MAS3
743 */
744 mtspr SPRN_MAS0,r3
745 tlbre
746 mfspr r6,SPRN_MAS1
747 rlwinm r6,r6,0,2,0 /* clear IPROT */
748 mtspr SPRN_MAS1,r6
749 tlbwe
750
751 /* Invalidate TLB1 */
752 PPC_TLBILX_ALL(0,0)
753 sync
754 isync
755
756/* The mapping only needs to be cache-coherent on SMP */
757#ifdef CONFIG_SMP
758#define M_IF_SMP MAS2_M
759#else
760#define M_IF_SMP 0
761#endif
762
763/* 6. Setup KERNELBASE mapping in TLB[0]
764 *
765 * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in
766 * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
767 * r5 = MAS3
768 */
769 rlwinm r3,r3,0,16,3 /* clear ESEL */
770 mtspr SPRN_MAS0,r3
771 lis r6,(MAS1_VALID|MAS1_IPROT)@h
772 ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_1GB))@l
773 mtspr SPRN_MAS1,r6
774
775 LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET | M_IF_SMP)
776 mtspr SPRN_MAS2,r6
777
778 rlwinm r5,r5,0,0,25
779 ori r5,r5,MAS3_SR | MAS3_SW | MAS3_SX
780 mtspr SPRN_MAS3,r5
781 li r5,-1
782 rlwinm r5,r5,0,0,25
783
784 tlbwe
785
786/* 7. Jump to KERNELBASE mapping
787 *
788 * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
789 */
790 /* Now we branch the new virtual address mapped by this entry */
791 LOAD_REG_IMMEDIATE(r6,2f)
792 lis r7,MSR_KERNEL@h
793 ori r7,r7,MSR_KERNEL@l
794 mtspr SPRN_SRR0,r6
795 mtspr SPRN_SRR1,r7
796 rfi /* start execution out of TLB1[0] entry */
7972:
798
799/* 8. Clear out the temp mapping
800 *
801 * r4 = MAS0 w/TLBSEL & ESEL for the entry we are running in
802 */
803 mtspr SPRN_MAS0,r4
804 tlbre
805 mfspr r5,SPRN_MAS1
806 rlwinm r5,r5,0,2,0 /* clear IPROT */
807 mtspr SPRN_MAS1,r5
808 tlbwe
809
810 /* Invalidate TLB1 */
811 PPC_TLBILX_ALL(0,0)
812 sync
813 isync
814
815 /* We translate LR and return */
816 tovirt(r8,r8)
817 mtlr r8
818 blr
819
820have_hes:
821 /* Setup MAS 0,1,2,3 and 7 for tlbwe of a 1G entry that maps the
822 * kernel linear mapping. We also set MAS8 once for all here though
823 * that will have to be made dependent on whether we are running under
824 * a hypervisor I suppose.
825 */
826 ori r3,r3,MAS0_HES | MAS0_WQ_ALLWAYS
827 mtspr SPRN_MAS0,r3
828 lis r3,(MAS1_VALID | MAS1_IPROT)@h
829 ori r3,r3,BOOK3E_PAGESZ_1GB << MAS1_TSIZE_SHIFT
830 mtspr SPRN_MAS1,r3
831 LOAD_REG_IMMEDIATE(r3, PAGE_OFFSET | MAS2_M)
832 mtspr SPRN_MAS2,r3
833 li r3,MAS3_SR | MAS3_SW | MAS3_SX
834 mtspr SPRN_MAS7_MAS3,r3
835 li r3,0
836 mtspr SPRN_MAS8,r3
837
838 /* Write the TLB entry */
839 tlbwe
840
841 /* Now we branch the new virtual address mapped by this entry */
842 LOAD_REG_IMMEDIATE(r3,1f)
843 mtctr r3
844 bctr
845
8461: /* We are now running at PAGE_OFFSET, clean the TLB of everything
847 * else (XXX we should scan for bolted crap from the firmware too)
848 */
849 PPC_TLBILX(0,0,0)
850 sync
851 isync
852
853 /* We translate LR and return */
854 mflr r3
855 tovirt(r3,r3)
856 mtlr r3
857 blr
858
859/*
860 * Main entry (boot CPU, thread 0)
861 *
862 * We enter here from head_64.S, possibly after the prom_init trampoline
863 * with r3 and r4 already saved to r31 and 30 respectively and in 64 bits
864 * mode. Anything else is as it was left by the bootloader
865 *
866 * Initial requirements of this port:
867 *
868 * - Kernel loaded at 0 physical
869 * - A good lump of memory mapped 0:0 by UTLB entry 0
870 * - MSR:IS & MSR:DS set to 0
871 *
872 * Note that some of the above requirements will be relaxed in the future
873 * as the kernel becomes smarter at dealing with different initial conditions
874 * but for now you have to be careful
875 */
876_GLOBAL(start_initialization_book3e)
877 mflr r28
878
879 /* First, we need to setup some initial TLBs to map the kernel
880 * text, data and bss at PAGE_OFFSET. We don't have a real mode
881 * and always use AS 0, so we just set it up to match our link
882 * address and never use 0 based addresses.
883 */
884 bl .initial_tlb_book3e
885
886 /* Init global core bits */
887 bl .init_core_book3e
888
889 /* Init per-thread bits */
890 bl .init_thread_book3e
891
892 /* Return to common init code */
893 tovirt(r28,r28)
894 mtlr r28
895 blr
896
897
898/*
899 * Secondary core/processor entry
900 *
901 * This is entered for thread 0 of a secondary core, all other threads
902 * are expected to be stopped. It's similar to start_initialization_book3e
903 * except that it's generally entered from the holding loop in head_64.S
904 * after CPUs have been gathered by Open Firmware.
905 *
906 * We assume we are in 32 bits mode running with whatever TLB entry was
907 * set for us by the firmware or POR engine.
908 */
909_GLOBAL(book3e_secondary_core_init_tlb_set)
910 li r4,1
911 b .generic_secondary_smp_init
912
913_GLOBAL(book3e_secondary_core_init)
914 mflr r28
915
916 /* Do we need to setup initial TLB entry ? */
917 cmplwi r4,0
918 bne 2f
919
920 /* Setup TLB for this core */
921 bl .initial_tlb_book3e
922
923 /* We can return from the above running at a different
924 * address, so recalculate r2 (TOC)
925 */
926 bl .relative_toc
927
928 /* Init global core bits */
9292: bl .init_core_book3e
930
931 /* Init per-thread bits */
9323: bl .init_thread_book3e
933
934 /* Return to common init code at proper virtual address.
935 *
936 * Due to various previous assumptions, we know we entered this
937 * function at either the final PAGE_OFFSET mapping or using a
938 * 1:1 mapping at 0, so we don't bother doing a complicated check
939 * here, we just ensure the return address has the right top bits.
940 *
941 * Note that if we ever want to be smarter about where we can be
942 * started from, we have to be careful that by the time we reach
943 * the code below we may already be running at a different location
944 * than the one we were called from since initial_tlb_book3e can
945 * have moved us already.
946 */
947 cmpdi cr0,r28,0
948 blt 1f
949 lis r3,PAGE_OFFSET@highest
950 sldi r3,r3,32
951 or r28,r28,r3
9521: mtlr r28
953 blr
954
955_GLOBAL(book3e_secondary_thread_init)
956 mflr r28
957 b 3b
958
959_STATIC(init_core_book3e)
960 /* Establish the interrupt vector base */
961 LOAD_REG_IMMEDIATE(r3, interrupt_base_book3e)
962 mtspr SPRN_IVPR,r3
963 sync
964 blr
965
966_STATIC(init_thread_book3e)
967 lis r3,(SPRN_EPCR_ICM | SPRN_EPCR_GICM)@h
968 mtspr SPRN_EPCR,r3
969
970 /* Make sure interrupts are off */
971 wrteei 0
972
973 /* disable all timers and clear out status */
974 li r3,0
975 mtspr SPRN_TCR,r3
976 mfspr r3,SPRN_TSR
977 mtspr SPRN_TSR,r3
978
979 blr
980
981_GLOBAL(__setup_base_ivors)
982 SET_IVOR(0, 0x020) /* Critical Input */
983 SET_IVOR(1, 0x000) /* Machine Check */
984 SET_IVOR(2, 0x060) /* Data Storage */
985 SET_IVOR(3, 0x080) /* Instruction Storage */
986 SET_IVOR(4, 0x0a0) /* External Input */
987 SET_IVOR(5, 0x0c0) /* Alignment */
988 SET_IVOR(6, 0x0e0) /* Program */
989 SET_IVOR(7, 0x100) /* FP Unavailable */
990 SET_IVOR(8, 0x120) /* System Call */
991 SET_IVOR(9, 0x140) /* Auxiliary Processor Unavailable */
992 SET_IVOR(10, 0x160) /* Decrementer */
993 SET_IVOR(11, 0x180) /* Fixed Interval Timer */
994 SET_IVOR(12, 0x1a0) /* Watchdog Timer */
995 SET_IVOR(13, 0x1c0) /* Data TLB Error */
996 SET_IVOR(14, 0x1e0) /* Instruction TLB Error */
997 SET_IVOR(15, 0x040) /* Debug */
998
999 sync
1000
1001 blr
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 8ac85e08ffae..1808876edcc9 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -12,6 +12,8 @@
12 * 12 *
13 */ 13 */
14 14
15#include <asm/exception-64s.h>
16
15/* 17/*
16 * We layout physical memory as follows: 18 * We layout physical memory as follows:
17 * 0x0000 - 0x00ff : Secondary processor spin code 19 * 0x0000 - 0x00ff : Secondary processor spin code
@@ -22,18 +24,6 @@
22 * 0x8000 - : Early init and support code 24 * 0x8000 - : Early init and support code
23 */ 25 */
24 26
25
26/*
27 * SPRG Usage
28 *
29 * Register Definition
30 *
31 * SPRG0 reserved for hypervisor
32 * SPRG1 temp - used to save gpr
33 * SPRG2 temp - used to save gpr
34 * SPRG3 virt addr of paca
35 */
36
37/* 27/*
38 * This is the start of the interrupt handlers for pSeries 28 * This is the start of the interrupt handlers for pSeries
39 * This code runs with relocation off. 29 * This code runs with relocation off.
@@ -51,34 +41,44 @@ __start_interrupts:
51 . = 0x200 41 . = 0x200
52_machine_check_pSeries: 42_machine_check_pSeries:
53 HMT_MEDIUM 43 HMT_MEDIUM
54 mtspr SPRN_SPRG1,r13 /* save r13 */ 44 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
55 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common) 45 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
56 46
57 . = 0x300 47 . = 0x300
58 .globl data_access_pSeries 48 .globl data_access_pSeries
59data_access_pSeries: 49data_access_pSeries:
60 HMT_MEDIUM 50 HMT_MEDIUM
61 mtspr SPRN_SPRG1,r13 51 mtspr SPRN_SPRG_SCRATCH0,r13
62BEGIN_FTR_SECTION 52BEGIN_FTR_SECTION
63 mtspr SPRN_SPRG2,r12 53 mfspr r13,SPRN_SPRG_PACA
64 mfspr r13,SPRN_DAR 54 std r9,PACA_EXSLB+EX_R9(r13)
65 mfspr r12,SPRN_DSISR 55 std r10,PACA_EXSLB+EX_R10(r13)
66 srdi r13,r13,60 56 mfspr r10,SPRN_DAR
67 rlwimi r13,r12,16,0x20 57 mfspr r9,SPRN_DSISR
68 mfcr r12 58 srdi r10,r10,60
69 cmpwi r13,0x2c 59 rlwimi r10,r9,16,0x20
60 mfcr r9
61 cmpwi r10,0x2c
70 beq do_stab_bolted_pSeries 62 beq do_stab_bolted_pSeries
71 mtcrf 0x80,r12 63 ld r10,PACA_EXSLB+EX_R10(r13)
72 mfspr r12,SPRN_SPRG2 64 std r11,PACA_EXGEN+EX_R11(r13)
73END_FTR_SECTION_IFCLR(CPU_FTR_SLB) 65 ld r11,PACA_EXSLB+EX_R9(r13)
66 std r12,PACA_EXGEN+EX_R12(r13)
67 mfspr r12,SPRN_SPRG_SCRATCH0
68 std r10,PACA_EXGEN+EX_R10(r13)
69 std r11,PACA_EXGEN+EX_R9(r13)
70 std r12,PACA_EXGEN+EX_R13(r13)
71 EXCEPTION_PROLOG_PSERIES_1(data_access_common)
72FTR_SECTION_ELSE
74 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common) 73 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common)
74ALT_FTR_SECTION_END_IFCLR(CPU_FTR_SLB)
75 75
76 . = 0x380 76 . = 0x380
77 .globl data_access_slb_pSeries 77 .globl data_access_slb_pSeries
78data_access_slb_pSeries: 78data_access_slb_pSeries:
79 HMT_MEDIUM 79 HMT_MEDIUM
80 mtspr SPRN_SPRG1,r13 80 mtspr SPRN_SPRG_SCRATCH0,r13
81 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ 81 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
82 std r3,PACA_EXSLB+EX_R3(r13) 82 std r3,PACA_EXSLB+EX_R3(r13)
83 mfspr r3,SPRN_DAR 83 mfspr r3,SPRN_DAR
84 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ 84 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
@@ -91,7 +91,7 @@ data_access_slb_pSeries:
91 std r10,PACA_EXSLB+EX_R10(r13) 91 std r10,PACA_EXSLB+EX_R10(r13)
92 std r11,PACA_EXSLB+EX_R11(r13) 92 std r11,PACA_EXSLB+EX_R11(r13)
93 std r12,PACA_EXSLB+EX_R12(r13) 93 std r12,PACA_EXSLB+EX_R12(r13)
94 mfspr r10,SPRN_SPRG1 94 mfspr r10,SPRN_SPRG_SCRATCH0
95 std r10,PACA_EXSLB+EX_R13(r13) 95 std r10,PACA_EXSLB+EX_R13(r13)
96 mfspr r12,SPRN_SRR1 /* and SRR1 */ 96 mfspr r12,SPRN_SRR1 /* and SRR1 */
97#ifndef CONFIG_RELOCATABLE 97#ifndef CONFIG_RELOCATABLE
@@ -115,8 +115,8 @@ data_access_slb_pSeries:
115 .globl instruction_access_slb_pSeries 115 .globl instruction_access_slb_pSeries
116instruction_access_slb_pSeries: 116instruction_access_slb_pSeries:
117 HMT_MEDIUM 117 HMT_MEDIUM
118 mtspr SPRN_SPRG1,r13 118 mtspr SPRN_SPRG_SCRATCH0,r13
119 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ 119 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
120 std r3,PACA_EXSLB+EX_R3(r13) 120 std r3,PACA_EXSLB+EX_R3(r13)
121 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ 121 mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
122 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ 122 std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
@@ -129,7 +129,7 @@ instruction_access_slb_pSeries:
129 std r10,PACA_EXSLB+EX_R10(r13) 129 std r10,PACA_EXSLB+EX_R10(r13)
130 std r11,PACA_EXSLB+EX_R11(r13) 130 std r11,PACA_EXSLB+EX_R11(r13)
131 std r12,PACA_EXSLB+EX_R12(r13) 131 std r12,PACA_EXSLB+EX_R12(r13)
132 mfspr r10,SPRN_SPRG1 132 mfspr r10,SPRN_SPRG_SCRATCH0
133 std r10,PACA_EXSLB+EX_R13(r13) 133 std r10,PACA_EXSLB+EX_R13(r13)
134 mfspr r12,SPRN_SRR1 /* and SRR1 */ 134 mfspr r12,SPRN_SRR1 /* and SRR1 */
135#ifndef CONFIG_RELOCATABLE 135#ifndef CONFIG_RELOCATABLE
@@ -159,7 +159,7 @@ BEGIN_FTR_SECTION
159 beq- 1f 159 beq- 1f
160END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) 160END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
161 mr r9,r13 161 mr r9,r13
162 mfspr r13,SPRN_SPRG3 162 mfspr r13,SPRN_SPRG_PACA
163 mfspr r11,SPRN_SRR0 163 mfspr r11,SPRN_SRR0
164 ld r12,PACAKBASE(r13) 164 ld r12,PACAKBASE(r13)
165 ld r10,PACAKMSR(r13) 165 ld r10,PACAKMSR(r13)
@@ -228,15 +228,17 @@ masked_interrupt:
228 rotldi r10,r10,16 228 rotldi r10,r10,16
229 mtspr SPRN_SRR1,r10 229 mtspr SPRN_SRR1,r10
230 ld r10,PACA_EXGEN+EX_R10(r13) 230 ld r10,PACA_EXGEN+EX_R10(r13)
231 mfspr r13,SPRN_SPRG1 231 mfspr r13,SPRN_SPRG_SCRATCH0
232 rfid 232 rfid
233 b . 233 b .
234 234
235 .align 7 235 .align 7
236do_stab_bolted_pSeries: 236do_stab_bolted_pSeries:
237 mtcrf 0x80,r12 237 std r11,PACA_EXSLB+EX_R11(r13)
238 mfspr r12,SPRN_SPRG2 238 std r12,PACA_EXSLB+EX_R12(r13)
239 EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted) 239 mfspr r10,SPRN_SPRG_SCRATCH0
240 std r10,PACA_EXSLB+EX_R13(r13)
241 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted)
240 242
241#ifdef CONFIG_PPC_PSERIES 243#ifdef CONFIG_PPC_PSERIES
242/* 244/*
@@ -246,14 +248,14 @@ do_stab_bolted_pSeries:
246 .align 7 248 .align 7
247system_reset_fwnmi: 249system_reset_fwnmi:
248 HMT_MEDIUM 250 HMT_MEDIUM
249 mtspr SPRN_SPRG1,r13 /* save r13 */ 251 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
250 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common) 252 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common)
251 253
252 .globl machine_check_fwnmi 254 .globl machine_check_fwnmi
253 .align 7 255 .align 7
254machine_check_fwnmi: 256machine_check_fwnmi:
255 HMT_MEDIUM 257 HMT_MEDIUM
256 mtspr SPRN_SPRG1,r13 /* save r13 */ 258 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
257 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common) 259 EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
258 260
259#endif /* CONFIG_PPC_PSERIES */ 261#endif /* CONFIG_PPC_PSERIES */
@@ -268,7 +270,7 @@ slb_miss_user_pseries:
268 std r10,PACA_EXGEN+EX_R10(r13) 270 std r10,PACA_EXGEN+EX_R10(r13)
269 std r11,PACA_EXGEN+EX_R11(r13) 271 std r11,PACA_EXGEN+EX_R11(r13)
270 std r12,PACA_EXGEN+EX_R12(r13) 272 std r12,PACA_EXGEN+EX_R12(r13)
271 mfspr r10,SPRG1 273 mfspr r10,SPRG_SCRATCH0
272 ld r11,PACA_EXSLB+EX_R9(r13) 274 ld r11,PACA_EXSLB+EX_R9(r13)
273 ld r12,PACA_EXSLB+EX_R3(r13) 275 ld r12,PACA_EXSLB+EX_R3(r13)
274 std r10,PACA_EXGEN+EX_R13(r13) 276 std r10,PACA_EXGEN+EX_R13(r13)
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index 2436df33c6f4..fc8f5b14019c 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -91,7 +91,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
91#endif /* CONFIG_SMP */ 91#endif /* CONFIG_SMP */
92 /* enable use of FP after return */ 92 /* enable use of FP after return */
93#ifdef CONFIG_PPC32 93#ifdef CONFIG_PPC32
94 mfspr r5,SPRN_SPRG3 /* current task's THREAD (phys) */ 94 mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */
95 lwz r4,THREAD_FPEXC_MODE(r5) 95 lwz r4,THREAD_FPEXC_MODE(r5)
96 ori r9,r9,MSR_FP /* enable FP for current */ 96 ori r9,r9,MSR_FP /* enable FP for current */
97 or r9,r9,r4 97 or r9,r9,r4
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index fc2132942754..829c3fe7c5a2 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -244,8 +244,8 @@ __secondary_hold_acknowledge:
244 * task's thread_struct. 244 * task's thread_struct.
245 */ 245 */
246#define EXCEPTION_PROLOG \ 246#define EXCEPTION_PROLOG \
247 mtspr SPRN_SPRG0,r10; \ 247 mtspr SPRN_SPRG_SCRATCH0,r10; \
248 mtspr SPRN_SPRG1,r11; \ 248 mtspr SPRN_SPRG_SCRATCH1,r11; \
249 mfcr r10; \ 249 mfcr r10; \
250 EXCEPTION_PROLOG_1; \ 250 EXCEPTION_PROLOG_1; \
251 EXCEPTION_PROLOG_2 251 EXCEPTION_PROLOG_2
@@ -255,7 +255,7 @@ __secondary_hold_acknowledge:
255 andi. r11,r11,MSR_PR; \ 255 andi. r11,r11,MSR_PR; \
256 tophys(r11,r1); /* use tophys(r1) if kernel */ \ 256 tophys(r11,r1); /* use tophys(r1) if kernel */ \
257 beq 1f; \ 257 beq 1f; \
258 mfspr r11,SPRN_SPRG3; \ 258 mfspr r11,SPRN_SPRG_THREAD; \
259 lwz r11,THREAD_INFO-THREAD(r11); \ 259 lwz r11,THREAD_INFO-THREAD(r11); \
260 addi r11,r11,THREAD_SIZE; \ 260 addi r11,r11,THREAD_SIZE; \
261 tophys(r11,r11); \ 261 tophys(r11,r11); \
@@ -267,9 +267,9 @@ __secondary_hold_acknowledge:
267 stw r10,_CCR(r11); /* save registers */ \ 267 stw r10,_CCR(r11); /* save registers */ \
268 stw r12,GPR12(r11); \ 268 stw r12,GPR12(r11); \
269 stw r9,GPR9(r11); \ 269 stw r9,GPR9(r11); \
270 mfspr r10,SPRN_SPRG0; \ 270 mfspr r10,SPRN_SPRG_SCRATCH0; \
271 stw r10,GPR10(r11); \ 271 stw r10,GPR10(r11); \
272 mfspr r12,SPRN_SPRG1; \ 272 mfspr r12,SPRN_SPRG_SCRATCH1; \
273 stw r12,GPR11(r11); \ 273 stw r12,GPR11(r11); \
274 mflr r10; \ 274 mflr r10; \
275 stw r10,_LINK(r11); \ 275 stw r10,_LINK(r11); \
@@ -355,11 +355,11 @@ i##n: \
355 * -- paulus. 355 * -- paulus.
356 */ 356 */
357 . = 0x200 357 . = 0x200
358 mtspr SPRN_SPRG0,r10 358 mtspr SPRN_SPRG_SCRATCH0,r10
359 mtspr SPRN_SPRG1,r11 359 mtspr SPRN_SPRG_SCRATCH1,r11
360 mfcr r10 360 mfcr r10
361#ifdef CONFIG_PPC_CHRP 361#ifdef CONFIG_PPC_CHRP
362 mfspr r11,SPRN_SPRG2 362 mfspr r11,SPRN_SPRG_RTAS
363 cmpwi 0,r11,0 363 cmpwi 0,r11,0
364 bne 7f 364 bne 7f
365#endif /* CONFIG_PPC_CHRP */ 365#endif /* CONFIG_PPC_CHRP */
@@ -367,7 +367,7 @@ i##n: \
3677: EXCEPTION_PROLOG_2 3677: EXCEPTION_PROLOG_2
368 addi r3,r1,STACK_FRAME_OVERHEAD 368 addi r3,r1,STACK_FRAME_OVERHEAD
369#ifdef CONFIG_PPC_CHRP 369#ifdef CONFIG_PPC_CHRP
370 mfspr r4,SPRN_SPRG2 370 mfspr r4,SPRN_SPRG_RTAS
371 cmpwi cr1,r4,0 371 cmpwi cr1,r4,0
372 bne cr1,1f 372 bne cr1,1f
373#endif 373#endif
@@ -485,7 +485,7 @@ InstructionTLBMiss:
485 mfspr r3,SPRN_IMISS 485 mfspr r3,SPRN_IMISS
486 lis r1,PAGE_OFFSET@h /* check if kernel address */ 486 lis r1,PAGE_OFFSET@h /* check if kernel address */
487 cmplw 0,r1,r3 487 cmplw 0,r1,r3
488 mfspr r2,SPRN_SPRG3 488 mfspr r2,SPRN_SPRG_THREAD
489 li r1,_PAGE_USER|_PAGE_PRESENT /* low addresses tested as user */ 489 li r1,_PAGE_USER|_PAGE_PRESENT /* low addresses tested as user */
490 lwz r2,PGDIR(r2) 490 lwz r2,PGDIR(r2)
491 bge- 112f 491 bge- 112f
@@ -559,7 +559,7 @@ DataLoadTLBMiss:
559 mfspr r3,SPRN_DMISS 559 mfspr r3,SPRN_DMISS
560 lis r1,PAGE_OFFSET@h /* check if kernel address */ 560 lis r1,PAGE_OFFSET@h /* check if kernel address */
561 cmplw 0,r1,r3 561 cmplw 0,r1,r3
562 mfspr r2,SPRN_SPRG3 562 mfspr r2,SPRN_SPRG_THREAD
563 li r1,_PAGE_USER|_PAGE_PRESENT /* low addresses tested as user */ 563 li r1,_PAGE_USER|_PAGE_PRESENT /* low addresses tested as user */
564 lwz r2,PGDIR(r2) 564 lwz r2,PGDIR(r2)
565 bge- 112f 565 bge- 112f
@@ -598,12 +598,12 @@ END_FTR_SECTION_IFCLR(CPU_FTR_NEED_COHERENT)
598 mtcrf 0x80,r2 598 mtcrf 0x80,r2
599BEGIN_MMU_FTR_SECTION 599BEGIN_MMU_FTR_SECTION
600 li r0,1 600 li r0,1
601 mfspr r1,SPRN_SPRG4 601 mfspr r1,SPRN_SPRG_603_LRU
602 rlwinm r2,r3,20,27,31 /* Get Address bits 15:19 */ 602 rlwinm r2,r3,20,27,31 /* Get Address bits 15:19 */
603 slw r0,r0,r2 603 slw r0,r0,r2
604 xor r1,r0,r1 604 xor r1,r0,r1
605 srw r0,r1,r2 605 srw r0,r1,r2
606 mtspr SPRN_SPRG4,r1 606 mtspr SPRN_SPRG_603_LRU,r1
607 mfspr r2,SPRN_SRR1 607 mfspr r2,SPRN_SRR1
608 rlwimi r2,r0,31-14,14,14 608 rlwimi r2,r0,31-14,14,14
609 mtspr SPRN_SRR1,r2 609 mtspr SPRN_SRR1,r2
@@ -643,7 +643,7 @@ DataStoreTLBMiss:
643 mfspr r3,SPRN_DMISS 643 mfspr r3,SPRN_DMISS
644 lis r1,PAGE_OFFSET@h /* check if kernel address */ 644 lis r1,PAGE_OFFSET@h /* check if kernel address */
645 cmplw 0,r1,r3 645 cmplw 0,r1,r3
646 mfspr r2,SPRN_SPRG3 646 mfspr r2,SPRN_SPRG_THREAD
647 li r1,_PAGE_RW|_PAGE_USER|_PAGE_PRESENT /* access flags */ 647 li r1,_PAGE_RW|_PAGE_USER|_PAGE_PRESENT /* access flags */
648 lwz r2,PGDIR(r2) 648 lwz r2,PGDIR(r2)
649 bge- 112f 649 bge- 112f
@@ -678,12 +678,12 @@ END_FTR_SECTION_IFCLR(CPU_FTR_NEED_COHERENT)
678 mtcrf 0x80,r2 678 mtcrf 0x80,r2
679BEGIN_MMU_FTR_SECTION 679BEGIN_MMU_FTR_SECTION
680 li r0,1 680 li r0,1
681 mfspr r1,SPRN_SPRG4 681 mfspr r1,SPRN_SPRG_603_LRU
682 rlwinm r2,r3,20,27,31 /* Get Address bits 15:19 */ 682 rlwinm r2,r3,20,27,31 /* Get Address bits 15:19 */
683 slw r0,r0,r2 683 slw r0,r0,r2
684 xor r1,r0,r1 684 xor r1,r0,r1
685 srw r0,r1,r2 685 srw r0,r1,r2
686 mtspr SPRN_SPRG4,r1 686 mtspr SPRN_SPRG_603_LRU,r1
687 mfspr r2,SPRN_SRR1 687 mfspr r2,SPRN_SRR1
688 rlwimi r2,r0,31-14,14,14 688 rlwimi r2,r0,31-14,14,14
689 mtspr SPRN_SRR1,r2 689 mtspr SPRN_SRR1,r2
@@ -864,9 +864,9 @@ __secondary_start:
864 tophys(r4,r2) 864 tophys(r4,r2)
865 addi r4,r4,THREAD /* phys address of our thread_struct */ 865 addi r4,r4,THREAD /* phys address of our thread_struct */
866 CLR_TOP32(r4) 866 CLR_TOP32(r4)
867 mtspr SPRN_SPRG3,r4 867 mtspr SPRN_SPRG_THREAD,r4
868 li r3,0 868 li r3,0
869 mtspr SPRN_SPRG2,r3 /* 0 => not in RTAS */ 869 mtspr SPRN_SPRG_RTAS,r3 /* 0 => not in RTAS */
870 870
871 /* enable MMU and jump to start_secondary */ 871 /* enable MMU and jump to start_secondary */
872 li r4,MSR_KERNEL 872 li r4,MSR_KERNEL
@@ -947,9 +947,9 @@ start_here:
947 tophys(r4,r2) 947 tophys(r4,r2)
948 addi r4,r4,THREAD /* init task's THREAD */ 948 addi r4,r4,THREAD /* init task's THREAD */
949 CLR_TOP32(r4) 949 CLR_TOP32(r4)
950 mtspr SPRN_SPRG3,r4 950 mtspr SPRN_SPRG_THREAD,r4
951 li r3,0 951 li r3,0
952 mtspr SPRN_SPRG2,r3 /* 0 => not in RTAS */ 952 mtspr SPRN_SPRG_RTAS,r3 /* 0 => not in RTAS */
953 953
954 /* stack */ 954 /* stack */
955 lis r1,init_thread_union@ha 955 lis r1,init_thread_union@ha
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index 0c96911d4299..a90625f9b485 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -103,21 +103,21 @@ _ENTRY(saved_ksp_limit)
103 103
104/* 104/*
105 * Exception vector entry code. This code runs with address translation 105 * Exception vector entry code. This code runs with address translation
106 * turned off (i.e. using physical addresses). We assume SPRG3 has the 106 * turned off (i.e. using physical addresses). We assume SPRG_THREAD has
107 * physical address of the current task thread_struct. 107 * the physical address of the current task thread_struct.
108 * Note that we have to have decremented r1 before we write to any fields 108 * Note that we have to have decremented r1 before we write to any fields
109 * of the exception frame, since a critical interrupt could occur at any 109 * of the exception frame, since a critical interrupt could occur at any
110 * time, and it will write to the area immediately below the current r1. 110 * time, and it will write to the area immediately below the current r1.
111 */ 111 */
112#define NORMAL_EXCEPTION_PROLOG \ 112#define NORMAL_EXCEPTION_PROLOG \
113 mtspr SPRN_SPRG0,r10; /* save two registers to work with */\ 113 mtspr SPRN_SPRG_SCRATCH0,r10; /* save two registers to work with */\
114 mtspr SPRN_SPRG1,r11; \ 114 mtspr SPRN_SPRG_SCRATCH1,r11; \
115 mtspr SPRN_SPRG2,r1; \ 115 mtspr SPRN_SPRG_SCRATCH2,r1; \
116 mfcr r10; /* save CR in r10 for now */\ 116 mfcr r10; /* save CR in r10 for now */\
117 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ 117 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
118 andi. r11,r11,MSR_PR; \ 118 andi. r11,r11,MSR_PR; \
119 beq 1f; \ 119 beq 1f; \
120 mfspr r1,SPRN_SPRG3; /* if from user, start at top of */\ 120 mfspr r1,SPRN_SPRG_THREAD; /* if from user, start at top of */\
121 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ 121 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\
122 addi r1,r1,THREAD_SIZE; \ 122 addi r1,r1,THREAD_SIZE; \
1231: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\ 1231: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\
@@ -125,13 +125,13 @@ _ENTRY(saved_ksp_limit)
125 stw r10,_CCR(r11); /* save various registers */\ 125 stw r10,_CCR(r11); /* save various registers */\
126 stw r12,GPR12(r11); \ 126 stw r12,GPR12(r11); \
127 stw r9,GPR9(r11); \ 127 stw r9,GPR9(r11); \
128 mfspr r10,SPRN_SPRG0; \ 128 mfspr r10,SPRN_SPRG_SCRATCH0; \
129 stw r10,GPR10(r11); \ 129 stw r10,GPR10(r11); \
130 mfspr r12,SPRN_SPRG1; \ 130 mfspr r12,SPRN_SPRG_SCRATCH1; \
131 stw r12,GPR11(r11); \ 131 stw r12,GPR11(r11); \
132 mflr r10; \ 132 mflr r10; \
133 stw r10,_LINK(r11); \ 133 stw r10,_LINK(r11); \
134 mfspr r10,SPRN_SPRG2; \ 134 mfspr r10,SPRN_SPRG_SCRATCH2; \
135 mfspr r12,SPRN_SRR0; \ 135 mfspr r12,SPRN_SRR0; \
136 stw r10,GPR1(r11); \ 136 stw r10,GPR1(r11); \
137 mfspr r9,SPRN_SRR1; \ 137 mfspr r9,SPRN_SRR1; \
@@ -160,7 +160,7 @@ _ENTRY(saved_ksp_limit)
160 lwz r11,critirq_ctx@l(r11); \ 160 lwz r11,critirq_ctx@l(r11); \
161 beq 1f; \ 161 beq 1f; \
162 /* COMING FROM USER MODE */ \ 162 /* COMING FROM USER MODE */ \
163 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\ 163 mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\
164 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\ 164 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
1651: addi r11,r11,THREAD_SIZE-INT_FRAME_SIZE; /* Alloc an excpt frm */\ 1651: addi r11,r11,THREAD_SIZE-INT_FRAME_SIZE; /* Alloc an excpt frm */\
166 tophys(r11,r11); \ 166 tophys(r11,r11); \
@@ -265,8 +265,8 @@ label:
265 * and exit. Otherwise, we call heavywight functions to do the work. 265 * and exit. Otherwise, we call heavywight functions to do the work.
266 */ 266 */
267 START_EXCEPTION(0x0300, DataStorage) 267 START_EXCEPTION(0x0300, DataStorage)
268 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 268 mtspr SPRN_SPRG_SCRATCH0, r10 /* Save some working registers */
269 mtspr SPRN_SPRG1, r11 269 mtspr SPRN_SPRG_SCRATCH1, r11
270#ifdef CONFIG_403GCX 270#ifdef CONFIG_403GCX
271 stw r12, 0(r0) 271 stw r12, 0(r0)
272 stw r9, 4(r0) 272 stw r9, 4(r0)
@@ -275,12 +275,12 @@ label:
275 stw r11, 8(r0) 275 stw r11, 8(r0)
276 stw r12, 12(r0) 276 stw r12, 12(r0)
277#else 277#else
278 mtspr SPRN_SPRG4, r12 278 mtspr SPRN_SPRG_SCRATCH3, r12
279 mtspr SPRN_SPRG5, r9 279 mtspr SPRN_SPRG_SCRATCH4, r9
280 mfcr r11 280 mfcr r11
281 mfspr r12, SPRN_PID 281 mfspr r12, SPRN_PID
282 mtspr SPRN_SPRG7, r11 282 mtspr SPRN_SPRG_SCRATCH6, r11
283 mtspr SPRN_SPRG6, r12 283 mtspr SPRN_SPRG_SCRATCH5, r12
284#endif 284#endif
285 285
286 /* First, check if it was a zone fault (which means a user 286 /* First, check if it was a zone fault (which means a user
@@ -308,7 +308,7 @@ label:
308 /* Get the PGD for the current thread. 308 /* Get the PGD for the current thread.
309 */ 309 */
3103: 3103:
311 mfspr r11,SPRN_SPRG3 311 mfspr r11,SPRN_SPRG_THREAD
312 lwz r11,PGDIR(r11) 312 lwz r11,PGDIR(r11)
3134: 3134:
314 tophys(r11, r11) 314 tophys(r11, r11)
@@ -355,15 +355,15 @@ label:
355 lwz r9, 4(r0) 355 lwz r9, 4(r0)
356 lwz r12, 0(r0) 356 lwz r12, 0(r0)
357#else 357#else
358 mfspr r12, SPRN_SPRG6 358 mfspr r12, SPRN_SPRG_SCRATCH5
359 mfspr r11, SPRN_SPRG7 359 mfspr r11, SPRN_SPRG_SCRATCH6
360 mtspr SPRN_PID, r12 360 mtspr SPRN_PID, r12
361 mtcr r11 361 mtcr r11
362 mfspr r9, SPRN_SPRG5 362 mfspr r9, SPRN_SPRG_SCRATCH4
363 mfspr r12, SPRN_SPRG4 363 mfspr r12, SPRN_SPRG_SCRATCH3
364#endif 364#endif
365 mfspr r11, SPRN_SPRG1 365 mfspr r11, SPRN_SPRG_SCRATCH1
366 mfspr r10, SPRN_SPRG0 366 mfspr r10, SPRN_SPRG_SCRATCH0
367 PPC405_ERR77_SYNC 367 PPC405_ERR77_SYNC
368 rfi /* Should sync shadow TLBs */ 368 rfi /* Should sync shadow TLBs */
369 b . /* prevent prefetch past rfi */ 369 b . /* prevent prefetch past rfi */
@@ -380,15 +380,15 @@ label:
380 lwz r9, 4(r0) 380 lwz r9, 4(r0)
381 lwz r12, 0(r0) 381 lwz r12, 0(r0)
382#else 382#else
383 mfspr r12, SPRN_SPRG6 383 mfspr r12, SPRN_SPRG_SCRATCH5
384 mfspr r11, SPRN_SPRG7 384 mfspr r11, SPRN_SPRG_SCRATCH6
385 mtspr SPRN_PID, r12 385 mtspr SPRN_PID, r12
386 mtcr r11 386 mtcr r11
387 mfspr r9, SPRN_SPRG5 387 mfspr r9, SPRN_SPRG_SCRATCH4
388 mfspr r12, SPRN_SPRG4 388 mfspr r12, SPRN_SPRG_SCRATCH3
389#endif 389#endif
390 mfspr r11, SPRN_SPRG1 390 mfspr r11, SPRN_SPRG_SCRATCH1
391 mfspr r10, SPRN_SPRG0 391 mfspr r10, SPRN_SPRG_SCRATCH0
392 b DataAccess 392 b DataAccess
393 393
394/* 394/*
@@ -466,8 +466,8 @@ label:
466 * load TLB entries from the page table if they exist. 466 * load TLB entries from the page table if they exist.
467 */ 467 */
468 START_EXCEPTION(0x1100, DTLBMiss) 468 START_EXCEPTION(0x1100, DTLBMiss)
469 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 469 mtspr SPRN_SPRG_SCRATCH0, r10 /* Save some working registers */
470 mtspr SPRN_SPRG1, r11 470 mtspr SPRN_SPRG_SCRATCH1, r11
471#ifdef CONFIG_403GCX 471#ifdef CONFIG_403GCX
472 stw r12, 0(r0) 472 stw r12, 0(r0)
473 stw r9, 4(r0) 473 stw r9, 4(r0)
@@ -476,12 +476,12 @@ label:
476 stw r11, 8(r0) 476 stw r11, 8(r0)
477 stw r12, 12(r0) 477 stw r12, 12(r0)
478#else 478#else
479 mtspr SPRN_SPRG4, r12 479 mtspr SPRN_SPRG_SCRATCH3, r12
480 mtspr SPRN_SPRG5, r9 480 mtspr SPRN_SPRG_SCRATCH4, r9
481 mfcr r11 481 mfcr r11
482 mfspr r12, SPRN_PID 482 mfspr r12, SPRN_PID
483 mtspr SPRN_SPRG7, r11 483 mtspr SPRN_SPRG_SCRATCH6, r11
484 mtspr SPRN_SPRG6, r12 484 mtspr SPRN_SPRG_SCRATCH5, r12
485#endif 485#endif
486 mfspr r10, SPRN_DEAR /* Get faulting address */ 486 mfspr r10, SPRN_DEAR /* Get faulting address */
487 487
@@ -500,7 +500,7 @@ label:
500 /* Get the PGD for the current thread. 500 /* Get the PGD for the current thread.
501 */ 501 */
5023: 5023:
503 mfspr r11,SPRN_SPRG3 503 mfspr r11,SPRN_SPRG_THREAD
504 lwz r11,PGDIR(r11) 504 lwz r11,PGDIR(r11)
5054: 5054:
506 tophys(r11, r11) 506 tophys(r11, r11)
@@ -550,15 +550,15 @@ label:
550 lwz r9, 4(r0) 550 lwz r9, 4(r0)
551 lwz r12, 0(r0) 551 lwz r12, 0(r0)
552#else 552#else
553 mfspr r12, SPRN_SPRG6 553 mfspr r12, SPRN_SPRG_SCRATCH5
554 mfspr r11, SPRN_SPRG7 554 mfspr r11, SPRN_SPRG_SCRATCH6
555 mtspr SPRN_PID, r12 555 mtspr SPRN_PID, r12
556 mtcr r11 556 mtcr r11
557 mfspr r9, SPRN_SPRG5 557 mfspr r9, SPRN_SPRG_SCRATCH4
558 mfspr r12, SPRN_SPRG4 558 mfspr r12, SPRN_SPRG_SCRATCH3
559#endif 559#endif
560 mfspr r11, SPRN_SPRG1 560 mfspr r11, SPRN_SPRG_SCRATCH1
561 mfspr r10, SPRN_SPRG0 561 mfspr r10, SPRN_SPRG_SCRATCH0
562 b DataAccess 562 b DataAccess
563 563
564/* 0x1200 - Instruction TLB Miss Exception 564/* 0x1200 - Instruction TLB Miss Exception
@@ -566,8 +566,8 @@ label:
566 * registers and bailout to a different point. 566 * registers and bailout to a different point.
567 */ 567 */
568 START_EXCEPTION(0x1200, ITLBMiss) 568 START_EXCEPTION(0x1200, ITLBMiss)
569 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 569 mtspr SPRN_SPRG_SCRATCH0, r10 /* Save some working registers */
570 mtspr SPRN_SPRG1, r11 570 mtspr SPRN_SPRG_SCRATCH1, r11
571#ifdef CONFIG_403GCX 571#ifdef CONFIG_403GCX
572 stw r12, 0(r0) 572 stw r12, 0(r0)
573 stw r9, 4(r0) 573 stw r9, 4(r0)
@@ -576,12 +576,12 @@ label:
576 stw r11, 8(r0) 576 stw r11, 8(r0)
577 stw r12, 12(r0) 577 stw r12, 12(r0)
578#else 578#else
579 mtspr SPRN_SPRG4, r12 579 mtspr SPRN_SPRG_SCRATCH3, r12
580 mtspr SPRN_SPRG5, r9 580 mtspr SPRN_SPRG_SCRATCH4, r9
581 mfcr r11 581 mfcr r11
582 mfspr r12, SPRN_PID 582 mfspr r12, SPRN_PID
583 mtspr SPRN_SPRG7, r11 583 mtspr SPRN_SPRG_SCRATCH6, r11
584 mtspr SPRN_SPRG6, r12 584 mtspr SPRN_SPRG_SCRATCH5, r12
585#endif 585#endif
586 mfspr r10, SPRN_SRR0 /* Get faulting address */ 586 mfspr r10, SPRN_SRR0 /* Get faulting address */
587 587
@@ -600,7 +600,7 @@ label:
600 /* Get the PGD for the current thread. 600 /* Get the PGD for the current thread.
601 */ 601 */
6023: 6023:
603 mfspr r11,SPRN_SPRG3 603 mfspr r11,SPRN_SPRG_THREAD
604 lwz r11,PGDIR(r11) 604 lwz r11,PGDIR(r11)
6054: 6054:
606 tophys(r11, r11) 606 tophys(r11, r11)
@@ -650,15 +650,15 @@ label:
650 lwz r9, 4(r0) 650 lwz r9, 4(r0)
651 lwz r12, 0(r0) 651 lwz r12, 0(r0)
652#else 652#else
653 mfspr r12, SPRN_SPRG6 653 mfspr r12, SPRN_SPRG_SCRATCH5
654 mfspr r11, SPRN_SPRG7 654 mfspr r11, SPRN_SPRG_SCRATCH6
655 mtspr SPRN_PID, r12 655 mtspr SPRN_PID, r12
656 mtcr r11 656 mtcr r11
657 mfspr r9, SPRN_SPRG5 657 mfspr r9, SPRN_SPRG_SCRATCH4
658 mfspr r12, SPRN_SPRG4 658 mfspr r12, SPRN_SPRG_SCRATCH3
659#endif 659#endif
660 mfspr r11, SPRN_SPRG1 660 mfspr r11, SPRN_SPRG_SCRATCH1
661 mfspr r10, SPRN_SPRG0 661 mfspr r10, SPRN_SPRG_SCRATCH0
662 b InstructionAccess 662 b InstructionAccess
663 663
664 EXCEPTION(0x1300, Trap_13, unknown_exception, EXC_XFER_EE) 664 EXCEPTION(0x1300, Trap_13, unknown_exception, EXC_XFER_EE)
@@ -803,15 +803,15 @@ finish_tlb_load:
803 lwz r9, 4(r0) 803 lwz r9, 4(r0)
804 lwz r12, 0(r0) 804 lwz r12, 0(r0)
805#else 805#else
806 mfspr r12, SPRN_SPRG6 806 mfspr r12, SPRN_SPRG_SCRATCH5
807 mfspr r11, SPRN_SPRG7 807 mfspr r11, SPRN_SPRG_SCRATCH6
808 mtspr SPRN_PID, r12 808 mtspr SPRN_PID, r12
809 mtcr r11 809 mtcr r11
810 mfspr r9, SPRN_SPRG5 810 mfspr r9, SPRN_SPRG_SCRATCH4
811 mfspr r12, SPRN_SPRG4 811 mfspr r12, SPRN_SPRG_SCRATCH3
812#endif 812#endif
813 mfspr r11, SPRN_SPRG1 813 mfspr r11, SPRN_SPRG_SCRATCH1
814 mfspr r10, SPRN_SPRG0 814 mfspr r10, SPRN_SPRG_SCRATCH0
815 PPC405_ERR77_SYNC 815 PPC405_ERR77_SYNC
816 rfi /* Should sync shadow TLBs */ 816 rfi /* Should sync shadow TLBs */
817 b . /* prevent prefetch past rfi */ 817 b . /* prevent prefetch past rfi */
@@ -835,7 +835,7 @@ start_here:
835 /* ptr to phys current thread */ 835 /* ptr to phys current thread */
836 tophys(r4,r2) 836 tophys(r4,r2)
837 addi r4,r4,THREAD /* init task's THREAD */ 837 addi r4,r4,THREAD /* init task's THREAD */
838 mtspr SPRN_SPRG3,r4 838 mtspr SPRN_SPRG_THREAD,r4
839 839
840 /* stack */ 840 /* stack */
841 lis r1,init_thread_union@ha 841 lis r1,init_thread_union@ha
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 18d8a1677c4d..711368b993f2 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -239,7 +239,7 @@ skpinv: addi r4,r4,1 /* Increment */
239 239
240 /* ptr to current thread */ 240 /* ptr to current thread */
241 addi r4,r2,THREAD /* init task's THREAD */ 241 addi r4,r2,THREAD /* init task's THREAD */
242 mtspr SPRN_SPRG3,r4 242 mtspr SPRN_SPRG_THREAD,r4
243 243
244 /* stack */ 244 /* stack */
245 lis r1,init_thread_union@h 245 lis r1,init_thread_union@h
@@ -350,12 +350,12 @@ interrupt_base:
350 350
351 /* Data TLB Error Interrupt */ 351 /* Data TLB Error Interrupt */
352 START_EXCEPTION(DataTLBError) 352 START_EXCEPTION(DataTLBError)
353 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 353 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
354 mtspr SPRN_SPRG1, r11 354 mtspr SPRN_SPRG_WSCRATCH1, r11
355 mtspr SPRN_SPRG4W, r12 355 mtspr SPRN_SPRG_WSCRATCH2, r12
356 mtspr SPRN_SPRG5W, r13 356 mtspr SPRN_SPRG_WSCRATCH3, r13
357 mfcr r11 357 mfcr r11
358 mtspr SPRN_SPRG7W, r11 358 mtspr SPRN_SPRG_WSCRATCH4, r11
359 mfspr r10, SPRN_DEAR /* Get faulting address */ 359 mfspr r10, SPRN_DEAR /* Get faulting address */
360 360
361 /* If we are faulting a kernel address, we have to use the 361 /* If we are faulting a kernel address, we have to use the
@@ -374,7 +374,7 @@ interrupt_base:
374 374
375 /* Get the PGD for the current thread */ 375 /* Get the PGD for the current thread */
3763: 3763:
377 mfspr r11,SPRN_SPRG3 377 mfspr r11,SPRN_SPRG_THREAD
378 lwz r11,PGDIR(r11) 378 lwz r11,PGDIR(r11)
379 379
380 /* Load PID into MMUCR TID */ 380 /* Load PID into MMUCR TID */
@@ -446,12 +446,12 @@ tlb_44x_patch_hwater_D:
446 /* The bailout. Restore registers to pre-exception conditions 446 /* The bailout. Restore registers to pre-exception conditions
447 * and call the heavyweights to help us out. 447 * and call the heavyweights to help us out.
448 */ 448 */
449 mfspr r11, SPRN_SPRG7R 449 mfspr r11, SPRN_SPRG_RSCRATCH4
450 mtcr r11 450 mtcr r11
451 mfspr r13, SPRN_SPRG5R 451 mfspr r13, SPRN_SPRG_RSCRATCH3
452 mfspr r12, SPRN_SPRG4R 452 mfspr r12, SPRN_SPRG_RSCRATCH2
453 mfspr r11, SPRN_SPRG1 453 mfspr r11, SPRN_SPRG_RSCRATCH1
454 mfspr r10, SPRN_SPRG0 454 mfspr r10, SPRN_SPRG_RSCRATCH0
455 b DataStorage 455 b DataStorage
456 456
457 /* Instruction TLB Error Interrupt */ 457 /* Instruction TLB Error Interrupt */
@@ -461,12 +461,12 @@ tlb_44x_patch_hwater_D:
461 * to a different point. 461 * to a different point.
462 */ 462 */
463 START_EXCEPTION(InstructionTLBError) 463 START_EXCEPTION(InstructionTLBError)
464 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 464 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
465 mtspr SPRN_SPRG1, r11 465 mtspr SPRN_SPRG_WSCRATCH1, r11
466 mtspr SPRN_SPRG4W, r12 466 mtspr SPRN_SPRG_WSCRATCH2, r12
467 mtspr SPRN_SPRG5W, r13 467 mtspr SPRN_SPRG_WSCRATCH3, r13
468 mfcr r11 468 mfcr r11
469 mtspr SPRN_SPRG7W, r11 469 mtspr SPRN_SPRG_WSCRATCH4, r11
470 mfspr r10, SPRN_SRR0 /* Get faulting address */ 470 mfspr r10, SPRN_SRR0 /* Get faulting address */
471 471
472 /* If we are faulting a kernel address, we have to use the 472 /* If we are faulting a kernel address, we have to use the
@@ -485,7 +485,7 @@ tlb_44x_patch_hwater_D:
485 485
486 /* Get the PGD for the current thread */ 486 /* Get the PGD for the current thread */
4873: 4873:
488 mfspr r11,SPRN_SPRG3 488 mfspr r11,SPRN_SPRG_THREAD
489 lwz r11,PGDIR(r11) 489 lwz r11,PGDIR(r11)
490 490
491 /* Load PID into MMUCR TID */ 491 /* Load PID into MMUCR TID */
@@ -497,7 +497,7 @@ tlb_44x_patch_hwater_D:
497 mtspr SPRN_MMUCR,r12 497 mtspr SPRN_MMUCR,r12
498 498
499 /* Make up the required permissions */ 499 /* Make up the required permissions */
500 li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_HWEXEC 500 li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
501 501
502 /* Compute pgdir/pmd offset */ 502 /* Compute pgdir/pmd offset */
503 rlwinm r12, r10, PPC44x_PGD_OFF_SHIFT, PPC44x_PGD_OFF_MASK_BIT, 29 503 rlwinm r12, r10, PPC44x_PGD_OFF_SHIFT, PPC44x_PGD_OFF_MASK_BIT, 29
@@ -542,12 +542,12 @@ tlb_44x_patch_hwater_I:
542 /* The bailout. Restore registers to pre-exception conditions 542 /* The bailout. Restore registers to pre-exception conditions
543 * and call the heavyweights to help us out. 543 * and call the heavyweights to help us out.
544 */ 544 */
545 mfspr r11, SPRN_SPRG7R 545 mfspr r11, SPRN_SPRG_RSCRATCH4
546 mtcr r11 546 mtcr r11
547 mfspr r13, SPRN_SPRG5R 547 mfspr r13, SPRN_SPRG_RSCRATCH3
548 mfspr r12, SPRN_SPRG4R 548 mfspr r12, SPRN_SPRG_RSCRATCH2
549 mfspr r11, SPRN_SPRG1 549 mfspr r11, SPRN_SPRG_RSCRATCH1
550 mfspr r10, SPRN_SPRG0 550 mfspr r10, SPRN_SPRG_RSCRATCH0
551 b InstructionStorage 551 b InstructionStorage
552 552
553 /* Debug Interrupt */ 553 /* Debug Interrupt */
@@ -593,12 +593,12 @@ finish_tlb_load:
593 593
594 /* Done...restore registers and get out of here. 594 /* Done...restore registers and get out of here.
595 */ 595 */
596 mfspr r11, SPRN_SPRG7R 596 mfspr r11, SPRN_SPRG_RSCRATCH4
597 mtcr r11 597 mtcr r11
598 mfspr r13, SPRN_SPRG5R 598 mfspr r13, SPRN_SPRG_RSCRATCH3
599 mfspr r12, SPRN_SPRG4R 599 mfspr r12, SPRN_SPRG_RSCRATCH2
600 mfspr r11, SPRN_SPRG1 600 mfspr r11, SPRN_SPRG_RSCRATCH1
601 mfspr r10, SPRN_SPRG0 601 mfspr r10, SPRN_SPRG_RSCRATCH0
602 rfi /* Force context change */ 602 rfi /* Force context change */
603 603
604/* 604/*
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 012505ebd9f9..c38afdb45d7b 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -36,7 +36,6 @@
36#include <asm/thread_info.h> 36#include <asm/thread_info.h>
37#include <asm/firmware.h> 37#include <asm/firmware.h>
38#include <asm/page_64.h> 38#include <asm/page_64.h>
39#include <asm/exception.h>
40#include <asm/irqflags.h> 39#include <asm/irqflags.h>
41 40
42/* The physical memory is layed out such that the secondary processor 41/* The physical memory is layed out such that the secondary processor
@@ -122,10 +121,11 @@ __run_at_load:
122 */ 121 */
123 .globl __secondary_hold 122 .globl __secondary_hold
124__secondary_hold: 123__secondary_hold:
124#ifndef CONFIG_PPC_BOOK3E
125 mfmsr r24 125 mfmsr r24
126 ori r24,r24,MSR_RI 126 ori r24,r24,MSR_RI
127 mtmsrd r24 /* RI on */ 127 mtmsrd r24 /* RI on */
128 128#endif
129 /* Grab our physical cpu number */ 129 /* Grab our physical cpu number */
130 mr r24,r3 130 mr r24,r3
131 131
@@ -144,6 +144,7 @@ __secondary_hold:
144 ld r4,0(r4) /* deref function descriptor */ 144 ld r4,0(r4) /* deref function descriptor */
145 mtctr r4 145 mtctr r4
146 mr r3,r24 146 mr r3,r24
147 li r4,0
147 bctr 148 bctr
148#else 149#else
149 BUG_OPCODE 150 BUG_OPCODE
@@ -164,21 +165,49 @@ exception_marker:
164#include "exceptions-64s.S" 165#include "exceptions-64s.S"
165#endif 166#endif
166 167
168_GLOBAL(generic_secondary_thread_init)
169 mr r24,r3
170
171 /* turn on 64-bit mode */
172 bl .enable_64b_mode
173
174 /* get a valid TOC pointer, wherever we're mapped at */
175 bl .relative_toc
176
177#ifdef CONFIG_PPC_BOOK3E
178 /* Book3E initialization */
179 mr r3,r24
180 bl .book3e_secondary_thread_init
181#endif
182 b generic_secondary_common_init
167 183
168/* 184/*
169 * On pSeries and most other platforms, secondary processors spin 185 * On pSeries and most other platforms, secondary processors spin
170 * in the following code. 186 * in the following code.
171 * At entry, r3 = this processor's number (physical cpu id) 187 * At entry, r3 = this processor's number (physical cpu id)
188 *
189 * On Book3E, r4 = 1 to indicate that the initial TLB entry for
190 * this core already exists (setup via some other mechanism such
191 * as SCOM before entry).
172 */ 192 */
173_GLOBAL(generic_secondary_smp_init) 193_GLOBAL(generic_secondary_smp_init)
174 mr r24,r3 194 mr r24,r3
175 195 mr r25,r4
196
176 /* turn on 64-bit mode */ 197 /* turn on 64-bit mode */
177 bl .enable_64b_mode 198 bl .enable_64b_mode
178 199
179 /* get the TOC pointer (real address) */ 200 /* get a valid TOC pointer, wherever we're mapped at */
180 bl .relative_toc 201 bl .relative_toc
181 202
203#ifdef CONFIG_PPC_BOOK3E
204 /* Book3E initialization */
205 mr r3,r24
206 mr r4,r25
207 bl .book3e_secondary_core_init
208#endif
209
210generic_secondary_common_init:
182 /* Set up a paca value for this processor. Since we have the 211 /* Set up a paca value for this processor. Since we have the
183 * physical cpu id in r24, we need to search the pacas to find 212 * physical cpu id in r24, we need to search the pacas to find
184 * which logical id maps to our physical one. 213 * which logical id maps to our physical one.
@@ -196,7 +225,12 @@ _GLOBAL(generic_secondary_smp_init)
196 mr r3,r24 /* not found, copy phys to r3 */ 225 mr r3,r24 /* not found, copy phys to r3 */
197 b .kexec_wait /* next kernel might do better */ 226 b .kexec_wait /* next kernel might do better */
198 227
1992: mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */ 2282: mtspr SPRN_SPRG_PACA,r13 /* Save vaddr of paca in an SPRG */
229#ifdef CONFIG_PPC_BOOK3E
230 addi r12,r13,PACA_EXTLB /* and TLB exc frame in another */
231 mtspr SPRN_SPRG_TLB_EXFRAME,r12
232#endif
233
200 /* From now on, r24 is expected to be logical cpuid */ 234 /* From now on, r24 is expected to be logical cpuid */
201 mr r24,r5 235 mr r24,r5
2023: HMT_LOW 2363: HMT_LOW
@@ -232,6 +266,7 @@ _GLOBAL(generic_secondary_smp_init)
232 * Turn the MMU off. 266 * Turn the MMU off.
233 * Assumes we're mapped EA == RA if the MMU is on. 267 * Assumes we're mapped EA == RA if the MMU is on.
234 */ 268 */
269#ifdef CONFIG_PPC_BOOK3S
235_STATIC(__mmu_off) 270_STATIC(__mmu_off)
236 mfmsr r3 271 mfmsr r3
237 andi. r0,r3,MSR_IR|MSR_DR 272 andi. r0,r3,MSR_IR|MSR_DR
@@ -243,6 +278,7 @@ _STATIC(__mmu_off)
243 sync 278 sync
244 rfid 279 rfid
245 b . /* prevent speculative execution */ 280 b . /* prevent speculative execution */
281#endif
246 282
247 283
248/* 284/*
@@ -280,6 +316,10 @@ _GLOBAL(__start_initialization_multiplatform)
280 mr r31,r3 316 mr r31,r3
281 mr r30,r4 317 mr r30,r4
282 318
319#ifdef CONFIG_PPC_BOOK3E
320 bl .start_initialization_book3e
321 b .__after_prom_start
322#else
283 /* Setup some critical 970 SPRs before switching MMU off */ 323 /* Setup some critical 970 SPRs before switching MMU off */
284 mfspr r0,SPRN_PVR 324 mfspr r0,SPRN_PVR
285 srwi r0,r0,16 325 srwi r0,r0,16
@@ -297,6 +337,7 @@ _GLOBAL(__start_initialization_multiplatform)
297 /* Switch off MMU if not already off */ 337 /* Switch off MMU if not already off */
298 bl .__mmu_off 338 bl .__mmu_off
299 b .__after_prom_start 339 b .__after_prom_start
340#endif /* CONFIG_PPC_BOOK3E */
300 341
301_INIT_STATIC(__boot_from_prom) 342_INIT_STATIC(__boot_from_prom)
302#ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE 343#ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
@@ -359,10 +400,16 @@ _STATIC(__after_prom_start)
359 * Note: This process overwrites the OF exception vectors. 400 * Note: This process overwrites the OF exception vectors.
360 */ 401 */
361 li r3,0 /* target addr */ 402 li r3,0 /* target addr */
403#ifdef CONFIG_PPC_BOOK3E
404 tovirt(r3,r3) /* on booke, we already run at PAGE_OFFSET */
405#endif
362 mr. r4,r26 /* In some cases the loader may */ 406 mr. r4,r26 /* In some cases the loader may */
363 beq 9f /* have already put us at zero */ 407 beq 9f /* have already put us at zero */
364 li r6,0x100 /* Start offset, the first 0x100 */ 408 li r6,0x100 /* Start offset, the first 0x100 */
365 /* bytes were copied earlier. */ 409 /* bytes were copied earlier. */
410#ifdef CONFIG_PPC_BOOK3E
411 tovirt(r6,r6) /* on booke, we already run at PAGE_OFFSET */
412#endif
366 413
367#ifdef CONFIG_CRASH_DUMP 414#ifdef CONFIG_CRASH_DUMP
368/* 415/*
@@ -485,7 +532,7 @@ _GLOBAL(pmac_secondary_start)
485 LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */ 532 LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */
486 mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */ 533 mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */
487 add r13,r13,r4 /* for this processor. */ 534 add r13,r13,r4 /* for this processor. */
488 mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */ 535 mtspr SPRN_SPRG_PACA,r13 /* Save vaddr of paca in an SPRG*/
489 536
490 /* Create a temp kernel stack for use before relocation is on. */ 537 /* Create a temp kernel stack for use before relocation is on. */
491 ld r1,PACAEMERGSP(r13) 538 ld r1,PACAEMERGSP(r13)
@@ -503,11 +550,14 @@ _GLOBAL(pmac_secondary_start)
503 * 1. Processor number 550 * 1. Processor number
504 * 2. Segment table pointer (virtual address) 551 * 2. Segment table pointer (virtual address)
505 * On entry the following are set: 552 * On entry the following are set:
506 * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries 553 * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries
507 * r24 = cpu# (in Linux terms) 554 * r24 = cpu# (in Linux terms)
508 * r13 = paca virtual address 555 * r13 = paca virtual address
509 * SPRG3 = paca virtual address 556 * SPRG_PACA = paca virtual address
510 */ 557 */
558 .section ".text";
559 .align 2 ;
560
511 .globl __secondary_start 561 .globl __secondary_start
512__secondary_start: 562__secondary_start:
513 /* Set thread priority to MEDIUM */ 563 /* Set thread priority to MEDIUM */
@@ -544,7 +594,7 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
544 594
545 mtspr SPRN_SRR0,r3 595 mtspr SPRN_SRR0,r3
546 mtspr SPRN_SRR1,r4 596 mtspr SPRN_SRR1,r4
547 rfid 597 RFI
548 b . /* prevent speculative execution */ 598 b . /* prevent speculative execution */
549 599
550/* 600/*
@@ -565,11 +615,16 @@ _GLOBAL(start_secondary_prolog)
565 */ 615 */
566_GLOBAL(enable_64b_mode) 616_GLOBAL(enable_64b_mode)
567 mfmsr r11 /* grab the current MSR */ 617 mfmsr r11 /* grab the current MSR */
618#ifdef CONFIG_PPC_BOOK3E
619 oris r11,r11,0x8000 /* CM bit set, we'll set ICM later */
620 mtmsr r11
621#else /* CONFIG_PPC_BOOK3E */
568 li r12,(MSR_SF | MSR_ISF)@highest 622 li r12,(MSR_SF | MSR_ISF)@highest
569 sldi r12,r12,48 623 sldi r12,r12,48
570 or r11,r11,r12 624 or r11,r11,r12
571 mtmsrd r11 625 mtmsrd r11
572 isync 626 isync
627#endif
573 blr 628 blr
574 629
575/* 630/*
@@ -613,9 +668,11 @@ _INIT_STATIC(start_here_multiplatform)
613 bdnz 3b 668 bdnz 3b
6144: 6694:
615 670
671#ifndef CONFIG_PPC_BOOK3E
616 mfmsr r6 672 mfmsr r6
617 ori r6,r6,MSR_RI 673 ori r6,r6,MSR_RI
618 mtmsrd r6 /* RI on */ 674 mtmsrd r6 /* RI on */
675#endif
619 676
620#ifdef CONFIG_RELOCATABLE 677#ifdef CONFIG_RELOCATABLE
621 /* Save the physical address we're running at in kernstart_addr */ 678 /* Save the physical address we're running at in kernstart_addr */
@@ -642,13 +699,13 @@ _INIT_STATIC(start_here_multiplatform)
642 699
643 /* Restore parameters passed from prom_init/kexec */ 700 /* Restore parameters passed from prom_init/kexec */
644 mr r3,r31 701 mr r3,r31
645 bl .early_setup /* also sets r13 and SPRG3 */ 702 bl .early_setup /* also sets r13 and SPRG_PACA */
646 703
647 LOAD_REG_ADDR(r3, .start_here_common) 704 LOAD_REG_ADDR(r3, .start_here_common)
648 ld r4,PACAKMSR(r13) 705 ld r4,PACAKMSR(r13)
649 mtspr SPRN_SRR0,r3 706 mtspr SPRN_SRR0,r3
650 mtspr SPRN_SRR1,r4 707 mtspr SPRN_SRR1,r4
651 rfid 708 RFI
652 b . /* prevent speculative execution */ 709 b . /* prevent speculative execution */
653 710
654 /* This is where all platforms converge execution */ 711 /* This is where all platforms converge execution */
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 52ff8c53b93c..6ded19d01891 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -110,8 +110,8 @@ turn_on_mmu:
110 * task's thread_struct. 110 * task's thread_struct.
111 */ 111 */
112#define EXCEPTION_PROLOG \ 112#define EXCEPTION_PROLOG \
113 mtspr SPRN_SPRG0,r10; \ 113 mtspr SPRN_SPRG_SCRATCH0,r10; \
114 mtspr SPRN_SPRG1,r11; \ 114 mtspr SPRN_SPRG_SCRATCH1,r11; \
115 mfcr r10; \ 115 mfcr r10; \
116 EXCEPTION_PROLOG_1; \ 116 EXCEPTION_PROLOG_1; \
117 EXCEPTION_PROLOG_2 117 EXCEPTION_PROLOG_2
@@ -121,7 +121,7 @@ turn_on_mmu:
121 andi. r11,r11,MSR_PR; \ 121 andi. r11,r11,MSR_PR; \
122 tophys(r11,r1); /* use tophys(r1) if kernel */ \ 122 tophys(r11,r1); /* use tophys(r1) if kernel */ \
123 beq 1f; \ 123 beq 1f; \
124 mfspr r11,SPRN_SPRG3; \ 124 mfspr r11,SPRN_SPRG_THREAD; \
125 lwz r11,THREAD_INFO-THREAD(r11); \ 125 lwz r11,THREAD_INFO-THREAD(r11); \
126 addi r11,r11,THREAD_SIZE; \ 126 addi r11,r11,THREAD_SIZE; \
127 tophys(r11,r11); \ 127 tophys(r11,r11); \
@@ -133,9 +133,9 @@ turn_on_mmu:
133 stw r10,_CCR(r11); /* save registers */ \ 133 stw r10,_CCR(r11); /* save registers */ \
134 stw r12,GPR12(r11); \ 134 stw r12,GPR12(r11); \
135 stw r9,GPR9(r11); \ 135 stw r9,GPR9(r11); \
136 mfspr r10,SPRN_SPRG0; \ 136 mfspr r10,SPRN_SPRG_SCRATCH0; \
137 stw r10,GPR10(r11); \ 137 stw r10,GPR10(r11); \
138 mfspr r12,SPRN_SPRG1; \ 138 mfspr r12,SPRN_SPRG_SCRATCH1; \
139 stw r12,GPR11(r11); \ 139 stw r12,GPR11(r11); \
140 mflr r10; \ 140 mflr r10; \
141 stw r10,_LINK(r11); \ 141 stw r10,_LINK(r11); \
@@ -603,8 +603,9 @@ start_here:
603 /* ptr to phys current thread */ 603 /* ptr to phys current thread */
604 tophys(r4,r2) 604 tophys(r4,r2)
605 addi r4,r4,THREAD /* init task's THREAD */ 605 addi r4,r4,THREAD /* init task's THREAD */
606 mtspr SPRN_SPRG3,r4 606 mtspr SPRN_SPRG_THREAD,r4
607 li r3,0 607 li r3,0
608 /* XXX What is that for ? SPRG2 appears otherwise unused on 8xx */
608 mtspr SPRN_SPRG2,r3 /* 0 => r1 has kernel sp */ 609 mtspr SPRN_SPRG2,r3 /* 0 => r1 has kernel sp */
609 610
610 /* stack */ 611 /* stack */
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index 5f9febc8d143..50504ae39cb7 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -20,14 +20,14 @@
20#endif 20#endif
21 21
22#define NORMAL_EXCEPTION_PROLOG \ 22#define NORMAL_EXCEPTION_PROLOG \
23 mtspr SPRN_SPRG0,r10; /* save two registers to work with */\ 23 mtspr SPRN_SPRG_WSCRATCH0,r10;/* save two registers to work with */\
24 mtspr SPRN_SPRG1,r11; \ 24 mtspr SPRN_SPRG_WSCRATCH1,r11; \
25 mtspr SPRN_SPRG4W,r1; \ 25 mtspr SPRN_SPRG_WSCRATCH2,r1; \
26 mfcr r10; /* save CR in r10 for now */\ 26 mfcr r10; /* save CR in r10 for now */\
27 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\ 27 mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
28 andi. r11,r11,MSR_PR; \ 28 andi. r11,r11,MSR_PR; \
29 beq 1f; \ 29 beq 1f; \
30 mfspr r1,SPRN_SPRG3; /* if from user, start at top of */\ 30 mfspr r1,SPRN_SPRG_THREAD; /* if from user, start at top of */\
31 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\ 31 lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\
32 ALLOC_STACK_FRAME(r1, THREAD_SIZE); \ 32 ALLOC_STACK_FRAME(r1, THREAD_SIZE); \
331: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\ 331: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\
@@ -35,13 +35,13 @@
35 stw r10,_CCR(r11); /* save various registers */\ 35 stw r10,_CCR(r11); /* save various registers */\
36 stw r12,GPR12(r11); \ 36 stw r12,GPR12(r11); \
37 stw r9,GPR9(r11); \ 37 stw r9,GPR9(r11); \
38 mfspr r10,SPRN_SPRG0; \ 38 mfspr r10,SPRN_SPRG_RSCRATCH0; \
39 stw r10,GPR10(r11); \ 39 stw r10,GPR10(r11); \
40 mfspr r12,SPRN_SPRG1; \ 40 mfspr r12,SPRN_SPRG_RSCRATCH1; \
41 stw r12,GPR11(r11); \ 41 stw r12,GPR11(r11); \
42 mflr r10; \ 42 mflr r10; \
43 stw r10,_LINK(r11); \ 43 stw r10,_LINK(r11); \
44 mfspr r10,SPRN_SPRG4R; \ 44 mfspr r10,SPRN_SPRG_RSCRATCH2; \
45 mfspr r12,SPRN_SRR0; \ 45 mfspr r12,SPRN_SRR0; \
46 stw r10,GPR1(r11); \ 46 stw r10,GPR1(r11); \
47 mfspr r9,SPRN_SRR1; \ 47 mfspr r9,SPRN_SRR1; \
@@ -69,21 +69,11 @@
69 * providing configurations that micro-optimize space usage. 69 * providing configurations that micro-optimize space usage.
70 */ 70 */
71 71
72/* CRIT_SPRG only used in critical exception handling */ 72#define MC_STACK_BASE mcheckirq_ctx
73#define CRIT_SPRG SPRN_SPRG2
74/* MCHECK_SPRG only used in machine check exception handling */
75#define MCHECK_SPRG SPRN_SPRG6W
76
77#define MCHECK_STACK_BASE mcheckirq_ctx
78#define CRIT_STACK_BASE critirq_ctx 73#define CRIT_STACK_BASE critirq_ctx
79 74
80/* only on e500mc/e200 */ 75/* only on e500mc/e200 */
81#define DEBUG_STACK_BASE dbgirq_ctx 76#define DBG_STACK_BASE dbgirq_ctx
82#ifdef CONFIG_E200
83#define DEBUG_SPRG SPRN_SPRG6W
84#else
85#define DEBUG_SPRG SPRN_SPRG9
86#endif
87 77
88#define EXC_LVL_FRAME_OVERHEAD (THREAD_SIZE - INT_FRAME_SIZE - EXC_LVL_SIZE) 78#define EXC_LVL_FRAME_OVERHEAD (THREAD_SIZE - INT_FRAME_SIZE - EXC_LVL_SIZE)
89 79
@@ -110,7 +100,7 @@
110 * critical/machine check exception stack at low physical addresses. 100 * critical/machine check exception stack at low physical addresses.
111 */ 101 */
112#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \ 102#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
113 mtspr exc_level##_SPRG,r8; \ 103 mtspr SPRN_SPRG_WSCRATCH_##exc_level,r8; \
114 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \ 104 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
115 stw r9,GPR9(r8); /* save various registers */\ 105 stw r9,GPR9(r8); /* save various registers */\
116 mfcr r9; /* save CR in r9 for now */\ 106 mfcr r9; /* save CR in r9 for now */\
@@ -119,7 +109,7 @@
119 stw r9,_CCR(r8); /* save CR on stack */\ 109 stw r9,_CCR(r8); /* save CR on stack */\
120 mfspr r10,exc_level_srr1; /* check whether user or kernel */\ 110 mfspr r10,exc_level_srr1; /* check whether user or kernel */\
121 andi. r10,r10,MSR_PR; \ 111 andi. r10,r10,MSR_PR; \
122 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\ 112 mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\
123 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\ 113 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
124 addi r11,r11,EXC_LVL_FRAME_OVERHEAD; /* allocate stack frame */\ 114 addi r11,r11,EXC_LVL_FRAME_OVERHEAD; /* allocate stack frame */\
125 beq 1f; \ 115 beq 1f; \
@@ -140,7 +130,7 @@
140 lwz r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r11); \ 130 lwz r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r11); \
141 stw r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r8); \ 131 stw r9,TI_TASK-EXC_LVL_FRAME_OVERHEAD(r8); \
142 mr r11,r8; \ 132 mr r11,r8; \
1432: mfspr r8,exc_level##_SPRG; \ 1332: mfspr r8,SPRN_SPRG_RSCRATCH_##exc_level; \
144 stw r12,GPR12(r11); /* save various registers */\ 134 stw r12,GPR12(r11); /* save various registers */\
145 mflr r10; \ 135 mflr r10; \
146 stw r10,_LINK(r11); \ 136 stw r10,_LINK(r11); \
@@ -161,9 +151,9 @@
161#define CRITICAL_EXCEPTION_PROLOG \ 151#define CRITICAL_EXCEPTION_PROLOG \
162 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1) 152 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1)
163#define DEBUG_EXCEPTION_PROLOG \ 153#define DEBUG_EXCEPTION_PROLOG \
164 EXC_LEVEL_EXCEPTION_PROLOG(DEBUG, SPRN_DSRR0, SPRN_DSRR1) 154 EXC_LEVEL_EXCEPTION_PROLOG(DBG, SPRN_DSRR0, SPRN_DSRR1)
165#define MCHECK_EXCEPTION_PROLOG \ 155#define MCHECK_EXCEPTION_PROLOG \
166 EXC_LEVEL_EXCEPTION_PROLOG(MCHECK, SPRN_MCSRR0, SPRN_MCSRR1) 156 EXC_LEVEL_EXCEPTION_PROLOG(MC, SPRN_MCSRR0, SPRN_MCSRR1)
167 157
168/* 158/*
169 * Exception vectors. 159 * Exception vectors.
@@ -282,13 +272,13 @@ label:
282 mtspr SPRN_DSRR1,r9; \ 272 mtspr SPRN_DSRR1,r9; \
283 lwz r9,GPR9(r11); \ 273 lwz r9,GPR9(r11); \
284 lwz r12,GPR12(r11); \ 274 lwz r12,GPR12(r11); \
285 mtspr DEBUG_SPRG,r8; \ 275 mtspr SPRN_SPRG_WSCRATCH_DBG,r8; \
286 BOOKE_LOAD_EXC_LEVEL_STACK(DEBUG); /* r8 points to the debug stack */ \ 276 BOOKE_LOAD_EXC_LEVEL_STACK(DBG); /* r8 points to the debug stack */ \
287 lwz r10,GPR10(r8); \ 277 lwz r10,GPR10(r8); \
288 lwz r11,GPR11(r8); \ 278 lwz r11,GPR11(r8); \
289 mfspr r8,DEBUG_SPRG; \ 279 mfspr r8,SPRN_SPRG_RSCRATCH_DBG; \
290 \ 280 \
291 PPC_RFDI; \ 281 PPC_RFDI; \
292 b .; \ 282 b .; \
293 \ 283 \
294 /* continue normal handling for a debug exception... */ \ 284 /* continue normal handling for a debug exception... */ \
@@ -335,11 +325,11 @@ label:
335 mtspr SPRN_CSRR1,r9; \ 325 mtspr SPRN_CSRR1,r9; \
336 lwz r9,GPR9(r11); \ 326 lwz r9,GPR9(r11); \
337 lwz r12,GPR12(r11); \ 327 lwz r12,GPR12(r11); \
338 mtspr CRIT_SPRG,r8; \ 328 mtspr SPRN_SPRG_WSCRATCH_CRIT,r8; \
339 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \ 329 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
340 lwz r10,GPR10(r8); \ 330 lwz r10,GPR10(r8); \
341 lwz r11,GPR11(r8); \ 331 lwz r11,GPR11(r8); \
342 mfspr r8,CRIT_SPRG; \ 332 mfspr r8,SPRN_SPRG_RSCRATCH_CRIT; \
343 \ 333 \
344 rfci; \ 334 rfci; \
345 b .; \ 335 b .; \
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 5bdcc06d294c..975788ca05d2 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -361,7 +361,7 @@ skpinv: addi r6,r6,1 /* Increment */
361 361
362 /* ptr to current thread */ 362 /* ptr to current thread */
363 addi r4,r2,THREAD /* init task's THREAD */ 363 addi r4,r2,THREAD /* init task's THREAD */
364 mtspr SPRN_SPRG3,r4 364 mtspr SPRN_SPRG_THREAD,r4
365 365
366 /* stack */ 366 /* stack */
367 lis r1,init_thread_union@h 367 lis r1,init_thread_union@h
@@ -532,12 +532,12 @@ interrupt_base:
532 532
533 /* Data TLB Error Interrupt */ 533 /* Data TLB Error Interrupt */
534 START_EXCEPTION(DataTLBError) 534 START_EXCEPTION(DataTLBError)
535 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 535 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
536 mtspr SPRN_SPRG1, r11 536 mtspr SPRN_SPRG_WSCRATCH1, r11
537 mtspr SPRN_SPRG4W, r12 537 mtspr SPRN_SPRG_WSCRATCH2, r12
538 mtspr SPRN_SPRG5W, r13 538 mtspr SPRN_SPRG_WSCRATCH3, r13
539 mfcr r11 539 mfcr r11
540 mtspr SPRN_SPRG7W, r11 540 mtspr SPRN_SPRG_WSCRATCH4, r11
541 mfspr r10, SPRN_DEAR /* Get faulting address */ 541 mfspr r10, SPRN_DEAR /* Get faulting address */
542 542
543 /* If we are faulting a kernel address, we have to use the 543 /* If we are faulting a kernel address, we have to use the
@@ -557,7 +557,7 @@ interrupt_base:
557 557
558 /* Get the PGD for the current thread */ 558 /* Get the PGD for the current thread */
5593: 5593:
560 mfspr r11,SPRN_SPRG3 560 mfspr r11,SPRN_SPRG_THREAD
561 lwz r11,PGDIR(r11) 561 lwz r11,PGDIR(r11)
562 562
5634: 5634:
@@ -575,7 +575,12 @@ interrupt_base:
575 * place or can we save a couple of instructions here ? 575 * place or can we save a couple of instructions here ?
576 */ 576 */
577 mfspr r12,SPRN_ESR 577 mfspr r12,SPRN_ESR
578#ifdef CONFIG_PTE_64BIT
579 li r13,_PAGE_PRESENT
580 oris r13,r13,_PAGE_ACCESSED@h
581#else
578 li r13,_PAGE_PRESENT|_PAGE_ACCESSED 582 li r13,_PAGE_PRESENT|_PAGE_ACCESSED
583#endif
579 rlwimi r13,r12,11,29,29 584 rlwimi r13,r12,11,29,29
580 585
581 FIND_PTE 586 FIND_PTE
@@ -598,12 +603,12 @@ interrupt_base:
598 /* The bailout. Restore registers to pre-exception conditions 603 /* The bailout. Restore registers to pre-exception conditions
599 * and call the heavyweights to help us out. 604 * and call the heavyweights to help us out.
600 */ 605 */
601 mfspr r11, SPRN_SPRG7R 606 mfspr r11, SPRN_SPRG_RSCRATCH4
602 mtcr r11 607 mtcr r11
603 mfspr r13, SPRN_SPRG5R 608 mfspr r13, SPRN_SPRG_RSCRATCH3
604 mfspr r12, SPRN_SPRG4R 609 mfspr r12, SPRN_SPRG_RSCRATCH2
605 mfspr r11, SPRN_SPRG1 610 mfspr r11, SPRN_SPRG_RSCRATCH1
606 mfspr r10, SPRN_SPRG0 611 mfspr r10, SPRN_SPRG_RSCRATCH0
607 b DataStorage 612 b DataStorage
608 613
609 /* Instruction TLB Error Interrupt */ 614 /* Instruction TLB Error Interrupt */
@@ -613,12 +618,12 @@ interrupt_base:
613 * to a different point. 618 * to a different point.
614 */ 619 */
615 START_EXCEPTION(InstructionTLBError) 620 START_EXCEPTION(InstructionTLBError)
616 mtspr SPRN_SPRG0, r10 /* Save some working registers */ 621 mtspr SPRN_SPRG_WSCRATCH0, r10 /* Save some working registers */
617 mtspr SPRN_SPRG1, r11 622 mtspr SPRN_SPRG_WSCRATCH1, r11
618 mtspr SPRN_SPRG4W, r12 623 mtspr SPRN_SPRG_WSCRATCH2, r12
619 mtspr SPRN_SPRG5W, r13 624 mtspr SPRN_SPRG_WSCRATCH3, r13
620 mfcr r11 625 mfcr r11
621 mtspr SPRN_SPRG7W, r11 626 mtspr SPRN_SPRG_WSCRATCH4, r11
622 mfspr r10, SPRN_SRR0 /* Get faulting address */ 627 mfspr r10, SPRN_SRR0 /* Get faulting address */
623 628
624 /* If we are faulting a kernel address, we have to use the 629 /* If we are faulting a kernel address, we have to use the
@@ -638,12 +643,17 @@ interrupt_base:
638 643
639 /* Get the PGD for the current thread */ 644 /* Get the PGD for the current thread */
6403: 6453:
641 mfspr r11,SPRN_SPRG3 646 mfspr r11,SPRN_SPRG_THREAD
642 lwz r11,PGDIR(r11) 647 lwz r11,PGDIR(r11)
643 648
6444: 6494:
645 /* Make up the required permissions */ 650 /* Make up the required permissions */
646 li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_HWEXEC 651#ifdef CONFIG_PTE_64BIT
652 li r13,_PAGE_PRESENT | _PAGE_EXEC
653 oris r13,r13,_PAGE_ACCESSED@h
654#else
655 li r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
656#endif
647 657
648 FIND_PTE 658 FIND_PTE
649 andc. r13,r13,r11 /* Check permission */ 659 andc. r13,r13,r11 /* Check permission */
@@ -666,12 +676,12 @@ interrupt_base:
666 /* The bailout. Restore registers to pre-exception conditions 676 /* The bailout. Restore registers to pre-exception conditions
667 * and call the heavyweights to help us out. 677 * and call the heavyweights to help us out.
668 */ 678 */
669 mfspr r11, SPRN_SPRG7R 679 mfspr r11, SPRN_SPRG_RSCRATCH4
670 mtcr r11 680 mtcr r11
671 mfspr r13, SPRN_SPRG5R 681 mfspr r13, SPRN_SPRG_RSCRATCH3
672 mfspr r12, SPRN_SPRG4R 682 mfspr r12, SPRN_SPRG_RSCRATCH2
673 mfspr r11, SPRN_SPRG1 683 mfspr r11, SPRN_SPRG_RSCRATCH1
674 mfspr r10, SPRN_SPRG0 684 mfspr r10, SPRN_SPRG_RSCRATCH0
675 b InstructionStorage 685 b InstructionStorage
676 686
677#ifdef CONFIG_SPE 687#ifdef CONFIG_SPE
@@ -733,7 +743,7 @@ finish_tlb_load:
733 743
734 mfspr r12, SPRN_MAS2 744 mfspr r12, SPRN_MAS2
735#ifdef CONFIG_PTE_64BIT 745#ifdef CONFIG_PTE_64BIT
736 rlwimi r12, r11, 26, 24, 31 /* extract ...WIMGE from pte */ 746 rlwimi r12, r11, 32-19, 27, 31 /* extract WIMGE from pte */
737#else 747#else
738 rlwimi r12, r11, 26, 27, 31 /* extract WIMGE from pte */ 748 rlwimi r12, r11, 26, 27, 31 /* extract WIMGE from pte */
739#endif 749#endif
@@ -742,23 +752,27 @@ finish_tlb_load:
742#endif 752#endif
743 mtspr SPRN_MAS2, r12 753 mtspr SPRN_MAS2, r12
744 754
745 li r10, (_PAGE_HWEXEC | _PAGE_PRESENT)
746 rlwimi r10, r11, 31, 29, 29 /* extract _PAGE_DIRTY into SW */
747 and r12, r11, r10
748 andi. r10, r11, _PAGE_USER /* Test for _PAGE_USER */
749 slwi r10, r12, 1
750 or r10, r10, r12
751 iseleq r12, r12, r10
752
753#ifdef CONFIG_PTE_64BIT 755#ifdef CONFIG_PTE_64BIT
754 rlwimi r12, r13, 24, 0, 7 /* grab RPN[32:39] */ 756 rlwinm r12, r11, 32-2, 26, 31 /* Move in perm bits */
755 rlwimi r12, r11, 24, 8, 19 /* grab RPN[40:51] */ 757 andi. r10, r11, _PAGE_DIRTY
758 bne 1f
759 li r10, MAS3_SW | MAS3_UW
760 andc r12, r12, r10
7611: rlwimi r12, r13, 20, 0, 11 /* grab RPN[32:43] */
762 rlwimi r12, r11, 20, 12, 19 /* grab RPN[44:51] */
756 mtspr SPRN_MAS3, r12 763 mtspr SPRN_MAS3, r12
757BEGIN_MMU_FTR_SECTION 764BEGIN_MMU_FTR_SECTION
758 srwi r10, r13, 8 /* grab RPN[8:31] */ 765 srwi r10, r13, 12 /* grab RPN[12:31] */
759 mtspr SPRN_MAS7, r10 766 mtspr SPRN_MAS7, r10
760END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS) 767END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS)
761#else 768#else
769 li r10, (_PAGE_EXEC | _PAGE_PRESENT)
770 rlwimi r10, r11, 31, 29, 29 /* extract _PAGE_DIRTY into SW */
771 and r12, r11, r10
772 andi. r10, r11, _PAGE_USER /* Test for _PAGE_USER */
773 slwi r10, r12, 1
774 or r10, r10, r12
775 iseleq r12, r12, r10
762 rlwimi r11, r12, 0, 20, 31 /* Extract RPN from PTE and merge with perms */ 776 rlwimi r11, r12, 0, 20, 31 /* Extract RPN from PTE and merge with perms */
763 mtspr SPRN_MAS3, r11 777 mtspr SPRN_MAS3, r11
764#endif 778#endif
@@ -790,12 +804,12 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS)
790 tlbwe 804 tlbwe
791 805
792 /* Done...restore registers and get out of here. */ 806 /* Done...restore registers and get out of here. */
793 mfspr r11, SPRN_SPRG7R 807 mfspr r11, SPRN_SPRG_RSCRATCH4
794 mtcr r11 808 mtcr r11
795 mfspr r13, SPRN_SPRG5R 809 mfspr r13, SPRN_SPRG_RSCRATCH3
796 mfspr r12, SPRN_SPRG4R 810 mfspr r12, SPRN_SPRG_RSCRATCH2
797 mfspr r11, SPRN_SPRG1 811 mfspr r11, SPRN_SPRG_RSCRATCH1
798 mfspr r10, SPRN_SPRG0 812 mfspr r10, SPRN_SPRG_RSCRATCH0
799 rfi /* Force context change */ 813 rfi /* Force context change */
800 814
801#ifdef CONFIG_SPE 815#ifdef CONFIG_SPE
@@ -839,7 +853,7 @@ load_up_spe:
839#endif /* !CONFIG_SMP */ 853#endif /* !CONFIG_SMP */
840 /* enable use of SPE after return */ 854 /* enable use of SPE after return */
841 oris r9,r9,MSR_SPE@h 855 oris r9,r9,MSR_SPE@h
842 mfspr r5,SPRN_SPRG3 /* current task's THREAD (phys) */ 856 mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */
843 li r4,1 857 li r4,1
844 li r10,THREAD_ACC 858 li r10,THREAD_ACC
845 stw r4,THREAD_USED_SPE(r5) 859 stw r4,THREAD_USED_SPE(r5)
@@ -1118,7 +1132,7 @@ __secondary_start:
1118 1132
1119 /* ptr to current thread */ 1133 /* ptr to current thread */
1120 addi r4,r2,THREAD /* address of our thread_struct */ 1134 addi r4,r2,THREAD /* address of our thread_struct */
1121 mtspr SPRN_SPRG3,r4 1135 mtspr SPRN_SPRG_THREAD,r4
1122 1136
1123 /* Setup the defaults for TLB entries */ 1137 /* Setup the defaults for TLB entries */
1124 li r4,(MAS4_TSIZED(BOOK3E_PAGESZ_4K))@l 1138 li r4,(MAS4_TSIZED(BOOK3E_PAGESZ_4K))@l
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 6e3f62493659..a4c8b38b0ba1 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
127 return 1; 127 return 1;
128} 128}
129 129
130static struct dma_mapping_ops ibmebus_dma_ops = { 130static struct dma_map_ops ibmebus_dma_ops = {
131 .alloc_coherent = ibmebus_alloc_coherent, 131 .alloc_coherent = ibmebus_alloc_coherent,
132 .free_coherent = ibmebus_free_coherent, 132 .free_coherent = ibmebus_free_coherent,
133 .map_sg = ibmebus_map_sg, 133 .map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 2419cc706ff1..ed0ac4e4b8d8 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -35,6 +35,7 @@
35#include <asm/prom.h> 35#include <asm/prom.h>
36#include <asm/vdso_datapage.h> 36#include <asm/vdso_datapage.h>
37#include <asm/vio.h> 37#include <asm/vio.h>
38#include <asm/mmu.h>
38 39
39#define MODULE_VERS "1.8" 40#define MODULE_VERS "1.8"
40#define MODULE_NAME "lparcfg" 41#define MODULE_NAME "lparcfg"
@@ -537,6 +538,8 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
537 538
538 seq_printf(m, "shared_processor_mode=%d\n", lppaca[0].shared_proc); 539 seq_printf(m, "shared_processor_mode=%d\n", lppaca[0].shared_proc);
539 540
541 seq_printf(m, "slb_size=%d\n", mmu_slb_size);
542
540 return 0; 543 return 0;
541} 544}
542 545
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 15f28e0de78d..da9c0c4c10f3 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -342,10 +342,17 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
342 addi r3,r3,L1_CACHE_BYTES 342 addi r3,r3,L1_CACHE_BYTES
343 bdnz 1b 343 bdnz 1b
344 sync /* wait for dcbst's to get to ram */ 344 sync /* wait for dcbst's to get to ram */
345#ifndef CONFIG_44x
345 mtctr r4 346 mtctr r4
3462: icbi 0,r6 3472: icbi 0,r6
347 addi r6,r6,L1_CACHE_BYTES 348 addi r6,r6,L1_CACHE_BYTES
348 bdnz 2b 349 bdnz 2b
350#else
351 /* Flash invalidate on 44x because we are passed kmapped addresses and
352 this doesn't work for userspace pages due to the virtually tagged
353 icache. Sigh. */
354 iccci 0, r0
355#endif
349 sync /* additional sync needed on g4 */ 356 sync /* additional sync needed on g4 */
350 isync 357 isync
351 blr 358 blr
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 87df428e3588..1a4fc0d11a03 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -276,7 +276,7 @@ static int __devinit of_pci_phb_probe(struct of_device *dev,
276#endif /* CONFIG_EEH */ 276#endif /* CONFIG_EEH */
277 277
278 /* Scan the bus */ 278 /* Scan the bus */
279 scan_phb(phb); 279 pcibios_scan_phb(phb, dev->node);
280 if (phb->bus == NULL) 280 if (phb->bus == NULL)
281 return -ENXIO; 281 return -ENXIO;
282 282
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index e9962c7f8a09..d16b1ea55d44 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -13,6 +13,7 @@
13#include <asm/lppaca.h> 13#include <asm/lppaca.h>
14#include <asm/paca.h> 14#include <asm/paca.h>
15#include <asm/sections.h> 15#include <asm/sections.h>
16#include <asm/pgtable.h>
16 17
17/* This symbol is provided by the linker - let it fill in the paca 18/* This symbol is provided by the linker - let it fill in the paca
18 * field correctly */ 19 * field correctly */
@@ -87,6 +88,8 @@ void __init initialise_pacas(void)
87 88
88#ifdef CONFIG_PPC_BOOK3S 89#ifdef CONFIG_PPC_BOOK3S
89 new_paca->lppaca_ptr = &lppaca[cpu]; 90 new_paca->lppaca_ptr = &lppaca[cpu];
91#else
92 new_paca->kernel_pgd = swapper_pg_dir;
90#endif 93#endif
91 new_paca->lock_token = 0x8000; 94 new_paca->lock_token = 0x8000;
92 new_paca->paca_index = cpu; 95 new_paca->paca_index = cpu;
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 5a56e97c5ac0..e9f4840096b3 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
50unsigned int ppc_pci_flags = 0; 50unsigned int ppc_pci_flags = 0;
51 51
52 52
53static struct dma_mapping_ops *pci_dma_ops = &dma_direct_ops; 53static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
54 54
55void set_pci_dma_ops(struct dma_mapping_ops *dma_ops) 55void set_pci_dma_ops(struct dma_map_ops *dma_ops)
56{ 56{
57 pci_dma_ops = dma_ops; 57 pci_dma_ops = dma_ops;
58} 58}
59 59
60struct dma_mapping_ops *get_pci_dma_ops(void) 60struct dma_map_ops *get_pci_dma_ops(void)
61{ 61{
62 return pci_dma_ops; 62 return pci_dma_ops;
63} 63}
@@ -176,8 +176,6 @@ int pci_domain_nr(struct pci_bus *bus)
176} 176}
177EXPORT_SYMBOL(pci_domain_nr); 177EXPORT_SYMBOL(pci_domain_nr);
178 178
179#ifdef CONFIG_PPC_OF
180
181/* This routine is meant to be used early during boot, when the 179/* This routine is meant to be used early during boot, when the
182 * PCI bus numbers have not yet been assigned, and you need to 180 * PCI bus numbers have not yet been assigned, and you need to
183 * issue PCI config cycles to an OF device. 181 * issue PCI config cycles to an OF device.
@@ -210,17 +208,11 @@ static ssize_t pci_show_devspec(struct device *dev,
210 return sprintf(buf, "%s", np->full_name); 208 return sprintf(buf, "%s", np->full_name);
211} 209}
212static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL); 210static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL);
213#endif /* CONFIG_PPC_OF */
214 211
215/* Add sysfs properties */ 212/* Add sysfs properties */
216int pcibios_add_platform_entries(struct pci_dev *pdev) 213int pcibios_add_platform_entries(struct pci_dev *pdev)
217{ 214{
218#ifdef CONFIG_PPC_OF
219 return device_create_file(&pdev->dev, &dev_attr_devspec); 215 return device_create_file(&pdev->dev, &dev_attr_devspec);
220#else
221 return 0;
222#endif /* CONFIG_PPC_OF */
223
224} 216}
225 217
226char __devinit *pcibios_setup(char *str) 218char __devinit *pcibios_setup(char *str)
@@ -1626,3 +1618,122 @@ void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
1626 1618
1627} 1619}
1628 1620
1621/*
1622 * Null PCI config access functions, for the case when we can't
1623 * find a hose.
1624 */
1625#define NULL_PCI_OP(rw, size, type) \
1626static int \
1627null_##rw##_config_##size(struct pci_dev *dev, int offset, type val) \
1628{ \
1629 return PCIBIOS_DEVICE_NOT_FOUND; \
1630}
1631
1632static int
1633null_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
1634 int len, u32 *val)
1635{
1636 return PCIBIOS_DEVICE_NOT_FOUND;
1637}
1638
1639static int
1640null_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
1641 int len, u32 val)
1642{
1643 return PCIBIOS_DEVICE_NOT_FOUND;
1644}
1645
1646static struct pci_ops null_pci_ops =
1647{
1648 .read = null_read_config,
1649 .write = null_write_config,
1650};
1651
1652/*
1653 * These functions are used early on before PCI scanning is done
1654 * and all of the pci_dev and pci_bus structures have been created.
1655 */
1656static struct pci_bus *
1657fake_pci_bus(struct pci_controller *hose, int busnr)
1658{
1659 static struct pci_bus bus;
1660
1661 if (hose == 0) {
1662 printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr);
1663 }
1664 bus.number = busnr;
1665 bus.sysdata = hose;
1666 bus.ops = hose? hose->ops: &null_pci_ops;
1667 return &bus;
1668}
1669
1670#define EARLY_PCI_OP(rw, size, type) \
1671int early_##rw##_config_##size(struct pci_controller *hose, int bus, \
1672 int devfn, int offset, type value) \
1673{ \
1674 return pci_bus_##rw##_config_##size(fake_pci_bus(hose, bus), \
1675 devfn, offset, value); \
1676}
1677
1678EARLY_PCI_OP(read, byte, u8 *)
1679EARLY_PCI_OP(read, word, u16 *)
1680EARLY_PCI_OP(read, dword, u32 *)
1681EARLY_PCI_OP(write, byte, u8)
1682EARLY_PCI_OP(write, word, u16)
1683EARLY_PCI_OP(write, dword, u32)
1684
1685extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
1686int early_find_capability(struct pci_controller *hose, int bus, int devfn,
1687 int cap)
1688{
1689 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
1690}
1691
1692/**
1693 * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus
1694 * @hose: Pointer to the PCI host controller instance structure
1695 * @sysdata: value to use for sysdata pointer. ppc32 and ppc64 differ here
1696 *
1697 * Note: the 'data' pointer is a temporary measure. As 32 and 64 bit
1698 * pci code gets merged, this parameter should become unnecessary because
1699 * both will use the same value.
1700 */
1701void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata)
1702{
1703 struct pci_bus *bus;
1704 struct device_node *node = hose->dn;
1705 int mode;
1706
1707 pr_debug("PCI: Scanning PHB %s\n",
1708 node ? node->full_name : "<NO NAME>");
1709
1710 /* Create an empty bus for the toplevel */
1711 bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops,
1712 sysdata);
1713 if (bus == NULL) {
1714 pr_err("Failed to create bus for PCI domain %04x\n",
1715 hose->global_number);
1716 return;
1717 }
1718 bus->secondary = hose->first_busno;
1719 hose->bus = bus;
1720
1721 /* Get some IO space for the new PHB */
1722 pcibios_setup_phb_io_space(hose);
1723
1724 /* Wire up PHB bus resources */
1725 pcibios_setup_phb_resources(hose);
1726
1727 /* Get probe mode and perform scan */
1728 mode = PCI_PROBE_NORMAL;
1729 if (node && ppc_md.pci_probe_mode)
1730 mode = ppc_md.pci_probe_mode(bus);
1731 pr_debug(" probe mode: %d\n", mode);
1732 if (mode == PCI_PROBE_DEVTREE) {
1733 bus->subordinate = hose->last_busno;
1734 of_scan_bus(node, bus);
1735 }
1736
1737 if (mode == PCI_PROBE_NORMAL)
1738 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
1739}
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 3ae1c666ff92..c13668cf36d9 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -34,9 +34,7 @@ int pcibios_assign_bus_offset = 1;
34void pcibios_make_OF_bus_map(void); 34void pcibios_make_OF_bus_map(void);
35 35
36static void fixup_cpc710_pci64(struct pci_dev* dev); 36static void fixup_cpc710_pci64(struct pci_dev* dev);
37#ifdef CONFIG_PPC_OF
38static u8* pci_to_OF_bus_map; 37static u8* pci_to_OF_bus_map;
39#endif
40 38
41/* By default, we don't re-assign bus numbers. We do this only on 39/* By default, we don't re-assign bus numbers. We do this only on
42 * some pmacs 40 * some pmacs
@@ -83,7 +81,6 @@ fixup_cpc710_pci64(struct pci_dev* dev)
83} 81}
84DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CPC710_PCI64, fixup_cpc710_pci64); 82DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CPC710_PCI64, fixup_cpc710_pci64);
85 83
86#ifdef CONFIG_PPC_OF
87/* 84/*
88 * Functions below are used on OpenFirmware machines. 85 * Functions below are used on OpenFirmware machines.
89 */ 86 */
@@ -357,42 +354,15 @@ pci_create_OF_bus_map(void)
357 } 354 }
358} 355}
359 356
360#else /* CONFIG_PPC_OF */ 357void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
361void pcibios_make_OF_bus_map(void)
362{ 358{
363}
364#endif /* CONFIG_PPC_OF */
365
366static void __devinit pcibios_scan_phb(struct pci_controller *hose)
367{
368 struct pci_bus *bus;
369 struct device_node *node = hose->dn;
370 unsigned long io_offset; 359 unsigned long io_offset;
371 struct resource *res = &hose->io_resource; 360 struct resource *res = &hose->io_resource;
372 361
373 pr_debug("PCI: Scanning PHB %s\n",
374 node ? node->full_name : "<NO NAME>");
375
376 /* Create an empty bus for the toplevel */
377 bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose);
378 if (bus == NULL) {
379 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
380 hose->global_number);
381 return;
382 }
383 bus->secondary = hose->first_busno;
384 hose->bus = bus;
385
386 /* Fixup IO space offset */ 362 /* Fixup IO space offset */
387 io_offset = (unsigned long)hose->io_base_virt - isa_io_base; 363 io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
388 res->start = (res->start + io_offset) & 0xffffffffu; 364 res->start = (res->start + io_offset) & 0xffffffffu;
389 res->end = (res->end + io_offset) & 0xffffffffu; 365 res->end = (res->end + io_offset) & 0xffffffffu;
390
391 /* Wire up PHB bus resources */
392 pcibios_setup_phb_resources(hose);
393
394 /* Scan children */
395 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
396} 366}
397 367
398static int __init pcibios_init(void) 368static int __init pcibios_init(void)
@@ -410,7 +380,7 @@ static int __init pcibios_init(void)
410 if (pci_assign_all_buses) 380 if (pci_assign_all_buses)
411 hose->first_busno = next_busno; 381 hose->first_busno = next_busno;
412 hose->last_busno = 0xff; 382 hose->last_busno = 0xff;
413 pcibios_scan_phb(hose); 383 pcibios_scan_phb(hose, hose);
414 pci_bus_add_devices(hose->bus); 384 pci_bus_add_devices(hose->bus);
415 if (pci_assign_all_buses || next_busno <= hose->last_busno) 385 if (pci_assign_all_buses || next_busno <= hose->last_busno)
416 next_busno = hose->last_busno + pcibios_assign_bus_offset; 386 next_busno = hose->last_busno + pcibios_assign_bus_offset;
@@ -478,75 +448,4 @@ long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
478 return result; 448 return result;
479} 449}
480 450
481/*
482 * Null PCI config access functions, for the case when we can't
483 * find a hose.
484 */
485#define NULL_PCI_OP(rw, size, type) \
486static int \
487null_##rw##_config_##size(struct pci_dev *dev, int offset, type val) \
488{ \
489 return PCIBIOS_DEVICE_NOT_FOUND; \
490}
491 451
492static int
493null_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
494 int len, u32 *val)
495{
496 return PCIBIOS_DEVICE_NOT_FOUND;
497}
498
499static int
500null_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
501 int len, u32 val)
502{
503 return PCIBIOS_DEVICE_NOT_FOUND;
504}
505
506static struct pci_ops null_pci_ops =
507{
508 .read = null_read_config,
509 .write = null_write_config,
510};
511
512/*
513 * These functions are used early on before PCI scanning is done
514 * and all of the pci_dev and pci_bus structures have been created.
515 */
516static struct pci_bus *
517fake_pci_bus(struct pci_controller *hose, int busnr)
518{
519 static struct pci_bus bus;
520
521 if (hose == 0) {
522 hose = pci_bus_to_hose(busnr);
523 if (hose == 0)
524 printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr);
525 }
526 bus.number = busnr;
527 bus.sysdata = hose;
528 bus.ops = hose? hose->ops: &null_pci_ops;
529 return &bus;
530}
531
532#define EARLY_PCI_OP(rw, size, type) \
533int early_##rw##_config_##size(struct pci_controller *hose, int bus, \
534 int devfn, int offset, type value) \
535{ \
536 return pci_bus_##rw##_config_##size(fake_pci_bus(hose, bus), \
537 devfn, offset, value); \
538}
539
540EARLY_PCI_OP(read, byte, u8 *)
541EARLY_PCI_OP(read, word, u16 *)
542EARLY_PCI_OP(read, dword, u32 *)
543EARLY_PCI_OP(write, byte, u8)
544EARLY_PCI_OP(write, word, u16)
545EARLY_PCI_OP(write, dword, u32)
546
547extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
548int early_find_capability(struct pci_controller *hose, int bus, int devfn,
549 int cap)
550{
551 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
552}
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 9e8902fa14c7..ba949a2c93ac 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -43,334 +43,6 @@ unsigned long pci_probe_only = 1;
43unsigned long pci_io_base = ISA_IO_BASE; 43unsigned long pci_io_base = ISA_IO_BASE;
44EXPORT_SYMBOL(pci_io_base); 44EXPORT_SYMBOL(pci_io_base);
45 45
46static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
47{
48 const u32 *prop;
49 int len;
50
51 prop = of_get_property(np, name, &len);
52 if (prop && len >= 4)
53 return *prop;
54 return def;
55}
56
57static unsigned int pci_parse_of_flags(u32 addr0, int bridge)
58{
59 unsigned int flags = 0;
60
61 if (addr0 & 0x02000000) {
62 flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY;
63 flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64;
64 flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M;
65 if (addr0 & 0x40000000)
66 flags |= IORESOURCE_PREFETCH
67 | PCI_BASE_ADDRESS_MEM_PREFETCH;
68 /* Note: We don't know whether the ROM has been left enabled
69 * by the firmware or not. We mark it as disabled (ie, we do
70 * not set the IORESOURCE_ROM_ENABLE flag) for now rather than
71 * do a config space read, it will be force-enabled if needed
72 */
73 if (!bridge && (addr0 & 0xff) == 0x30)
74 flags |= IORESOURCE_READONLY;
75 } else if (addr0 & 0x01000000)
76 flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO;
77 if (flags)
78 flags |= IORESOURCE_SIZEALIGN;
79 return flags;
80}
81
82
83static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
84{
85 u64 base, size;
86 unsigned int flags;
87 struct resource *res;
88 const u32 *addrs;
89 u32 i;
90 int proplen;
91
92 addrs = of_get_property(node, "assigned-addresses", &proplen);
93 if (!addrs)
94 return;
95 pr_debug(" parse addresses (%d bytes) @ %p\n", proplen, addrs);
96 for (; proplen >= 20; proplen -= 20, addrs += 5) {
97 flags = pci_parse_of_flags(addrs[0], 0);
98 if (!flags)
99 continue;
100 base = of_read_number(&addrs[1], 2);
101 size = of_read_number(&addrs[3], 2);
102 if (!size)
103 continue;
104 i = addrs[0] & 0xff;
105 pr_debug(" base: %llx, size: %llx, i: %x\n",
106 (unsigned long long)base,
107 (unsigned long long)size, i);
108
109 if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
110 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
111 } else if (i == dev->rom_base_reg) {
112 res = &dev->resource[PCI_ROM_RESOURCE];
113 flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
114 } else {
115 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
116 continue;
117 }
118 res->start = base;
119 res->end = base + size - 1;
120 res->flags = flags;
121 res->name = pci_name(dev);
122 }
123}
124
125struct pci_dev *of_create_pci_dev(struct device_node *node,
126 struct pci_bus *bus, int devfn)
127{
128 struct pci_dev *dev;
129 const char *type;
130
131 dev = alloc_pci_dev();
132 if (!dev)
133 return NULL;
134 type = of_get_property(node, "device_type", NULL);
135 if (type == NULL)
136 type = "";
137
138 pr_debug(" create device, devfn: %x, type: %s\n", devfn, type);
139
140 dev->bus = bus;
141 dev->sysdata = node;
142 dev->dev.parent = bus->bridge;
143 dev->dev.bus = &pci_bus_type;
144 dev->devfn = devfn;
145 dev->multifunction = 0; /* maybe a lie? */
146
147 dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
148 dev->device = get_int_prop(node, "device-id", 0xffff);
149 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
150 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);
151
152 dev->cfg_size = pci_cfg_space_size(dev);
153
154 dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
155 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
156 dev->class = get_int_prop(node, "class-code", 0);
157 dev->revision = get_int_prop(node, "revision-id", 0);
158
159 pr_debug(" class: 0x%x\n", dev->class);
160 pr_debug(" revision: 0x%x\n", dev->revision);
161
162 dev->current_state = 4; /* unknown power state */
163 dev->error_state = pci_channel_io_normal;
164 dev->dma_mask = 0xffffffff;
165
166 if (!strcmp(type, "pci") || !strcmp(type, "pciex")) {
167 /* a PCI-PCI bridge */
168 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
169 dev->rom_base_reg = PCI_ROM_ADDRESS1;
170 } else if (!strcmp(type, "cardbus")) {
171 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
172 } else {
173 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
174 dev->rom_base_reg = PCI_ROM_ADDRESS;
175 /* Maybe do a default OF mapping here */
176 dev->irq = NO_IRQ;
177 }
178
179 pci_parse_of_addrs(node, dev);
180
181 pr_debug(" adding to system ...\n");
182
183 pci_device_add(dev, bus);
184
185 return dev;
186}
187EXPORT_SYMBOL(of_create_pci_dev);
188
189static void __devinit __of_scan_bus(struct device_node *node,
190 struct pci_bus *bus, int rescan_existing)
191{
192 struct device_node *child;
193 const u32 *reg;
194 int reglen, devfn;
195 struct pci_dev *dev;
196
197 pr_debug("of_scan_bus(%s) bus no %d... \n",
198 node->full_name, bus->number);
199
200 /* Scan direct children */
201 for_each_child_of_node(node, child) {
202 pr_debug(" * %s\n", child->full_name);
203 reg = of_get_property(child, "reg", &reglen);
204 if (reg == NULL || reglen < 20)
205 continue;
206 devfn = (reg[0] >> 8) & 0xff;
207
208 /* create a new pci_dev for this device */
209 dev = of_create_pci_dev(child, bus, devfn);
210 if (!dev)
211 continue;
212 pr_debug(" dev header type: %x\n", dev->hdr_type);
213 }
214
215 /* Apply all fixups necessary. We don't fixup the bus "self"
216 * for an existing bridge that is being rescanned
217 */
218 if (!rescan_existing)
219 pcibios_setup_bus_self(bus);
220 pcibios_setup_bus_devices(bus);
221
222 /* Now scan child busses */
223 list_for_each_entry(dev, &bus->devices, bus_list) {
224 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
225 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
226 struct device_node *child = pci_device_to_OF_node(dev);
227 if (dev)
228 of_scan_pci_bridge(child, dev);
229 }
230 }
231}
232
233void __devinit of_scan_bus(struct device_node *node,
234 struct pci_bus *bus)
235{
236 __of_scan_bus(node, bus, 0);
237}
238EXPORT_SYMBOL_GPL(of_scan_bus);
239
240void __devinit of_rescan_bus(struct device_node *node,
241 struct pci_bus *bus)
242{
243 __of_scan_bus(node, bus, 1);
244}
245EXPORT_SYMBOL_GPL(of_rescan_bus);
246
247void __devinit of_scan_pci_bridge(struct device_node *node,
248 struct pci_dev *dev)
249{
250 struct pci_bus *bus;
251 const u32 *busrange, *ranges;
252 int len, i, mode;
253 struct resource *res;
254 unsigned int flags;
255 u64 size;
256
257 pr_debug("of_scan_pci_bridge(%s)\n", node->full_name);
258
259 /* parse bus-range property */
260 busrange = of_get_property(node, "bus-range", &len);
261 if (busrange == NULL || len != 8) {
262 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n",
263 node->full_name);
264 return;
265 }
266 ranges = of_get_property(node, "ranges", &len);
267 if (ranges == NULL) {
268 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n",
269 node->full_name);
270 return;
271 }
272
273 bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
274 if (!bus) {
275 printk(KERN_ERR "Failed to create pci bus for %s\n",
276 node->full_name);
277 return;
278 }
279
280 bus->primary = dev->bus->number;
281 bus->subordinate = busrange[1];
282 bus->bridge_ctl = 0;
283 bus->sysdata = node;
284
285 /* parse ranges property */
286 /* PCI #address-cells == 3 and #size-cells == 2 always */
287 res = &dev->resource[PCI_BRIDGE_RESOURCES];
288 for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {
289 res->flags = 0;
290 bus->resource[i] = res;
291 ++res;
292 }
293 i = 1;
294 for (; len >= 32; len -= 32, ranges += 8) {
295 flags = pci_parse_of_flags(ranges[0], 1);
296 size = of_read_number(&ranges[6], 2);
297 if (flags == 0 || size == 0)
298 continue;
299 if (flags & IORESOURCE_IO) {
300 res = bus->resource[0];
301 if (res->flags) {
302 printk(KERN_ERR "PCI: ignoring extra I/O range"
303 " for bridge %s\n", node->full_name);
304 continue;
305 }
306 } else {
307 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
308 printk(KERN_ERR "PCI: too many memory ranges"
309 " for bridge %s\n", node->full_name);
310 continue;
311 }
312 res = bus->resource[i];
313 ++i;
314 }
315 res->start = of_read_number(&ranges[1], 2);
316 res->end = res->start + size - 1;
317 res->flags = flags;
318 }
319 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
320 bus->number);
321 pr_debug(" bus name: %s\n", bus->name);
322
323 mode = PCI_PROBE_NORMAL;
324 if (ppc_md.pci_probe_mode)
325 mode = ppc_md.pci_probe_mode(bus);
326 pr_debug(" probe mode: %d\n", mode);
327
328 if (mode == PCI_PROBE_DEVTREE)
329 of_scan_bus(node, bus);
330 else if (mode == PCI_PROBE_NORMAL)
331 pci_scan_child_bus(bus);
332}
333EXPORT_SYMBOL(of_scan_pci_bridge);
334
335void __devinit scan_phb(struct pci_controller *hose)
336{
337 struct pci_bus *bus;
338 struct device_node *node = hose->dn;
339 int mode;
340
341 pr_debug("PCI: Scanning PHB %s\n",
342 node ? node->full_name : "<NO NAME>");
343
344 /* Create an empty bus for the toplevel */
345 bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, node);
346 if (bus == NULL) {
347 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
348 hose->global_number);
349 return;
350 }
351 bus->secondary = hose->first_busno;
352 hose->bus = bus;
353
354 /* Get some IO space for the new PHB */
355 pcibios_map_io_space(bus);
356
357 /* Wire up PHB bus resources */
358 pcibios_setup_phb_resources(hose);
359
360 /* Get probe mode and perform scan */
361 mode = PCI_PROBE_NORMAL;
362 if (node && ppc_md.pci_probe_mode)
363 mode = ppc_md.pci_probe_mode(bus);
364 pr_debug(" probe mode: %d\n", mode);
365 if (mode == PCI_PROBE_DEVTREE) {
366 bus->subordinate = hose->last_busno;
367 of_scan_bus(node, bus);
368 }
369
370 if (mode == PCI_PROBE_NORMAL)
371 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
372}
373
374static int __init pcibios_init(void) 46static int __init pcibios_init(void)
375{ 47{
376 struct pci_controller *hose, *tmp; 48 struct pci_controller *hose, *tmp;
@@ -392,7 +64,7 @@ static int __init pcibios_init(void)
392 64
393 /* Scan all of the recorded PCI controllers. */ 65 /* Scan all of the recorded PCI controllers. */
394 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { 66 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
395 scan_phb(hose); 67 pcibios_scan_phb(hose, hose->dn);
396 pci_bus_add_devices(hose->bus); 68 pci_bus_add_devices(hose->bus);
397 } 69 }
398 70
@@ -526,6 +198,11 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus)
526} 198}
527EXPORT_SYMBOL_GPL(pcibios_map_io_space); 199EXPORT_SYMBOL_GPL(pcibios_map_io_space);
528 200
201void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
202{
203 pcibios_map_io_space(hose->bus);
204}
205
529#define IOBASE_BRIDGE_NUMBER 0 206#define IOBASE_BRIDGE_NUMBER 0
530#define IOBASE_MEMORY 1 207#define IOBASE_MEMORY 1
531#define IOBASE_IO 2 208#define IOBASE_IO 2
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
new file mode 100644
index 000000000000..7311fdfb9bf8
--- /dev/null
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -0,0 +1,359 @@
1/*
2 * Helper routines to scan the device tree for PCI devices and busses
3 *
4 * Migrated out of PowerPC architecture pci_64.c file by Grant Likely
5 * <grant.likely@secretlab.ca> so that these routines are available for
6 * 32 bit also.
7 *
8 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
9 * Rework, based on alpha PCI code.
10 * Copyright (c) 2009 Secret Lab Technologies Ltd.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * version 2 as published by the Free Software Foundation.
15 */
16
17#include <linux/pci.h>
18#include <asm/pci-bridge.h>
19#include <asm/prom.h>
20
21/**
22 * get_int_prop - Decode a u32 from a device tree property
23 */
24static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
25{
26 const u32 *prop;
27 int len;
28
29 prop = of_get_property(np, name, &len);
30 if (prop && len >= 4)
31 return *prop;
32 return def;
33}
34
35/**
36 * pci_parse_of_flags - Parse the flags cell of a device tree PCI address
37 * @addr0: value of 1st cell of a device tree PCI address.
38 * @bridge: Set this flag if the address is from a bridge 'ranges' property
39 */
40unsigned int pci_parse_of_flags(u32 addr0, int bridge)
41{
42 unsigned int flags = 0;
43
44 if (addr0 & 0x02000000) {
45 flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY;
46 flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64;
47 flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M;
48 if (addr0 & 0x40000000)
49 flags |= IORESOURCE_PREFETCH
50 | PCI_BASE_ADDRESS_MEM_PREFETCH;
51 /* Note: We don't know whether the ROM has been left enabled
52 * by the firmware or not. We mark it as disabled (ie, we do
53 * not set the IORESOURCE_ROM_ENABLE flag) for now rather than
54 * do a config space read, it will be force-enabled if needed
55 */
56 if (!bridge && (addr0 & 0xff) == 0x30)
57 flags |= IORESOURCE_READONLY;
58 } else if (addr0 & 0x01000000)
59 flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO;
60 if (flags)
61 flags |= IORESOURCE_SIZEALIGN;
62 return flags;
63}
64
65/**
66 * of_pci_parse_addrs - Parse PCI addresses assigned in the device tree node
67 * @node: device tree node for the PCI device
68 * @dev: pci_dev structure for the device
69 *
70 * This function parses the 'assigned-addresses' property of a PCI devices'
71 * device tree node and writes them into the associated pci_dev structure.
72 */
73static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
74{
75 u64 base, size;
76 unsigned int flags;
77 struct resource *res;
78 const u32 *addrs;
79 u32 i;
80 int proplen;
81
82 addrs = of_get_property(node, "assigned-addresses", &proplen);
83 if (!addrs)
84 return;
85 pr_debug(" parse addresses (%d bytes) @ %p\n", proplen, addrs);
86 for (; proplen >= 20; proplen -= 20, addrs += 5) {
87 flags = pci_parse_of_flags(addrs[0], 0);
88 if (!flags)
89 continue;
90 base = of_read_number(&addrs[1], 2);
91 size = of_read_number(&addrs[3], 2);
92 if (!size)
93 continue;
94 i = addrs[0] & 0xff;
95 pr_debug(" base: %llx, size: %llx, i: %x\n",
96 (unsigned long long)base,
97 (unsigned long long)size, i);
98
99 if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
100 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
101 } else if (i == dev->rom_base_reg) {
102 res = &dev->resource[PCI_ROM_RESOURCE];
103 flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
104 } else {
105 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
106 continue;
107 }
108 res->start = base;
109 res->end = base + size - 1;
110 res->flags = flags;
111 res->name = pci_name(dev);
112 }
113}
114
115/**
116 * of_create_pci_dev - Given a device tree node on a pci bus, create a pci_dev
117 * @node: device tree node pointer
118 * @bus: bus the device is sitting on
119 * @devfn: PCI function number, extracted from device tree by caller.
120 */
121struct pci_dev *of_create_pci_dev(struct device_node *node,
122 struct pci_bus *bus, int devfn)
123{
124 struct pci_dev *dev;
125 const char *type;
126
127 dev = alloc_pci_dev();
128 if (!dev)
129 return NULL;
130 type = of_get_property(node, "device_type", NULL);
131 if (type == NULL)
132 type = "";
133
134 pr_debug(" create device, devfn: %x, type: %s\n", devfn, type);
135
136 dev->bus = bus;
137 dev->sysdata = node;
138 dev->dev.parent = bus->bridge;
139 dev->dev.bus = &pci_bus_type;
140 dev->devfn = devfn;
141 dev->multifunction = 0; /* maybe a lie? */
142 dev->needs_freset = 0; /* pcie fundamental reset required */
143
144 dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
145 dev->device = get_int_prop(node, "device-id", 0xffff);
146 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
147 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);
148
149 dev->cfg_size = pci_cfg_space_size(dev);
150
151 dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
152 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
153 dev->class = get_int_prop(node, "class-code", 0);
154 dev->revision = get_int_prop(node, "revision-id", 0);
155
156 pr_debug(" class: 0x%x\n", dev->class);
157 pr_debug(" revision: 0x%x\n", dev->revision);
158
159 dev->current_state = 4; /* unknown power state */
160 dev->error_state = pci_channel_io_normal;
161 dev->dma_mask = 0xffffffff;
162
163 if (!strcmp(type, "pci") || !strcmp(type, "pciex")) {
164 /* a PCI-PCI bridge */
165 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
166 dev->rom_base_reg = PCI_ROM_ADDRESS1;
167 } else if (!strcmp(type, "cardbus")) {
168 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
169 } else {
170 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
171 dev->rom_base_reg = PCI_ROM_ADDRESS;
172 /* Maybe do a default OF mapping here */
173 dev->irq = NO_IRQ;
174 }
175
176 of_pci_parse_addrs(node, dev);
177
178 pr_debug(" adding to system ...\n");
179
180 pci_device_add(dev, bus);
181
182 return dev;
183}
184EXPORT_SYMBOL(of_create_pci_dev);
185
186/**
187 * of_scan_pci_bridge - Set up a PCI bridge and scan for child nodes
188 * @node: device tree node of bridge
189 * @dev: pci_dev structure for the bridge
190 *
191 * of_scan_bus() calls this routine for each PCI bridge that it finds, and
192 * this routine in turn call of_scan_bus() recusively to scan for more child
193 * devices.
194 */
195void __devinit of_scan_pci_bridge(struct device_node *node,
196 struct pci_dev *dev)
197{
198 struct pci_bus *bus;
199 const u32 *busrange, *ranges;
200 int len, i, mode;
201 struct resource *res;
202 unsigned int flags;
203 u64 size;
204
205 pr_debug("of_scan_pci_bridge(%s)\n", node->full_name);
206
207 /* parse bus-range property */
208 busrange = of_get_property(node, "bus-range", &len);
209 if (busrange == NULL || len != 8) {
210 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n",
211 node->full_name);
212 return;
213 }
214 ranges = of_get_property(node, "ranges", &len);
215 if (ranges == NULL) {
216 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n",
217 node->full_name);
218 return;
219 }
220
221 bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
222 if (!bus) {
223 printk(KERN_ERR "Failed to create pci bus for %s\n",
224 node->full_name);
225 return;
226 }
227
228 bus->primary = dev->bus->number;
229 bus->subordinate = busrange[1];
230 bus->bridge_ctl = 0;
231 bus->sysdata = node;
232
233 /* parse ranges property */
234 /* PCI #address-cells == 3 and #size-cells == 2 always */
235 res = &dev->resource[PCI_BRIDGE_RESOURCES];
236 for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {
237 res->flags = 0;
238 bus->resource[i] = res;
239 ++res;
240 }
241 i = 1;
242 for (; len >= 32; len -= 32, ranges += 8) {
243 flags = pci_parse_of_flags(ranges[0], 1);
244 size = of_read_number(&ranges[6], 2);
245 if (flags == 0 || size == 0)
246 continue;
247 if (flags & IORESOURCE_IO) {
248 res = bus->resource[0];
249 if (res->flags) {
250 printk(KERN_ERR "PCI: ignoring extra I/O range"
251 " for bridge %s\n", node->full_name);
252 continue;
253 }
254 } else {
255 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
256 printk(KERN_ERR "PCI: too many memory ranges"
257 " for bridge %s\n", node->full_name);
258 continue;
259 }
260 res = bus->resource[i];
261 ++i;
262 }
263 res->start = of_read_number(&ranges[1], 2);
264 res->end = res->start + size - 1;
265 res->flags = flags;
266 }
267 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
268 bus->number);
269 pr_debug(" bus name: %s\n", bus->name);
270
271 mode = PCI_PROBE_NORMAL;
272 if (ppc_md.pci_probe_mode)
273 mode = ppc_md.pci_probe_mode(bus);
274 pr_debug(" probe mode: %d\n", mode);
275
276 if (mode == PCI_PROBE_DEVTREE)
277 of_scan_bus(node, bus);
278 else if (mode == PCI_PROBE_NORMAL)
279 pci_scan_child_bus(bus);
280}
281EXPORT_SYMBOL(of_scan_pci_bridge);
282
283/**
284 * __of_scan_bus - given a PCI bus node, setup bus and scan for child devices
285 * @node: device tree node for the PCI bus
286 * @bus: pci_bus structure for the PCI bus
287 * @rescan_existing: Flag indicating bus has already been set up
288 */
289static void __devinit __of_scan_bus(struct device_node *node,
290 struct pci_bus *bus, int rescan_existing)
291{
292 struct device_node *child;
293 const u32 *reg;
294 int reglen, devfn;
295 struct pci_dev *dev;
296
297 pr_debug("of_scan_bus(%s) bus no %d... \n",
298 node->full_name, bus->number);
299
300 /* Scan direct children */
301 for_each_child_of_node(node, child) {
302 pr_debug(" * %s\n", child->full_name);
303 reg = of_get_property(child, "reg", &reglen);
304 if (reg == NULL || reglen < 20)
305 continue;
306 devfn = (reg[0] >> 8) & 0xff;
307
308 /* create a new pci_dev for this device */
309 dev = of_create_pci_dev(child, bus, devfn);
310 if (!dev)
311 continue;
312 pr_debug(" dev header type: %x\n", dev->hdr_type);
313 }
314
315 /* Apply all fixups necessary. We don't fixup the bus "self"
316 * for an existing bridge that is being rescanned
317 */
318 if (!rescan_existing)
319 pcibios_setup_bus_self(bus);
320 pcibios_setup_bus_devices(bus);
321
322 /* Now scan child busses */
323 list_for_each_entry(dev, &bus->devices, bus_list) {
324 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
325 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
326 struct device_node *child = pci_device_to_OF_node(dev);
327 if (dev)
328 of_scan_pci_bridge(child, dev);
329 }
330 }
331}
332
333/**
334 * of_scan_bus - given a PCI bus node, setup bus and scan for child devices
335 * @node: device tree node for the PCI bus
336 * @bus: pci_bus structure for the PCI bus
337 */
338void __devinit of_scan_bus(struct device_node *node,
339 struct pci_bus *bus)
340{
341 __of_scan_bus(node, bus, 0);
342}
343EXPORT_SYMBOL_GPL(of_scan_bus);
344
345/**
346 * of_rescan_bus - given a PCI bus node, scan for child devices
347 * @node: device tree node for the PCI bus
348 * @bus: pci_bus structure for the PCI bus
349 *
350 * Same as of_scan_bus, but for a pci_bus structure that has already been
351 * setup.
352 */
353void __devinit of_rescan_bus(struct device_node *node,
354 struct pci_bus *bus)
355{
356 __of_scan_bus(node, bus, 1);
357}
358EXPORT_SYMBOL_GPL(of_rescan_bus);
359
diff --git a/arch/powerpc/kernel/perf_counter.c b/arch/powerpc/kernel/perf_counter.c
index 70e1f57f7dd8..7ceefaf3a7f5 100644
--- a/arch/powerpc/kernel/perf_counter.c
+++ b/arch/powerpc/kernel/perf_counter.c
@@ -32,6 +32,9 @@ struct cpu_hw_counters {
32 unsigned long mmcr[3]; 32 unsigned long mmcr[3];
33 struct perf_counter *limited_counter[MAX_LIMITED_HWCOUNTERS]; 33 struct perf_counter *limited_counter[MAX_LIMITED_HWCOUNTERS];
34 u8 limited_hwidx[MAX_LIMITED_HWCOUNTERS]; 34 u8 limited_hwidx[MAX_LIMITED_HWCOUNTERS];
35 u64 alternatives[MAX_HWCOUNTERS][MAX_EVENT_ALTERNATIVES];
36 unsigned long amasks[MAX_HWCOUNTERS][MAX_EVENT_ALTERNATIVES];
37 unsigned long avalues[MAX_HWCOUNTERS][MAX_EVENT_ALTERNATIVES];
35}; 38};
36DEFINE_PER_CPU(struct cpu_hw_counters, cpu_hw_counters); 39DEFINE_PER_CPU(struct cpu_hw_counters, cpu_hw_counters);
37 40
@@ -62,7 +65,6 @@ static inline unsigned long perf_ip_adjust(struct pt_regs *regs)
62{ 65{
63 return 0; 66 return 0;
64} 67}
65static inline void perf_set_pmu_inuse(int inuse) { }
66static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp) { } 68static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp) { }
67static inline u32 perf_get_misc_flags(struct pt_regs *regs) 69static inline u32 perf_get_misc_flags(struct pt_regs *regs)
68{ 70{
@@ -93,11 +95,6 @@ static inline unsigned long perf_ip_adjust(struct pt_regs *regs)
93 return 0; 95 return 0;
94} 96}
95 97
96static inline void perf_set_pmu_inuse(int inuse)
97{
98 get_lppaca()->pmcregs_in_use = inuse;
99}
100
101/* 98/*
102 * The user wants a data address recorded. 99 * The user wants a data address recorded.
103 * If we're not doing instruction sampling, give them the SDAR 100 * If we're not doing instruction sampling, give them the SDAR
@@ -245,13 +242,11 @@ static void write_pmc(int idx, unsigned long val)
245 * and see if any combination of alternative codes is feasible. 242 * and see if any combination of alternative codes is feasible.
246 * The feasible set is returned in event[]. 243 * The feasible set is returned in event[].
247 */ 244 */
248static int power_check_constraints(u64 event[], unsigned int cflags[], 245static int power_check_constraints(struct cpu_hw_counters *cpuhw,
246 u64 event[], unsigned int cflags[],
249 int n_ev) 247 int n_ev)
250{ 248{
251 unsigned long mask, value, nv; 249 unsigned long mask, value, nv;
252 u64 alternatives[MAX_HWCOUNTERS][MAX_EVENT_ALTERNATIVES];
253 unsigned long amasks[MAX_HWCOUNTERS][MAX_EVENT_ALTERNATIVES];
254 unsigned long avalues[MAX_HWCOUNTERS][MAX_EVENT_ALTERNATIVES];
255 unsigned long smasks[MAX_HWCOUNTERS], svalues[MAX_HWCOUNTERS]; 250 unsigned long smasks[MAX_HWCOUNTERS], svalues[MAX_HWCOUNTERS];
256 int n_alt[MAX_HWCOUNTERS], choice[MAX_HWCOUNTERS]; 251 int n_alt[MAX_HWCOUNTERS], choice[MAX_HWCOUNTERS];
257 int i, j; 252 int i, j;
@@ -266,21 +261,23 @@ static int power_check_constraints(u64 event[], unsigned int cflags[],
266 if ((cflags[i] & PPMU_LIMITED_PMC_REQD) 261 if ((cflags[i] & PPMU_LIMITED_PMC_REQD)
267 && !ppmu->limited_pmc_event(event[i])) { 262 && !ppmu->limited_pmc_event(event[i])) {
268 ppmu->get_alternatives(event[i], cflags[i], 263 ppmu->get_alternatives(event[i], cflags[i],
269 alternatives[i]); 264 cpuhw->alternatives[i]);
270 event[i] = alternatives[i][0]; 265 event[i] = cpuhw->alternatives[i][0];
271 } 266 }
272 if (ppmu->get_constraint(event[i], &amasks[i][0], 267 if (ppmu->get_constraint(event[i], &cpuhw->amasks[i][0],
273 &avalues[i][0])) 268 &cpuhw->avalues[i][0]))
274 return -1; 269 return -1;
275 } 270 }
276 value = mask = 0; 271 value = mask = 0;
277 for (i = 0; i < n_ev; ++i) { 272 for (i = 0; i < n_ev; ++i) {
278 nv = (value | avalues[i][0]) + (value & avalues[i][0] & addf); 273 nv = (value | cpuhw->avalues[i][0]) +
274 (value & cpuhw->avalues[i][0] & addf);
279 if ((((nv + tadd) ^ value) & mask) != 0 || 275 if ((((nv + tadd) ^ value) & mask) != 0 ||
280 (((nv + tadd) ^ avalues[i][0]) & amasks[i][0]) != 0) 276 (((nv + tadd) ^ cpuhw->avalues[i][0]) &
277 cpuhw->amasks[i][0]) != 0)
281 break; 278 break;
282 value = nv; 279 value = nv;
283 mask |= amasks[i][0]; 280 mask |= cpuhw->amasks[i][0];
284 } 281 }
285 if (i == n_ev) 282 if (i == n_ev)
286 return 0; /* all OK */ 283 return 0; /* all OK */
@@ -291,10 +288,11 @@ static int power_check_constraints(u64 event[], unsigned int cflags[],
291 for (i = 0; i < n_ev; ++i) { 288 for (i = 0; i < n_ev; ++i) {
292 choice[i] = 0; 289 choice[i] = 0;
293 n_alt[i] = ppmu->get_alternatives(event[i], cflags[i], 290 n_alt[i] = ppmu->get_alternatives(event[i], cflags[i],
294 alternatives[i]); 291 cpuhw->alternatives[i]);
295 for (j = 1; j < n_alt[i]; ++j) 292 for (j = 1; j < n_alt[i]; ++j)
296 ppmu->get_constraint(alternatives[i][j], 293 ppmu->get_constraint(cpuhw->alternatives[i][j],
297 &amasks[i][j], &avalues[i][j]); 294 &cpuhw->amasks[i][j],
295 &cpuhw->avalues[i][j]);
298 } 296 }
299 297
300 /* enumerate all possibilities and see if any will work */ 298 /* enumerate all possibilities and see if any will work */
@@ -313,11 +311,11 @@ static int power_check_constraints(u64 event[], unsigned int cflags[],
313 * where k > j, will satisfy the constraints. 311 * where k > j, will satisfy the constraints.
314 */ 312 */
315 while (++j < n_alt[i]) { 313 while (++j < n_alt[i]) {
316 nv = (value | avalues[i][j]) + 314 nv = (value | cpuhw->avalues[i][j]) +
317 (value & avalues[i][j] & addf); 315 (value & cpuhw->avalues[i][j] & addf);
318 if ((((nv + tadd) ^ value) & mask) == 0 && 316 if ((((nv + tadd) ^ value) & mask) == 0 &&
319 (((nv + tadd) ^ avalues[i][j]) 317 (((nv + tadd) ^ cpuhw->avalues[i][j])
320 & amasks[i][j]) == 0) 318 & cpuhw->amasks[i][j]) == 0)
321 break; 319 break;
322 } 320 }
323 if (j >= n_alt[i]) { 321 if (j >= n_alt[i]) {
@@ -339,7 +337,7 @@ static int power_check_constraints(u64 event[], unsigned int cflags[],
339 svalues[i] = value; 337 svalues[i] = value;
340 smasks[i] = mask; 338 smasks[i] = mask;
341 value = nv; 339 value = nv;
342 mask |= amasks[i][j]; 340 mask |= cpuhw->amasks[i][j];
343 ++i; 341 ++i;
344 j = -1; 342 j = -1;
345 } 343 }
@@ -347,7 +345,7 @@ static int power_check_constraints(u64 event[], unsigned int cflags[],
347 345
348 /* OK, we have a feasible combination, tell the caller the solution */ 346 /* OK, we have a feasible combination, tell the caller the solution */
349 for (i = 0; i < n_ev; ++i) 347 for (i = 0; i < n_ev; ++i)
350 event[i] = alternatives[i][choice[i]]; 348 event[i] = cpuhw->alternatives[i][choice[i]];
351 return 0; 349 return 0;
352} 350}
353 351
@@ -531,8 +529,7 @@ void hw_perf_disable(void)
531 * Check if we ever enabled the PMU on this cpu. 529 * Check if we ever enabled the PMU on this cpu.
532 */ 530 */
533 if (!cpuhw->pmcs_enabled) { 531 if (!cpuhw->pmcs_enabled) {
534 if (ppc_md.enable_pmcs) 532 ppc_enable_pmcs();
535 ppc_md.enable_pmcs();
536 cpuhw->pmcs_enabled = 1; 533 cpuhw->pmcs_enabled = 1;
537 } 534 }
538 535
@@ -594,7 +591,7 @@ void hw_perf_enable(void)
594 mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE); 591 mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE);
595 mtspr(SPRN_MMCR1, cpuhw->mmcr[1]); 592 mtspr(SPRN_MMCR1, cpuhw->mmcr[1]);
596 if (cpuhw->n_counters == 0) 593 if (cpuhw->n_counters == 0)
597 perf_set_pmu_inuse(0); 594 ppc_set_pmu_inuse(0);
598 goto out_enable; 595 goto out_enable;
599 } 596 }
600 597
@@ -627,7 +624,7 @@ void hw_perf_enable(void)
627 * bit set and set the hardware counters to their initial values. 624 * bit set and set the hardware counters to their initial values.
628 * Then unfreeze the counters. 625 * Then unfreeze the counters.
629 */ 626 */
630 perf_set_pmu_inuse(1); 627 ppc_set_pmu_inuse(1);
631 mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE); 628 mtspr(SPRN_MMCRA, cpuhw->mmcr[2] & ~MMCRA_SAMPLE_ENABLE);
632 mtspr(SPRN_MMCR1, cpuhw->mmcr[1]); 629 mtspr(SPRN_MMCR1, cpuhw->mmcr[1]);
633 mtspr(SPRN_MMCR0, (cpuhw->mmcr[0] & ~(MMCR0_PMC1CE | MMCR0_PMCjCE)) 630 mtspr(SPRN_MMCR0, (cpuhw->mmcr[0] & ~(MMCR0_PMC1CE | MMCR0_PMCjCE))
@@ -752,7 +749,7 @@ int hw_perf_group_sched_in(struct perf_counter *group_leader,
752 return -EAGAIN; 749 return -EAGAIN;
753 if (check_excludes(cpuhw->counter, cpuhw->flags, n0, n)) 750 if (check_excludes(cpuhw->counter, cpuhw->flags, n0, n))
754 return -EAGAIN; 751 return -EAGAIN;
755 i = power_check_constraints(cpuhw->events, cpuhw->flags, n + n0); 752 i = power_check_constraints(cpuhw, cpuhw->events, cpuhw->flags, n + n0);
756 if (i < 0) 753 if (i < 0)
757 return -EAGAIN; 754 return -EAGAIN;
758 cpuhw->n_counters = n0 + n; 755 cpuhw->n_counters = n0 + n;
@@ -807,7 +804,7 @@ static int power_pmu_enable(struct perf_counter *counter)
807 cpuhw->flags[n0] = counter->hw.counter_base; 804 cpuhw->flags[n0] = counter->hw.counter_base;
808 if (check_excludes(cpuhw->counter, cpuhw->flags, n0, 1)) 805 if (check_excludes(cpuhw->counter, cpuhw->flags, n0, 1))
809 goto out; 806 goto out;
810 if (power_check_constraints(cpuhw->events, cpuhw->flags, n0 + 1)) 807 if (power_check_constraints(cpuhw, cpuhw->events, cpuhw->flags, n0 + 1))
811 goto out; 808 goto out;
812 809
813 counter->hw.config = cpuhw->events[n0]; 810 counter->hw.config = cpuhw->events[n0];
@@ -1012,6 +1009,7 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
1012 unsigned int cflags[MAX_HWCOUNTERS]; 1009 unsigned int cflags[MAX_HWCOUNTERS];
1013 int n; 1010 int n;
1014 int err; 1011 int err;
1012 struct cpu_hw_counters *cpuhw;
1015 1013
1016 if (!ppmu) 1014 if (!ppmu)
1017 return ERR_PTR(-ENXIO); 1015 return ERR_PTR(-ENXIO);
@@ -1090,7 +1088,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
1090 cflags[n] = flags; 1088 cflags[n] = flags;
1091 if (check_excludes(ctrs, cflags, n, 1)) 1089 if (check_excludes(ctrs, cflags, n, 1))
1092 return ERR_PTR(-EINVAL); 1090 return ERR_PTR(-EINVAL);
1093 if (power_check_constraints(events, cflags, n + 1)) 1091
1092 cpuhw = &get_cpu_var(cpu_hw_counters);
1093 err = power_check_constraints(cpuhw, events, cflags, n + 1);
1094 put_cpu_var(cpu_hw_counters);
1095 if (err)
1094 return ERR_PTR(-EINVAL); 1096 return ERR_PTR(-EINVAL);
1095 1097
1096 counter->hw.config = events[n]; 1098 counter->hw.config = events[n];
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 892a9f2e6d76..0a3216433051 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -284,14 +284,13 @@ int set_dabr(unsigned long dabr)
284 return ppc_md.set_dabr(dabr); 284 return ppc_md.set_dabr(dabr);
285 285
286 /* XXX should we have a CPU_FTR_HAS_DABR ? */ 286 /* XXX should we have a CPU_FTR_HAS_DABR ? */
287#if defined(CONFIG_PPC64) || defined(CONFIG_6xx)
288 mtspr(SPRN_DABR, dabr);
289#endif
290
291#if defined(CONFIG_BOOKE) 287#if defined(CONFIG_BOOKE)
292 mtspr(SPRN_DAC1, dabr); 288 mtspr(SPRN_DAC1, dabr);
289#elif defined(CONFIG_PPC_BOOK3S)
290 mtspr(SPRN_DABR, dabr);
293#endif 291#endif
294 292
293
295 return 0; 294 return 0;
296} 295}
297 296
@@ -372,15 +371,16 @@ struct task_struct *__switch_to(struct task_struct *prev,
372 371
373#endif /* CONFIG_SMP */ 372#endif /* CONFIG_SMP */
374 373
375 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr))
376 set_dabr(new->thread.dabr);
377
378#if defined(CONFIG_BOOKE) 374#if defined(CONFIG_BOOKE)
379 /* If new thread DAC (HW breakpoint) is the same then leave it */ 375 /* If new thread DAC (HW breakpoint) is the same then leave it */
380 if (new->thread.dabr) 376 if (new->thread.dabr)
381 set_dabr(new->thread.dabr); 377 set_dabr(new->thread.dabr);
378#else
379 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr))
380 set_dabr(new->thread.dabr);
382#endif 381#endif
383 382
383
384 new_thread = &new->thread; 384 new_thread = &new->thread;
385 old_thread = &current->thread; 385 old_thread = &current->thread;
386 386
@@ -664,6 +664,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
664 sp_vsid |= SLB_VSID_KERNEL | llp; 664 sp_vsid |= SLB_VSID_KERNEL | llp;
665 p->thread.ksp_vsid = sp_vsid; 665 p->thread.ksp_vsid = sp_vsid;
666 } 666 }
667#endif /* CONFIG_PPC_STD_MMU_64 */
667 668
668 /* 669 /*
669 * The PPC64 ABI makes use of a TOC to contain function 670 * The PPC64 ABI makes use of a TOC to contain function
@@ -671,6 +672,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
671 * to the TOC entry. The first entry is a pointer to the actual 672 * to the TOC entry. The first entry is a pointer to the actual
672 * function. 673 * function.
673 */ 674 */
675#ifdef CONFIG_PPC64
674 kregs->nip = *((unsigned long *)ret_from_fork); 676 kregs->nip = *((unsigned long *)ret_from_fork);
675#else 677#else
676 kregs->nip = (unsigned long)ret_from_fork; 678 kregs->nip = (unsigned long)ret_from_fork;
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index a538824616fd..864334b337a3 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -190,6 +190,8 @@ static int __initdata of_platform;
190 190
191static char __initdata prom_cmd_line[COMMAND_LINE_SIZE]; 191static char __initdata prom_cmd_line[COMMAND_LINE_SIZE];
192 192
193static unsigned long __initdata prom_memory_limit;
194
193static unsigned long __initdata alloc_top; 195static unsigned long __initdata alloc_top;
194static unsigned long __initdata alloc_top_high; 196static unsigned long __initdata alloc_top_high;
195static unsigned long __initdata alloc_bottom; 197static unsigned long __initdata alloc_bottom;
@@ -484,6 +486,67 @@ static int __init prom_setprop(phandle node, const char *nodename,
484 return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd); 486 return call_prom("interpret", 1, 1, (u32)(unsigned long) cmd);
485} 487}
486 488
489/* We can't use the standard versions because of RELOC headaches. */
490#define isxdigit(c) (('0' <= (c) && (c) <= '9') \
491 || ('a' <= (c) && (c) <= 'f') \
492 || ('A' <= (c) && (c) <= 'F'))
493
494#define isdigit(c) ('0' <= (c) && (c) <= '9')
495#define islower(c) ('a' <= (c) && (c) <= 'z')
496#define toupper(c) (islower(c) ? ((c) - 'a' + 'A') : (c))
497
498unsigned long prom_strtoul(const char *cp, const char **endp)
499{
500 unsigned long result = 0, base = 10, value;
501
502 if (*cp == '0') {
503 base = 8;
504 cp++;
505 if (toupper(*cp) == 'X') {
506 cp++;
507 base = 16;
508 }
509 }
510
511 while (isxdigit(*cp) &&
512 (value = isdigit(*cp) ? *cp - '0' : toupper(*cp) - 'A' + 10) < base) {
513 result = result * base + value;
514 cp++;
515 }
516
517 if (endp)
518 *endp = cp;
519
520 return result;
521}
522
523unsigned long prom_memparse(const char *ptr, const char **retptr)
524{
525 unsigned long ret = prom_strtoul(ptr, retptr);
526 int shift = 0;
527
528 /*
529 * We can't use a switch here because GCC *may* generate a
530 * jump table which won't work, because we're not running at
531 * the address we're linked at.
532 */
533 if ('G' == **retptr || 'g' == **retptr)
534 shift = 30;
535
536 if ('M' == **retptr || 'm' == **retptr)
537 shift = 20;
538
539 if ('K' == **retptr || 'k' == **retptr)
540 shift = 10;
541
542 if (shift) {
543 ret <<= shift;
544 (*retptr)++;
545 }
546
547 return ret;
548}
549
487/* 550/*
488 * Early parsing of the command line passed to the kernel, used for 551 * Early parsing of the command line passed to the kernel, used for
489 * "mem=x" and the options that affect the iommu 552 * "mem=x" and the options that affect the iommu
@@ -491,9 +554,8 @@ static int __init prom_setprop(phandle node, const char *nodename,
491static void __init early_cmdline_parse(void) 554static void __init early_cmdline_parse(void)
492{ 555{
493 struct prom_t *_prom = &RELOC(prom); 556 struct prom_t *_prom = &RELOC(prom);
494#ifdef CONFIG_PPC64
495 const char *opt; 557 const char *opt;
496#endif 558
497 char *p; 559 char *p;
498 int l = 0; 560 int l = 0;
499 561
@@ -521,6 +583,15 @@ static void __init early_cmdline_parse(void)
521 RELOC(prom_iommu_force_on) = 1; 583 RELOC(prom_iommu_force_on) = 1;
522 } 584 }
523#endif 585#endif
586 opt = strstr(RELOC(prom_cmd_line), RELOC("mem="));
587 if (opt) {
588 opt += 4;
589 RELOC(prom_memory_limit) = prom_memparse(opt, (const char **)&opt);
590#ifdef CONFIG_PPC64
591 /* Align to 16 MB == size of ppc64 large page */
592 RELOC(prom_memory_limit) = ALIGN(RELOC(prom_memory_limit), 0x1000000);
593#endif
594 }
524} 595}
525 596
526#ifdef CONFIG_PPC_PSERIES 597#ifdef CONFIG_PPC_PSERIES
@@ -1027,6 +1098,29 @@ static void __init prom_init_mem(void)
1027 } 1098 }
1028 1099
1029 /* 1100 /*
1101 * If prom_memory_limit is set we reduce the upper limits *except* for
1102 * alloc_top_high. This must be the real top of RAM so we can put
1103 * TCE's up there.
1104 */
1105
1106 RELOC(alloc_top_high) = RELOC(ram_top);
1107
1108 if (RELOC(prom_memory_limit)) {
1109 if (RELOC(prom_memory_limit) <= RELOC(alloc_bottom)) {
1110 prom_printf("Ignoring mem=%x <= alloc_bottom.\n",
1111 RELOC(prom_memory_limit));
1112 RELOC(prom_memory_limit) = 0;
1113 } else if (RELOC(prom_memory_limit) >= RELOC(ram_top)) {
1114 prom_printf("Ignoring mem=%x >= ram_top.\n",
1115 RELOC(prom_memory_limit));
1116 RELOC(prom_memory_limit) = 0;
1117 } else {
1118 RELOC(ram_top) = RELOC(prom_memory_limit);
1119 RELOC(rmo_top) = min(RELOC(rmo_top), RELOC(prom_memory_limit));
1120 }
1121 }
1122
1123 /*
1030 * Setup our top alloc point, that is top of RMO or top of 1124 * Setup our top alloc point, that is top of RMO or top of
1031 * segment 0 when running non-LPAR. 1125 * segment 0 when running non-LPAR.
1032 * Some RS64 machines have buggy firmware where claims up at 1126 * Some RS64 machines have buggy firmware where claims up at
@@ -1041,6 +1135,7 @@ static void __init prom_init_mem(void)
1041 RELOC(alloc_top_high) = RELOC(ram_top); 1135 RELOC(alloc_top_high) = RELOC(ram_top);
1042 1136
1043 prom_printf("memory layout at init:\n"); 1137 prom_printf("memory layout at init:\n");
1138 prom_printf(" memory_limit : %x (16 MB aligned)\n", RELOC(prom_memory_limit));
1044 prom_printf(" alloc_bottom : %x\n", RELOC(alloc_bottom)); 1139 prom_printf(" alloc_bottom : %x\n", RELOC(alloc_bottom));
1045 prom_printf(" alloc_top : %x\n", RELOC(alloc_top)); 1140 prom_printf(" alloc_top : %x\n", RELOC(alloc_top));
1046 prom_printf(" alloc_top_hi : %x\n", RELOC(alloc_top_high)); 1141 prom_printf(" alloc_top_hi : %x\n", RELOC(alloc_top_high));
@@ -1259,10 +1354,6 @@ static void __init prom_initialize_tce_table(void)
1259 * 1354 *
1260 * -- Cort 1355 * -- Cort
1261 */ 1356 */
1262extern char __secondary_hold;
1263extern unsigned long __secondary_hold_spinloop;
1264extern unsigned long __secondary_hold_acknowledge;
1265
1266/* 1357/*
1267 * We want to reference the copy of __secondary_hold_* in the 1358 * We want to reference the copy of __secondary_hold_* in the
1268 * 0 - 0x100 address range 1359 * 0 - 0x100 address range
@@ -2399,6 +2490,10 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2399 /* 2490 /*
2400 * Fill in some infos for use by the kernel later on 2491 * Fill in some infos for use by the kernel later on
2401 */ 2492 */
2493 if (RELOC(prom_memory_limit))
2494 prom_setprop(_prom->chosen, "/chosen", "linux,memory-limit",
2495 &RELOC(prom_memory_limit),
2496 sizeof(prom_memory_limit));
2402#ifdef CONFIG_PPC64 2497#ifdef CONFIG_PPC64
2403 if (RELOC(prom_iommu_off)) 2498 if (RELOC(prom_iommu_off))
2404 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off", 2499 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off",
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index c434823b8c83..bf90361bb70f 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -39,6 +39,7 @@
39#include <asm/smp.h> 39#include <asm/smp.h>
40#include <asm/atomic.h> 40#include <asm/atomic.h>
41#include <asm/time.h> 41#include <asm/time.h>
42#include <asm/mmu.h>
42 43
43struct rtas_t rtas = { 44struct rtas_t rtas = {
44 .lock = __RAW_SPIN_LOCK_UNLOCKED 45 .lock = __RAW_SPIN_LOCK_UNLOCKED
@@ -713,6 +714,7 @@ static void rtas_percpu_suspend_me(void *info)
713{ 714{
714 long rc = H_SUCCESS; 715 long rc = H_SUCCESS;
715 unsigned long msr_save; 716 unsigned long msr_save;
717 u16 slb_size = mmu_slb_size;
716 int cpu; 718 int cpu;
717 struct rtas_suspend_me_data *data = 719 struct rtas_suspend_me_data *data =
718 (struct rtas_suspend_me_data *)info; 720 (struct rtas_suspend_me_data *)info;
@@ -735,13 +737,16 @@ static void rtas_percpu_suspend_me(void *info)
735 /* All other cpus are in H_JOIN, this cpu does 737 /* All other cpus are in H_JOIN, this cpu does
736 * the suspend. 738 * the suspend.
737 */ 739 */
740 slb_set_size(SLB_MIN_SIZE);
738 printk(KERN_DEBUG "calling ibm,suspend-me on cpu %i\n", 741 printk(KERN_DEBUG "calling ibm,suspend-me on cpu %i\n",
739 smp_processor_id()); 742 smp_processor_id());
740 data->error = rtas_call(data->token, 0, 1, NULL); 743 data->error = rtas_call(data->token, 0, 1, NULL);
741 744
742 if (data->error) 745 if (data->error) {
743 printk(KERN_DEBUG "ibm,suspend-me returned %d\n", 746 printk(KERN_DEBUG "ibm,suspend-me returned %d\n",
744 data->error); 747 data->error);
748 slb_set_size(slb_size);
749 }
745 } else { 750 } else {
746 printk(KERN_ERR "H_JOIN on cpu %i failed with rc = %ld\n", 751 printk(KERN_ERR "H_JOIN on cpu %i failed with rc = %ld\n",
747 smp_processor_id(), rc); 752 smp_processor_id(), rc);
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index e1e3059cf34b..53bcf3d792db 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -210,6 +210,14 @@ void nvram_write_byte(unsigned char val, int addr)
210} 210}
211EXPORT_SYMBOL(nvram_write_byte); 211EXPORT_SYMBOL(nvram_write_byte);
212 212
213ssize_t nvram_get_size(void)
214{
215 if (ppc_md.nvram_size)
216 return ppc_md.nvram_size();
217 return -1;
218}
219EXPORT_SYMBOL(nvram_get_size);
220
213void nvram_sync(void) 221void nvram_sync(void)
214{ 222{
215 if (ppc_md.nvram_sync) 223 if (ppc_md.nvram_sync)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 1f6816003ebe..797ea95aae2e 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -57,11 +57,13 @@
57#include <asm/cache.h> 57#include <asm/cache.h>
58#include <asm/page.h> 58#include <asm/page.h>
59#include <asm/mmu.h> 59#include <asm/mmu.h>
60#include <asm/mmu-hash64.h>
60#include <asm/firmware.h> 61#include <asm/firmware.h>
61#include <asm/xmon.h> 62#include <asm/xmon.h>
62#include <asm/udbg.h> 63#include <asm/udbg.h>
63#include <asm/kexec.h> 64#include <asm/kexec.h>
64#include <asm/swiotlb.h> 65#include <asm/swiotlb.h>
66#include <asm/mmu_context.h>
65 67
66#include "setup.h" 68#include "setup.h"
67 69
@@ -142,11 +144,14 @@ early_param("smt-enabled", early_smt_enabled);
142#define check_smt_enabled() 144#define check_smt_enabled()
143#endif /* CONFIG_SMP */ 145#endif /* CONFIG_SMP */
144 146
145/* Put the paca pointer into r13 and SPRG3 */ 147/* Put the paca pointer into r13 and SPRG_PACA */
146void __init setup_paca(int cpu) 148void __init setup_paca(int cpu)
147{ 149{
148 local_paca = &paca[cpu]; 150 local_paca = &paca[cpu];
149 mtspr(SPRN_SPRG3, local_paca); 151 mtspr(SPRN_SPRG_PACA, local_paca);
152#ifdef CONFIG_PPC_BOOK3E
153 mtspr(SPRN_SPRG_TLB_EXFRAME, local_paca->extlb);
154#endif
150} 155}
151 156
152/* 157/*
@@ -230,9 +235,6 @@ void early_setup_secondary(void)
230#endif /* CONFIG_SMP */ 235#endif /* CONFIG_SMP */
231 236
232#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) 237#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
233extern unsigned long __secondary_hold_spinloop;
234extern void generic_secondary_smp_init(void);
235
236void smp_release_cpus(void) 238void smp_release_cpus(void)
237{ 239{
238 unsigned long *ptr; 240 unsigned long *ptr;
@@ -453,6 +455,24 @@ static void __init irqstack_early_init(void)
453#define irqstack_early_init() 455#define irqstack_early_init()
454#endif 456#endif
455 457
458#ifdef CONFIG_PPC_BOOK3E
459static void __init exc_lvl_early_init(void)
460{
461 unsigned int i;
462
463 for_each_possible_cpu(i) {
464 critirq_ctx[i] = (struct thread_info *)
465 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
466 dbgirq_ctx[i] = (struct thread_info *)
467 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
468 mcheckirq_ctx[i] = (struct thread_info *)
469 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
470 }
471}
472#else
473#define exc_lvl_early_init()
474#endif
475
456/* 476/*
457 * Stack space used when we detect a bad kernel stack pointer, and 477 * Stack space used when we detect a bad kernel stack pointer, and
458 * early in SMP boots before relocation is enabled. 478 * early in SMP boots before relocation is enabled.
@@ -512,6 +532,7 @@ void __init setup_arch(char **cmdline_p)
512 init_mm.brk = klimit; 532 init_mm.brk = klimit;
513 533
514 irqstack_early_init(); 534 irqstack_early_init();
535 exc_lvl_early_init();
515 emergency_stack_init(); 536 emergency_stack_init();
516 537
517#ifdef CONFIG_PPC_STD_MMU_64 538#ifdef CONFIG_PPC_STD_MMU_64
@@ -534,6 +555,10 @@ void __init setup_arch(char **cmdline_p)
534#endif 555#endif
535 556
536 paging_init(); 557 paging_init();
558
559 /* Initialize the MMU context management stuff */
560 mmu_context_init();
561
537 ppc64_boot_msg(0x15, "Setup Done"); 562 ppc64_boot_msg(0x15, "Setup Done");
538} 563}
539 564
@@ -569,25 +594,53 @@ void cpu_die(void)
569} 594}
570 595
571#ifdef CONFIG_SMP 596#ifdef CONFIG_SMP
572void __init setup_per_cpu_areas(void) 597#define PCPU_DYN_SIZE ()
598
599static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
573{ 600{
574 int i; 601 return __alloc_bootmem_node(NODE_DATA(cpu_to_node(cpu)), size, align,
575 unsigned long size; 602 __pa(MAX_DMA_ADDRESS));
576 char *ptr; 603}
577
578 /* Copy section for each CPU (we discard the original) */
579 size = ALIGN(__per_cpu_end - __per_cpu_start, PAGE_SIZE);
580#ifdef CONFIG_MODULES
581 if (size < PERCPU_ENOUGH_ROOM)
582 size = PERCPU_ENOUGH_ROOM;
583#endif
584 604
585 for_each_possible_cpu(i) { 605static void __init pcpu_fc_free(void *ptr, size_t size)
586 ptr = alloc_bootmem_pages_node(NODE_DATA(cpu_to_node(i)), size); 606{
607 free_bootmem(__pa(ptr), size);
608}
587 609
588 paca[i].data_offset = ptr - __per_cpu_start; 610static int pcpu_cpu_distance(unsigned int from, unsigned int to)
589 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 611{
590 } 612 if (cpu_to_node(from) == cpu_to_node(to))
613 return LOCAL_DISTANCE;
614 else
615 return REMOTE_DISTANCE;
616}
617
618void __init setup_per_cpu_areas(void)
619{
620 const size_t dyn_size = PERCPU_MODULE_RESERVE + PERCPU_DYNAMIC_RESERVE;
621 size_t atom_size;
622 unsigned long delta;
623 unsigned int cpu;
624 int rc;
625
626 /*
627 * Linear mapping is one of 4K, 1M and 16M. For 4K, no need
628 * to group units. For larger mappings, use 1M atom which
629 * should be large enough to contain a number of units.
630 */
631 if (mmu_linear_psize == MMU_PAGE_4K)
632 atom_size = PAGE_SIZE;
633 else
634 atom_size = 1 << 20;
635
636 rc = pcpu_embed_first_chunk(0, dyn_size, atom_size, pcpu_cpu_distance,
637 pcpu_fc_alloc, pcpu_fc_free);
638 if (rc < 0)
639 panic("cannot initialize percpu area (err=%d)", rc);
640
641 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
642 for_each_possible_cpu(cpu)
643 paca[cpu].data_offset = delta + pcpu_unit_offsets[cpu];
591} 644}
592#endif 645#endif
593 646
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 0b47de07302d..d387b3937ccc 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -269,7 +269,10 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
269 cpu_callin_map[boot_cpuid] = 1; 269 cpu_callin_map[boot_cpuid] = 1;
270 270
271 if (smp_ops) 271 if (smp_ops)
272 max_cpus = smp_ops->probe(); 272 if (smp_ops->probe)
273 max_cpus = smp_ops->probe();
274 else
275 max_cpus = NR_CPUS;
273 else 276 else
274 max_cpus = 1; 277 max_cpus = 1;
275 278
@@ -412,9 +415,8 @@ int __cpuinit __cpu_up(unsigned int cpu)
412 * CPUs can take much longer to come up in the 415 * CPUs can take much longer to come up in the
413 * hotplug case. Wait five seconds. 416 * hotplug case. Wait five seconds.
414 */ 417 */
415 for (c = 25; c && !cpu_callin_map[cpu]; c--) { 418 for (c = 5000; c && !cpu_callin_map[cpu]; c--)
416 msleep(200); 419 msleep(1);
417 }
418#endif 420#endif
419 421
420 if (!cpu_callin_map[cpu]) { 422 if (!cpu_callin_map[cpu]) {
@@ -494,7 +496,8 @@ int __devinit start_secondary(void *unused)
494 preempt_disable(); 496 preempt_disable();
495 cpu_callin_map[cpu] = 1; 497 cpu_callin_map[cpu] = 1;
496 498
497 smp_ops->setup_cpu(cpu); 499 if (smp_ops->setup_cpu)
500 smp_ops->setup_cpu(cpu);
498 if (smp_ops->take_timebase) 501 if (smp_ops->take_timebase)
499 smp_ops->take_timebase(); 502 smp_ops->take_timebase();
500 503
@@ -557,7 +560,7 @@ void __init smp_cpus_done(unsigned int max_cpus)
557 old_mask = current->cpus_allowed; 560 old_mask = current->cpus_allowed;
558 set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid)); 561 set_cpus_allowed(current, cpumask_of_cpu(boot_cpuid));
559 562
560 if (smp_ops) 563 if (smp_ops && smp_ops->setup_cpu)
561 smp_ops->setup_cpu(boot_cpuid); 564 smp_ops->setup_cpu(boot_cpuid);
562 565
563 set_cpus_allowed(current, old_mask); 566 set_cpus_allowed(current, old_mask);
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index bb1cfcfdbbbb..1cc5e9e5da96 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -343,6 +343,18 @@ off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
343 return sys_lseek(fd, (int)offset, origin); 343 return sys_lseek(fd, (int)offset, origin);
344} 344}
345 345
346long compat_sys_truncate(const char __user * path, u32 length)
347{
348 /* sign extend length */
349 return sys_truncate(path, (int)length);
350}
351
352long compat_sys_ftruncate(int fd, u32 length)
353{
354 /* sign extend length */
355 return sys_ftruncate(fd, (int)length);
356}
357
346/* Note: it is necessary to treat bufsiz as an unsigned int, 358/* Note: it is necessary to treat bufsiz as an unsigned int,
347 * with the corresponding cast to a signed int to insure that the 359 * with the corresponding cast to a signed int to insure that the
348 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) 360 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index f41aec85aa49..956ab33fd73f 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -17,6 +17,7 @@
17#include <asm/prom.h> 17#include <asm/prom.h>
18#include <asm/machdep.h> 18#include <asm/machdep.h>
19#include <asm/smp.h> 19#include <asm/smp.h>
20#include <asm/pmc.h>
20 21
21#include "cacheinfo.h" 22#include "cacheinfo.h"
22 23
@@ -123,6 +124,8 @@ static DEFINE_PER_CPU(char, pmcs_enabled);
123 124
124void ppc_enable_pmcs(void) 125void ppc_enable_pmcs(void)
125{ 126{
127 ppc_set_pmu_inuse(1);
128
126 /* Only need to enable them once */ 129 /* Only need to enable them once */
127 if (__get_cpu_var(pmcs_enabled)) 130 if (__get_cpu_var(pmcs_enabled))
128 return; 131 return;
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index eae4511ceeac..a180b4f9a4f6 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -479,7 +479,8 @@ static int __init iSeries_tb_recal(void)
479 unsigned long tb_ticks = tb - iSeries_recal_tb; 479 unsigned long tb_ticks = tb - iSeries_recal_tb;
480 unsigned long titan_usec = (titan - iSeries_recal_titan) >> 12; 480 unsigned long titan_usec = (titan - iSeries_recal_titan) >> 12;
481 unsigned long new_tb_ticks_per_sec = (tb_ticks * USEC_PER_SEC)/titan_usec; 481 unsigned long new_tb_ticks_per_sec = (tb_ticks * USEC_PER_SEC)/titan_usec;
482 unsigned long new_tb_ticks_per_jiffy = (new_tb_ticks_per_sec+(HZ/2))/HZ; 482 unsigned long new_tb_ticks_per_jiffy =
483 DIV_ROUND_CLOSEST(new_tb_ticks_per_sec, HZ);
483 long tick_diff = new_tb_ticks_per_jiffy - tb_ticks_per_jiffy; 484 long tick_diff = new_tb_ticks_per_jiffy - tb_ticks_per_jiffy;
484 char sign = '+'; 485 char sign = '+';
485 /* make sure tb_ticks_per_sec and tb_ticks_per_jiffy are consistent */ 486 /* make sure tb_ticks_per_sec and tb_ticks_per_jiffy are consistent */
@@ -726,6 +727,18 @@ static int __init get_freq(char *name, int cells, unsigned long *val)
726 return found; 727 return found;
727} 728}
728 729
730/* should become __cpuinit when secondary_cpu_time_init also is */
731void start_cpu_decrementer(void)
732{
733#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
734 /* Clear any pending timer interrupts */
735 mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
736
737 /* Enable decrementer interrupt */
738 mtspr(SPRN_TCR, TCR_DIE);
739#endif /* defined(CONFIG_BOOKE) || defined(CONFIG_40x) */
740}
741
729void __init generic_calibrate_decr(void) 742void __init generic_calibrate_decr(void)
730{ 743{
731 ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */ 744 ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
@@ -745,14 +758,6 @@ void __init generic_calibrate_decr(void)
745 printk(KERN_ERR "WARNING: Estimating processor frequency " 758 printk(KERN_ERR "WARNING: Estimating processor frequency "
746 "(not found)\n"); 759 "(not found)\n");
747 } 760 }
748
749#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
750 /* Clear any pending timer interrupts */
751 mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
752
753 /* Enable decrementer interrupt */
754 mtspr(SPRN_TCR, TCR_DIE);
755#endif
756} 761}
757 762
758int update_persistent_clock(struct timespec now) 763int update_persistent_clock(struct timespec now)
@@ -913,6 +918,11 @@ static void __init init_decrementer_clockevent(void)
913 918
914void secondary_cpu_time_init(void) 919void secondary_cpu_time_init(void)
915{ 920{
921 /* Start the decrementer on CPUs that have manual control
922 * such as BookE
923 */
924 start_cpu_decrementer();
925
916 /* FIME: Should make unrelatred change to move snapshot_timebase 926 /* FIME: Should make unrelatred change to move snapshot_timebase
917 * call here ! */ 927 * call here ! */
918 register_decrementer_clockevent(smp_processor_id()); 928 register_decrementer_clockevent(smp_processor_id());
@@ -1016,6 +1026,11 @@ void __init time_init(void)
1016 1026
1017 write_sequnlock_irqrestore(&xtime_lock, flags); 1027 write_sequnlock_irqrestore(&xtime_lock, flags);
1018 1028
1029 /* Start the decrementer on CPUs that have manual control
1030 * such as BookE
1031 */
1032 start_cpu_decrementer();
1033
1019 /* Register the clocksource, if we're not running on iSeries */ 1034 /* Register the clocksource, if we're not running on iSeries */
1020 if (!firmware_has_feature(FW_FEATURE_ISERIES)) 1035 if (!firmware_has_feature(FW_FEATURE_ISERIES))
1021 clocksource_init(); 1036 clocksource_init();
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index ad06d5c75b15..a0abce251d0a 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -203,7 +203,12 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
203 } else { 203 } else {
204 vdso_pagelist = vdso64_pagelist; 204 vdso_pagelist = vdso64_pagelist;
205 vdso_pages = vdso64_pages; 205 vdso_pages = vdso64_pages;
206 vdso_base = VDSO64_MBASE; 206 /*
207 * On 64bit we don't have a preferred map address. This
208 * allows get_unmapped_area to find an area near other mmaps
209 * and most likely share a SLB entry.
210 */
211 vdso_base = 0;
207 } 212 }
208#else 213#else
209 vdso_pagelist = vdso32_pagelist; 214 vdso_pagelist = vdso32_pagelist;
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
index c3d57bd01a88..b54b81688132 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -12,6 +12,7 @@ endif
12targets := $(obj-vdso32) vdso32.so vdso32.so.dbg 12targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
13obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) 13obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
14 14
15GCOV_PROFILE := n
15 16
16EXTRA_CFLAGS := -shared -fno-common -fno-builtin 17EXTRA_CFLAGS := -shared -fno-common -fno-builtin
17EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso32.so.1 \ 18EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso32.so.1 \
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
index fa7f1b8f3e50..dd0c8e936775 100644
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ b/arch/powerpc/kernel/vdso64/Makefile
@@ -7,6 +7,8 @@ obj-vdso64 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o
7targets := $(obj-vdso64) vdso64.so vdso64.so.dbg 7targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
8obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) 8obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
9 9
10GCOV_PROFILE := n
11
10EXTRA_CFLAGS := -shared -fno-common -fno-builtin 12EXTRA_CFLAGS := -shared -fno-common -fno-builtin
11EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso64.so.1 \ 13EXTRA_CFLAGS += -nostdlib -Wl,-soname=linux-vdso64.so.1 \
12 $(call ld-option, -Wl$(comma)--hash-style=sysv) 14 $(call ld-option, -Wl$(comma)--hash-style=sysv)
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index ea4d64644d02..67b6916f0e94 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -65,7 +65,7 @@ _GLOBAL(load_up_altivec)
651: 651:
66 /* enable use of VMX after return */ 66 /* enable use of VMX after return */
67#ifdef CONFIG_PPC32 67#ifdef CONFIG_PPC32
68 mfspr r5,SPRN_SPRG3 /* current task's THREAD (phys) */ 68 mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */
69 oris r9,r9,MSR_VEC@h 69 oris r9,r9,MSR_VEC@h
70#else 70#else
71 ld r4,PACACURRENT(r13) 71 ld r4,PACACURRENT(r13)
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 819e59f6f7c7..bc7b41edbdfc 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -601,7 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
601 vio_cmo_dealloc(viodev, alloc_size); 601 vio_cmo_dealloc(viodev, alloc_size);
602} 602}
603 603
604struct dma_mapping_ops vio_dma_mapping_ops = { 604struct dma_map_ops vio_dma_mapping_ops = {
605 .alloc_coherent = vio_dma_iommu_alloc_coherent, 605 .alloc_coherent = vio_dma_iommu_alloc_coherent,
606 .free_coherent = vio_dma_iommu_free_coherent, 606 .free_coherent = vio_dma_iommu_free_coherent,
607 .map_sg = vio_dma_iommu_map_sg, 607 .map_sg = vio_dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 8ef8a14abc95..58da4070723d 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -37,12 +37,6 @@ jiffies = jiffies_64 + 4;
37#endif 37#endif
38SECTIONS 38SECTIONS
39{ 39{
40 /* Sections to be discarded. */
41 /DISCARD/ : {
42 *(.exitcall.exit)
43 EXIT_DATA
44 }
45
46 . = KERNELBASE; 40 . = KERNELBASE;
47 41
48/* 42/*
@@ -245,10 +239,6 @@ SECTIONS
245 } 239 }
246#endif 240#endif
247 241
248 . = ALIGN(PAGE_SIZE);
249 _edata = .;
250 PROVIDE32 (edata = .);
251
252 /* The initial task and kernel stack */ 242 /* The initial task and kernel stack */
253#ifdef CONFIG_PPC32 243#ifdef CONFIG_PPC32
254 . = ALIGN(8192); 244 . = ALIGN(8192);
@@ -282,6 +272,10 @@ SECTIONS
282 __nosave_end = .; 272 __nosave_end = .;
283 } 273 }
284 274
275 . = ALIGN(PAGE_SIZE);
276 _edata = .;
277 PROVIDE32 (edata = .);
278
285/* 279/*
286 * And finally the bss 280 * And finally the bss
287 */ 281 */
@@ -298,4 +292,7 @@ SECTIONS
298 . = ALIGN(PAGE_SIZE); 292 . = ALIGN(PAGE_SIZE);
299 _end = . ; 293 _end = . ;
300 PROVIDE32 (end = .); 294 PROVIDE32 (end = .);
295
296 /* Sections to be discarded. */
297 DISCARDS
301} 298}
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index d0c6f841bbd1..380a78cf484d 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -56,8 +56,8 @@
56.macro KVM_HANDLER ivor_nr 56.macro KVM_HANDLER ivor_nr
57_GLOBAL(kvmppc_handler_\ivor_nr) 57_GLOBAL(kvmppc_handler_\ivor_nr)
58 /* Get pointer to vcpu and record exit number. */ 58 /* Get pointer to vcpu and record exit number. */
59 mtspr SPRN_SPRG0, r4 59 mtspr SPRN_SPRG_WSCRATCH0, r4
60 mfspr r4, SPRN_SPRG1 60 mfspr r4, SPRN_SPRG_RVCPU
61 stw r5, VCPU_GPR(r5)(r4) 61 stw r5, VCPU_GPR(r5)(r4)
62 stw r6, VCPU_GPR(r6)(r4) 62 stw r6, VCPU_GPR(r6)(r4)
63 mfctr r5 63 mfctr r5
@@ -95,7 +95,7 @@ _GLOBAL(kvmppc_handler_len)
95 95
96 96
97/* Registers: 97/* Registers:
98 * SPRG0: guest r4 98 * SPRG_SCRATCH0: guest r4
99 * r4: vcpu pointer 99 * r4: vcpu pointer
100 * r5: KVM exit number 100 * r5: KVM exit number
101 */ 101 */
@@ -181,7 +181,7 @@ _GLOBAL(kvmppc_resume_host)
181 stw r3, VCPU_LR(r4) 181 stw r3, VCPU_LR(r4)
182 mfxer r3 182 mfxer r3
183 stw r3, VCPU_XER(r4) 183 stw r3, VCPU_XER(r4)
184 mfspr r3, SPRN_SPRG0 184 mfspr r3, SPRN_SPRG_RSCRATCH0
185 stw r3, VCPU_GPR(r4)(r4) 185 stw r3, VCPU_GPR(r4)(r4)
186 mfspr r3, SPRN_SRR0 186 mfspr r3, SPRN_SRR0
187 stw r3, VCPU_PC(r4) 187 stw r3, VCPU_PC(r4)
@@ -374,7 +374,7 @@ lightweight_exit:
374 mtspr SPRN_IVPR, r8 374 mtspr SPRN_IVPR, r8
375 375
376 /* Save vcpu pointer for the exception handlers. */ 376 /* Save vcpu pointer for the exception handlers. */
377 mtspr SPRN_SPRG1, r4 377 mtspr SPRN_SPRG_WVCPU, r4
378 378
379 /* Can't switch the stack pointer until after IVPR is switched, 379 /* Can't switch the stack pointer until after IVPR is switched,
380 * because host interrupt handlers would get confused. */ 380 * because host interrupt handlers would get confused. */
@@ -384,13 +384,13 @@ lightweight_exit:
384 /* Host interrupt handlers may have clobbered these guest-readable 384 /* Host interrupt handlers may have clobbered these guest-readable
385 * SPRGs, so we need to reload them here with the guest's values. */ 385 * SPRGs, so we need to reload them here with the guest's values. */
386 lwz r3, VCPU_SPRG4(r4) 386 lwz r3, VCPU_SPRG4(r4)
387 mtspr SPRN_SPRG4, r3 387 mtspr SPRN_SPRG4W, r3
388 lwz r3, VCPU_SPRG5(r4) 388 lwz r3, VCPU_SPRG5(r4)
389 mtspr SPRN_SPRG5, r3 389 mtspr SPRN_SPRG5W, r3
390 lwz r3, VCPU_SPRG6(r4) 390 lwz r3, VCPU_SPRG6(r4)
391 mtspr SPRN_SPRG6, r3 391 mtspr SPRN_SPRG6W, r3
392 lwz r3, VCPU_SPRG7(r4) 392 lwz r3, VCPU_SPRG7(r4)
393 mtspr SPRN_SPRG7, r3 393 mtspr SPRN_SPRG7W, r3
394 394
395#ifdef CONFIG_KVM_EXIT_TIMING 395#ifdef CONFIG_KVM_EXIT_TIMING
396 /* save enter time */ 396 /* save enter time */
diff --git a/arch/powerpc/mm/40x_mmu.c b/arch/powerpc/mm/40x_mmu.c
index 29954dc28942..f5e7b9ce63dd 100644
--- a/arch/powerpc/mm/40x_mmu.c
+++ b/arch/powerpc/mm/40x_mmu.c
@@ -105,7 +105,7 @@ unsigned long __init mmu_mapin_ram(void)
105 105
106 while (s >= LARGE_PAGE_SIZE_16M) { 106 while (s >= LARGE_PAGE_SIZE_16M) {
107 pmd_t *pmdp; 107 pmd_t *pmdp;
108 unsigned long val = p | _PMD_SIZE_16M | _PAGE_HWEXEC | _PAGE_HWWRITE; 108 unsigned long val = p | _PMD_SIZE_16M | _PAGE_EXEC | _PAGE_HWWRITE;
109 109
110 pmdp = pmd_offset(pud_offset(pgd_offset_k(v), v), v); 110 pmdp = pmd_offset(pud_offset(pgd_offset_k(v), v), v);
111 pmd_val(*pmdp++) = val; 111 pmd_val(*pmdp++) = val;
@@ -120,7 +120,7 @@ unsigned long __init mmu_mapin_ram(void)
120 120
121 while (s >= LARGE_PAGE_SIZE_4M) { 121 while (s >= LARGE_PAGE_SIZE_4M) {
122 pmd_t *pmdp; 122 pmd_t *pmdp;
123 unsigned long val = p | _PMD_SIZE_4M | _PAGE_HWEXEC | _PAGE_HWWRITE; 123 unsigned long val = p | _PMD_SIZE_4M | _PAGE_EXEC | _PAGE_HWWRITE;
124 124
125 pmdp = pmd_offset(pud_offset(pgd_offset_k(v), v), v); 125 pmdp = pmd_offset(pud_offset(pgd_offset_k(v), v), v);
126 pmd_val(*pmdp) = val; 126 pmd_val(*pmdp) = val;
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 3e68363405b7..6fb8fc8d2fea 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -13,6 +13,7 @@ obj-y := fault.o mem.o pgtable.o gup.o \
13 pgtable_$(CONFIG_WORD_SIZE).o 13 pgtable_$(CONFIG_WORD_SIZE).o
14obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \ 14obj-$(CONFIG_PPC_MMU_NOHASH) += mmu_context_nohash.o tlb_nohash.o \
15 tlb_nohash_low.o 15 tlb_nohash_low.o
16obj-$(CONFIG_PPC_BOOK3E) += tlb_low_$(CONFIG_WORD_SIZE)e.o
16obj-$(CONFIG_PPC64) += mmap_64.o 17obj-$(CONFIG_PPC64) += mmap_64.o
17hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o 18hash64-$(CONFIG_PPC_NATIVE) := hash_native_64.o
18obj-$(CONFIG_PPC_STD_MMU_64) += hash_utils_64.o \ 19obj-$(CONFIG_PPC_STD_MMU_64) += hash_utils_64.o \
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c
index bb3d65998e6b..dc93e95b256e 100644
--- a/arch/powerpc/mm/fsl_booke_mmu.c
+++ b/arch/powerpc/mm/fsl_booke_mmu.c
@@ -161,7 +161,7 @@ unsigned long __init mmu_mapin_ram(void)
161 unsigned long virt = PAGE_OFFSET; 161 unsigned long virt = PAGE_OFFSET;
162 phys_addr_t phys = memstart_addr; 162 phys_addr_t phys = memstart_addr;
163 163
164 while (cam[tlbcam_index] && tlbcam_index < ARRAY_SIZE(cam)) { 164 while (tlbcam_index < ARRAY_SIZE(cam) && cam[tlbcam_index]) {
165 settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], PAGE_KERNEL_X, 0); 165 settlbcam(tlbcam_index, virt, phys, cam[tlbcam_index], PAGE_KERNEL_X, 0);
166 virt += cam[tlbcam_index]; 166 virt += cam[tlbcam_index];
167 phys += cam[tlbcam_index]; 167 phys += cam[tlbcam_index];
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index 14af8cedab70..b13d58932bf6 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -40,7 +40,7 @@ mmu_hash_lock:
40 * The address is in r4, and r3 contains an access flag: 40 * The address is in r4, and r3 contains an access flag:
41 * _PAGE_RW (0x400) if a write. 41 * _PAGE_RW (0x400) if a write.
42 * r9 contains the SRR1 value, from which we use the MSR_PR bit. 42 * r9 contains the SRR1 value, from which we use the MSR_PR bit.
43 * SPRG3 contains the physical address of the current task's thread. 43 * SPRG_THREAD contains the physical address of the current task's thread.
44 * 44 *
45 * Returns to the caller if the access is illegal or there is no 45 * Returns to the caller if the access is illegal or there is no
46 * mapping for the address. Otherwise it places an appropriate PTE 46 * mapping for the address. Otherwise it places an appropriate PTE
@@ -68,7 +68,7 @@ _GLOBAL(hash_page)
68 /* Get PTE (linux-style) and check access */ 68 /* Get PTE (linux-style) and check access */
69 lis r0,KERNELBASE@h /* check if kernel address */ 69 lis r0,KERNELBASE@h /* check if kernel address */
70 cmplw 0,r4,r0 70 cmplw 0,r4,r0
71 mfspr r8,SPRN_SPRG3 /* current task's THREAD (phys) */ 71 mfspr r8,SPRN_SPRG_THREAD /* current task's THREAD (phys) */
72 ori r3,r3,_PAGE_USER|_PAGE_PRESENT /* test low addresses as user */ 72 ori r3,r3,_PAGE_USER|_PAGE_PRESENT /* test low addresses as user */
73 lwz r5,PGDIR(r8) /* virt page-table root */ 73 lwz r5,PGDIR(r8) /* virt page-table root */
74 blt+ 112f /* assume user more likely */ 74 blt+ 112f /* assume user more likely */
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index c46ef2ffa3d9..90df6ffe3a43 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -57,8 +57,10 @@ unsigned int mmu_huge_psizes[MMU_PAGE_COUNT] = { }; /* initialize all to 0 */
57#define HUGEPTE_CACHE_NAME(psize) (huge_pgtable_cache_name[psize]) 57#define HUGEPTE_CACHE_NAME(psize) (huge_pgtable_cache_name[psize])
58 58
59static const char *huge_pgtable_cache_name[MMU_PAGE_COUNT] = { 59static const char *huge_pgtable_cache_name[MMU_PAGE_COUNT] = {
60 "unused_4K", "hugepte_cache_64K", "unused_64K_AP", 60 [MMU_PAGE_64K] = "hugepte_cache_64K",
61 "hugepte_cache_1M", "hugepte_cache_16M", "hugepte_cache_16G" 61 [MMU_PAGE_1M] = "hugepte_cache_1M",
62 [MMU_PAGE_16M] = "hugepte_cache_16M",
63 [MMU_PAGE_16G] = "hugepte_cache_16G",
62}; 64};
63 65
64/* Flag to mark huge PD pointers. This means pmd_bad() and pud_bad() 66/* Flag to mark huge PD pointers. This means pmd_bad() and pud_bad()
@@ -700,6 +702,8 @@ static void __init set_huge_psize(int psize)
700 if (mmu_huge_psizes[psize] || 702 if (mmu_huge_psizes[psize] ||
701 mmu_psize_defs[psize].shift == PAGE_SHIFT) 703 mmu_psize_defs[psize].shift == PAGE_SHIFT)
702 return; 704 return;
705 if (WARN_ON(HUGEPTE_CACHE_NAME(psize) == NULL))
706 return;
703 hugetlb_add_hstate(mmu_psize_defs[psize].shift - PAGE_SHIFT); 707 hugetlb_add_hstate(mmu_psize_defs[psize].shift - PAGE_SHIFT);
704 708
705 switch (mmu_psize_defs[psize].shift) { 709 switch (mmu_psize_defs[psize].shift) {
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 3de6a0d93824..3ef5084b90ca 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -54,8 +54,6 @@
54#endif 54#endif
55#define MAX_LOW_MEM CONFIG_LOWMEM_SIZE 55#define MAX_LOW_MEM CONFIG_LOWMEM_SIZE
56 56
57DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
58
59phys_addr_t total_memory; 57phys_addr_t total_memory;
60phys_addr_t total_lowmem; 58phys_addr_t total_lowmem;
61 59
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 68a821add28d..31582329cd67 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -205,6 +205,47 @@ static int __meminit vmemmap_populated(unsigned long start, int page_size)
205 return 0; 205 return 0;
206} 206}
207 207
208/* On hash-based CPUs, the vmemmap is bolted in the hash table.
209 *
210 * On Book3E CPUs, the vmemmap is currently mapped in the top half of
211 * the vmalloc space using normal page tables, though the size of
212 * pages encoded in the PTEs can be different
213 */
214
215#ifdef CONFIG_PPC_BOOK3E
216static void __meminit vmemmap_create_mapping(unsigned long start,
217 unsigned long page_size,
218 unsigned long phys)
219{
220 /* Create a PTE encoding without page size */
221 unsigned long i, flags = _PAGE_PRESENT | _PAGE_ACCESSED |
222 _PAGE_KERNEL_RW;
223
224 /* PTEs only contain page size encodings up to 32M */
225 BUG_ON(mmu_psize_defs[mmu_vmemmap_psize].enc > 0xf);
226
227 /* Encode the size in the PTE */
228 flags |= mmu_psize_defs[mmu_vmemmap_psize].enc << 8;
229
230 /* For each PTE for that area, map things. Note that we don't
231 * increment phys because all PTEs are of the large size and
232 * thus must have the low bits clear
233 */
234 for (i = 0; i < page_size; i += PAGE_SIZE)
235 BUG_ON(map_kernel_page(start + i, phys, flags));
236}
237#else /* CONFIG_PPC_BOOK3E */
238static void __meminit vmemmap_create_mapping(unsigned long start,
239 unsigned long page_size,
240 unsigned long phys)
241{
242 int mapped = htab_bolt_mapping(start, start + page_size, phys,
243 PAGE_KERNEL, mmu_vmemmap_psize,
244 mmu_kernel_ssize);
245 BUG_ON(mapped < 0);
246}
247#endif /* CONFIG_PPC_BOOK3E */
248
208int __meminit vmemmap_populate(struct page *start_page, 249int __meminit vmemmap_populate(struct page *start_page,
209 unsigned long nr_pages, int node) 250 unsigned long nr_pages, int node)
210{ 251{
@@ -215,8 +256,11 @@ int __meminit vmemmap_populate(struct page *start_page,
215 /* Align to the page size of the linear mapping. */ 256 /* Align to the page size of the linear mapping. */
216 start = _ALIGN_DOWN(start, page_size); 257 start = _ALIGN_DOWN(start, page_size);
217 258
259 pr_debug("vmemmap_populate page %p, %ld pages, node %d\n",
260 start_page, nr_pages, node);
261 pr_debug(" -> map %lx..%lx\n", start, end);
262
218 for (; start < end; start += page_size) { 263 for (; start < end; start += page_size) {
219 int mapped;
220 void *p; 264 void *p;
221 265
222 if (vmemmap_populated(start, page_size)) 266 if (vmemmap_populated(start, page_size))
@@ -226,13 +270,10 @@ int __meminit vmemmap_populate(struct page *start_page,
226 if (!p) 270 if (!p)
227 return -ENOMEM; 271 return -ENOMEM;
228 272
229 pr_debug("vmemmap %08lx allocated at %p, physical %08lx.\n", 273 pr_debug(" * %016lx..%016lx allocated at %p\n",
230 start, p, __pa(p)); 274 start, start + page_size, p);
231 275
232 mapped = htab_bolt_mapping(start, start + page_size, __pa(p), 276 vmemmap_create_mapping(start, page_size, __pa(p));
233 pgprot_val(PAGE_KERNEL),
234 mmu_vmemmap_psize, mmu_kernel_ssize);
235 BUG_ON(mapped < 0);
236 } 277 }
237 278
238 return 0; 279 return 0;
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
index b1a727def15b..c2f93dc470e6 100644
--- a/arch/powerpc/mm/mmu_context_nohash.c
+++ b/arch/powerpc/mm/mmu_context_nohash.c
@@ -25,10 +25,20 @@
25 * also clear mm->cpu_vm_mask bits when processes are migrated 25 * also clear mm->cpu_vm_mask bits when processes are migrated
26 */ 26 */
27 27
28#undef DEBUG 28#define DEBUG_MAP_CONSISTENCY
29#define DEBUG_STEAL_ONLY 29#define DEBUG_CLAMP_LAST_CONTEXT 31
30#undef DEBUG_MAP_CONSISTENCY 30//#define DEBUG_HARDER
31/*#define DEBUG_CLAMP_LAST_CONTEXT 15 */ 31
32/* We don't use DEBUG because it tends to be compiled in always nowadays
33 * and this would generate way too much output
34 */
35#ifdef DEBUG_HARDER
36#define pr_hard(args...) printk(KERN_DEBUG args)
37#define pr_hardcont(args...) printk(KERN_CONT args)
38#else
39#define pr_hard(args...) do { } while(0)
40#define pr_hardcont(args...) do { } while(0)
41#endif
32 42
33#include <linux/kernel.h> 43#include <linux/kernel.h>
34#include <linux/mm.h> 44#include <linux/mm.h>
@@ -71,7 +81,7 @@ static DEFINE_SPINLOCK(context_lock);
71static unsigned int steal_context_smp(unsigned int id) 81static unsigned int steal_context_smp(unsigned int id)
72{ 82{
73 struct mm_struct *mm; 83 struct mm_struct *mm;
74 unsigned int cpu, max; 84 unsigned int cpu, max, i;
75 85
76 max = last_context - first_context; 86 max = last_context - first_context;
77 87
@@ -89,15 +99,22 @@ static unsigned int steal_context_smp(unsigned int id)
89 id = first_context; 99 id = first_context;
90 continue; 100 continue;
91 } 101 }
92 pr_devel("[%d] steal context %d from mm @%p\n", 102 pr_hardcont(" | steal %d from 0x%p", id, mm);
93 smp_processor_id(), id, mm);
94 103
95 /* Mark this mm has having no context anymore */ 104 /* Mark this mm has having no context anymore */
96 mm->context.id = MMU_NO_CONTEXT; 105 mm->context.id = MMU_NO_CONTEXT;
97 106
98 /* Mark it stale on all CPUs that used this mm */ 107 /* Mark it stale on all CPUs that used this mm. For threaded
99 for_each_cpu(cpu, mm_cpumask(mm)) 108 * implementations, we set it on all threads on each core
100 __set_bit(id, stale_map[cpu]); 109 * represented in the mask. A future implementation will use
110 * a core map instead but this will do for now.
111 */
112 for_each_cpu(cpu, mm_cpumask(mm)) {
113 for (i = cpu_first_thread_in_core(cpu);
114 i <= cpu_last_thread_in_core(cpu); i++)
115 __set_bit(id, stale_map[i]);
116 cpu = i - 1;
117 }
101 return id; 118 return id;
102 } 119 }
103 120
@@ -126,7 +143,7 @@ static unsigned int steal_context_up(unsigned int id)
126 /* Pick up the victim mm */ 143 /* Pick up the victim mm */
127 mm = context_mm[id]; 144 mm = context_mm[id];
128 145
129 pr_devel("[%d] steal context %d from mm @%p\n", cpu, id, mm); 146 pr_hardcont(" | steal %d from 0x%p", id, mm);
130 147
131 /* Flush the TLB for that context */ 148 /* Flush the TLB for that context */
132 local_flush_tlb_mm(mm); 149 local_flush_tlb_mm(mm);
@@ -173,25 +190,20 @@ static void context_check_map(void) { }
173 190
174void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next) 191void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
175{ 192{
176 unsigned int id, cpu = smp_processor_id(); 193 unsigned int i, id, cpu = smp_processor_id();
177 unsigned long *map; 194 unsigned long *map;
178 195
179 /* No lockless fast path .. yet */ 196 /* No lockless fast path .. yet */
180 spin_lock(&context_lock); 197 spin_lock(&context_lock);
181 198
182#ifndef DEBUG_STEAL_ONLY 199 pr_hard("[%d] activating context for mm @%p, active=%d, id=%d",
183 pr_devel("[%d] activating context for mm @%p, active=%d, id=%d\n", 200 cpu, next, next->context.active, next->context.id);
184 cpu, next, next->context.active, next->context.id);
185#endif
186 201
187#ifdef CONFIG_SMP 202#ifdef CONFIG_SMP
188 /* Mark us active and the previous one not anymore */ 203 /* Mark us active and the previous one not anymore */
189 next->context.active++; 204 next->context.active++;
190 if (prev) { 205 if (prev) {
191#ifndef DEBUG_STEAL_ONLY 206 pr_hardcont(" (old=0x%p a=%d)", prev, prev->context.active);
192 pr_devel(" old context %p active was: %d\n",
193 prev, prev->context.active);
194#endif
195 WARN_ON(prev->context.active < 1); 207 WARN_ON(prev->context.active < 1);
196 prev->context.active--; 208 prev->context.active--;
197 } 209 }
@@ -201,8 +213,14 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
201 213
202 /* If we already have a valid assigned context, skip all that */ 214 /* If we already have a valid assigned context, skip all that */
203 id = next->context.id; 215 id = next->context.id;
204 if (likely(id != MMU_NO_CONTEXT)) 216 if (likely(id != MMU_NO_CONTEXT)) {
217#ifdef DEBUG_MAP_CONSISTENCY
218 if (context_mm[id] != next)
219 pr_err("MMU: mm 0x%p has id %d but context_mm[%d] says 0x%p\n",
220 next, id, id, context_mm[id]);
221#endif
205 goto ctxt_ok; 222 goto ctxt_ok;
223 }
206 224
207 /* We really don't have a context, let's try to acquire one */ 225 /* We really don't have a context, let's try to acquire one */
208 id = next_context; 226 id = next_context;
@@ -235,11 +253,7 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
235 next_context = id + 1; 253 next_context = id + 1;
236 context_mm[id] = next; 254 context_mm[id] = next;
237 next->context.id = id; 255 next->context.id = id;
238 256 pr_hardcont(" | new id=%d,nrf=%d", id, nr_free_contexts);
239#ifndef DEBUG_STEAL_ONLY
240 pr_devel("[%d] picked up new id %d, nrf is now %d\n",
241 cpu, id, nr_free_contexts);
242#endif
243 257
244 context_check_map(); 258 context_check_map();
245 ctxt_ok: 259 ctxt_ok:
@@ -248,15 +262,21 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
248 * local TLB for it and unmark it before we use it 262 * local TLB for it and unmark it before we use it
249 */ 263 */
250 if (test_bit(id, stale_map[cpu])) { 264 if (test_bit(id, stale_map[cpu])) {
251 pr_devel("[%d] flushing stale context %d for mm @%p !\n", 265 pr_hardcont(" | stale flush %d [%d..%d]",
252 cpu, id, next); 266 id, cpu_first_thread_in_core(cpu),
267 cpu_last_thread_in_core(cpu));
268
253 local_flush_tlb_mm(next); 269 local_flush_tlb_mm(next);
254 270
255 /* XXX This clear should ultimately be part of local_flush_tlb_mm */ 271 /* XXX This clear should ultimately be part of local_flush_tlb_mm */
256 __clear_bit(id, stale_map[cpu]); 272 for (i = cpu_first_thread_in_core(cpu);
273 i <= cpu_last_thread_in_core(cpu); i++) {
274 __clear_bit(id, stale_map[i]);
275 }
257 } 276 }
258 277
259 /* Flick the MMU and release lock */ 278 /* Flick the MMU and release lock */
279 pr_hardcont(" -> %d\n", id);
260 set_context(id, next->pgd); 280 set_context(id, next->pgd);
261 spin_unlock(&context_lock); 281 spin_unlock(&context_lock);
262} 282}
@@ -266,6 +286,8 @@ void switch_mmu_context(struct mm_struct *prev, struct mm_struct *next)
266 */ 286 */
267int init_new_context(struct task_struct *t, struct mm_struct *mm) 287int init_new_context(struct task_struct *t, struct mm_struct *mm)
268{ 288{
289 pr_hard("initing context for mm @%p\n", mm);
290
269 mm->context.id = MMU_NO_CONTEXT; 291 mm->context.id = MMU_NO_CONTEXT;
270 mm->context.active = 0; 292 mm->context.active = 0;
271 293
@@ -305,7 +327,9 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
305 unsigned long action, void *hcpu) 327 unsigned long action, void *hcpu)
306{ 328{
307 unsigned int cpu = (unsigned int)(long)hcpu; 329 unsigned int cpu = (unsigned int)(long)hcpu;
308 330#ifdef CONFIG_HOTPLUG_CPU
331 struct task_struct *p;
332#endif
309 /* We don't touch CPU 0 map, it's allocated at aboot and kept 333 /* We don't touch CPU 0 map, it's allocated at aboot and kept
310 * around forever 334 * around forever
311 */ 335 */
@@ -324,8 +348,16 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
324 pr_devel("MMU: Freeing stale context map for CPU %d\n", cpu); 348 pr_devel("MMU: Freeing stale context map for CPU %d\n", cpu);
325 kfree(stale_map[cpu]); 349 kfree(stale_map[cpu]);
326 stale_map[cpu] = NULL; 350 stale_map[cpu] = NULL;
327 break; 351
328#endif 352 /* We also clear the cpu_vm_mask bits of CPUs going away */
353 read_lock(&tasklist_lock);
354 for_each_process(p) {
355 if (p->mm)
356 cpu_mask_clear_cpu(cpu, mm_cpumask(p->mm));
357 }
358 read_unlock(&tasklist_lock);
359 break;
360#endif /* CONFIG_HOTPLUG_CPU */
329 } 361 }
330 return NOTIFY_OK; 362 return NOTIFY_OK;
331} 363}
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h
index d1f9c62dc177..d2e5321d5ea6 100644
--- a/arch/powerpc/mm/mmu_decl.h
+++ b/arch/powerpc/mm/mmu_decl.h
@@ -36,21 +36,37 @@ static inline void _tlbil_pid(unsigned int pid)
36{ 36{
37 asm volatile ("sync; tlbia; isync" : : : "memory"); 37 asm volatile ("sync; tlbia; isync" : : : "memory");
38} 38}
39#define _tlbil_pid_noind(pid) _tlbil_pid(pid)
40
39#else /* CONFIG_40x || CONFIG_8xx */ 41#else /* CONFIG_40x || CONFIG_8xx */
40extern void _tlbil_all(void); 42extern void _tlbil_all(void);
41extern void _tlbil_pid(unsigned int pid); 43extern void _tlbil_pid(unsigned int pid);
44#ifdef CONFIG_PPC_BOOK3E
45extern void _tlbil_pid_noind(unsigned int pid);
46#else
47#define _tlbil_pid_noind(pid) _tlbil_pid(pid)
48#endif
42#endif /* !(CONFIG_40x || CONFIG_8xx) */ 49#endif /* !(CONFIG_40x || CONFIG_8xx) */
43 50
44/* 51/*
45 * On 8xx, we directly inline tlbie, on others, it's extern 52 * On 8xx, we directly inline tlbie, on others, it's extern
46 */ 53 */
47#ifdef CONFIG_8xx 54#ifdef CONFIG_8xx
48static inline void _tlbil_va(unsigned long address, unsigned int pid) 55static inline void _tlbil_va(unsigned long address, unsigned int pid,
56 unsigned int tsize, unsigned int ind)
49{ 57{
50 asm volatile ("tlbie %0; sync" : : "r" (address) : "memory"); 58 asm volatile ("tlbie %0; sync" : : "r" (address) : "memory");
51} 59}
52#else /* CONFIG_8xx */ 60#elif defined(CONFIG_PPC_BOOK3E)
53extern void _tlbil_va(unsigned long address, unsigned int pid); 61extern void _tlbil_va(unsigned long address, unsigned int pid,
62 unsigned int tsize, unsigned int ind);
63#else
64extern void __tlbil_va(unsigned long address, unsigned int pid);
65static inline void _tlbil_va(unsigned long address, unsigned int pid,
66 unsigned int tsize, unsigned int ind)
67{
68 __tlbil_va(address, pid);
69}
54#endif /* CONIFG_8xx */ 70#endif /* CONIFG_8xx */
55 71
56/* 72/*
@@ -58,10 +74,16 @@ extern void _tlbil_va(unsigned long address, unsigned int pid);
58 * implementation. When that becomes the case, this will be 74 * implementation. When that becomes the case, this will be
59 * an extern. 75 * an extern.
60 */ 76 */
61static inline void _tlbivax_bcast(unsigned long address, unsigned int pid) 77#ifdef CONFIG_PPC_BOOK3E
78extern void _tlbivax_bcast(unsigned long address, unsigned int pid,
79 unsigned int tsize, unsigned int ind);
80#else
81static inline void _tlbivax_bcast(unsigned long address, unsigned int pid,
82 unsigned int tsize, unsigned int ind)
62{ 83{
63 BUG(); 84 BUG();
64} 85}
86#endif
65 87
66#else /* CONFIG_PPC_MMU_NOHASH */ 88#else /* CONFIG_PPC_MMU_NOHASH */
67 89
@@ -99,7 +121,12 @@ extern unsigned int rtas_data, rtas_size;
99struct hash_pte; 121struct hash_pte;
100extern struct hash_pte *Hash, *Hash_end; 122extern struct hash_pte *Hash, *Hash_end;
101extern unsigned long Hash_size, Hash_mask; 123extern unsigned long Hash_size, Hash_mask;
102#endif 124
125#endif /* CONFIG_PPC32 */
126
127#ifdef CONFIG_PPC64
128extern int map_kernel_page(unsigned long ea, unsigned long pa, int flags);
129#endif /* CONFIG_PPC64 */
103 130
104extern unsigned long ioremap_bot; 131extern unsigned long ioremap_bot;
105extern unsigned long __max_low_memory; 132extern unsigned long __max_low_memory;
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index 627767d6169b..83f1551ec2c9 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -30,6 +30,16 @@
30#include <asm/tlbflush.h> 30#include <asm/tlbflush.h>
31#include <asm/tlb.h> 31#include <asm/tlb.h>
32 32
33DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
34
35#ifdef CONFIG_SMP
36
37/*
38 * Handle batching of page table freeing on SMP. Page tables are
39 * queued up and send to be freed later by RCU in order to avoid
40 * freeing a page table page that is being walked without locks
41 */
42
33static DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur); 43static DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
34static unsigned long pte_freelist_forced_free; 44static unsigned long pte_freelist_forced_free;
35 45
@@ -116,27 +126,7 @@ void pte_free_finish(void)
116 *batchp = NULL; 126 *batchp = NULL;
117} 127}
118 128
119/* 129#endif /* CONFIG_SMP */
120 * Handle i/d cache flushing, called from set_pte_at() or ptep_set_access_flags()
121 */
122static pte_t do_dcache_icache_coherency(pte_t pte)
123{
124 unsigned long pfn = pte_pfn(pte);
125 struct page *page;
126
127 if (unlikely(!pfn_valid(pfn)))
128 return pte;
129 page = pfn_to_page(pfn);
130
131 if (!PageReserved(page) && !test_bit(PG_arch_1, &page->flags)) {
132 pr_devel("do_dcache_icache_coherency... flushing\n");
133 flush_dcache_icache_page(page);
134 set_bit(PG_arch_1, &page->flags);
135 }
136 else
137 pr_devel("do_dcache_icache_coherency... already clean\n");
138 return __pte(pte_val(pte) | _PAGE_HWEXEC);
139}
140 130
141static inline int is_exec_fault(void) 131static inline int is_exec_fault(void)
142{ 132{
@@ -145,49 +135,139 @@ static inline int is_exec_fault(void)
145 135
146/* We only try to do i/d cache coherency on stuff that looks like 136/* We only try to do i/d cache coherency on stuff that looks like
147 * reasonably "normal" PTEs. We currently require a PTE to be present 137 * reasonably "normal" PTEs. We currently require a PTE to be present
148 * and we avoid _PAGE_SPECIAL and _PAGE_NO_CACHE 138 * and we avoid _PAGE_SPECIAL and _PAGE_NO_CACHE. We also only do that
139 * on userspace PTEs
149 */ 140 */
150static inline int pte_looks_normal(pte_t pte) 141static inline int pte_looks_normal(pte_t pte)
151{ 142{
152 return (pte_val(pte) & 143 return (pte_val(pte) &
153 (_PAGE_PRESENT | _PAGE_SPECIAL | _PAGE_NO_CACHE)) == 144 (_PAGE_PRESENT | _PAGE_SPECIAL | _PAGE_NO_CACHE | _PAGE_USER)) ==
154 (_PAGE_PRESENT); 145 (_PAGE_PRESENT | _PAGE_USER);
155} 146}
156 147
157#if defined(CONFIG_PPC_STD_MMU) 148struct page * maybe_pte_to_page(pte_t pte)
149{
150 unsigned long pfn = pte_pfn(pte);
151 struct page *page;
152
153 if (unlikely(!pfn_valid(pfn)))
154 return NULL;
155 page = pfn_to_page(pfn);
156 if (PageReserved(page))
157 return NULL;
158 return page;
159}
160
161#if defined(CONFIG_PPC_STD_MMU) || _PAGE_EXEC == 0
162
158/* Server-style MMU handles coherency when hashing if HW exec permission 163/* Server-style MMU handles coherency when hashing if HW exec permission
159 * is supposed per page (currently 64-bit only). Else, we always flush 164 * is supposed per page (currently 64-bit only). If not, then, we always
160 * valid PTEs in set_pte. 165 * flush the cache for valid PTEs in set_pte. Embedded CPU without HW exec
166 * support falls into the same category.
161 */ 167 */
162static inline int pte_need_exec_flush(pte_t pte, int set_pte) 168
169static pte_t set_pte_filter(pte_t pte)
163{ 170{
164 return set_pte && pte_looks_normal(pte) && 171 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
165 !(cpu_has_feature(CPU_FTR_COHERENT_ICACHE) || 172 if (pte_looks_normal(pte) && !(cpu_has_feature(CPU_FTR_COHERENT_ICACHE) ||
166 cpu_has_feature(CPU_FTR_NOEXECUTE)); 173 cpu_has_feature(CPU_FTR_NOEXECUTE))) {
174 struct page *pg = maybe_pte_to_page(pte);
175 if (!pg)
176 return pte;
177 if (!test_bit(PG_arch_1, &pg->flags)) {
178 flush_dcache_icache_page(pg);
179 set_bit(PG_arch_1, &pg->flags);
180 }
181 }
182 return pte;
167} 183}
168#elif _PAGE_HWEXEC == 0 184
169/* Embedded type MMU without HW exec support (8xx only so far), we flush 185static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
170 * the cache for any present PTE 186 int dirty)
171 */
172static inline int pte_need_exec_flush(pte_t pte, int set_pte)
173{ 187{
174 return set_pte && pte_looks_normal(pte); 188 return pte;
175} 189}
176#else 190
177/* Other embedded CPUs with HW exec support per-page, we flush on exec 191#else /* defined(CONFIG_PPC_STD_MMU) || _PAGE_EXEC == 0 */
178 * fault if HWEXEC is not set 192
193/* Embedded type MMU with HW exec support. This is a bit more complicated
194 * as we don't have two bits to spare for _PAGE_EXEC and _PAGE_HWEXEC so
195 * instead we "filter out" the exec permission for non clean pages.
179 */ 196 */
180static inline int pte_need_exec_flush(pte_t pte, int set_pte) 197static pte_t set_pte_filter(pte_t pte)
181{ 198{
182 return pte_looks_normal(pte) && is_exec_fault() && 199 struct page *pg;
183 !(pte_val(pte) & _PAGE_HWEXEC); 200
201 /* No exec permission in the first place, move on */
202 if (!(pte_val(pte) & _PAGE_EXEC) || !pte_looks_normal(pte))
203 return pte;
204
205 /* If you set _PAGE_EXEC on weird pages you're on your own */
206 pg = maybe_pte_to_page(pte);
207 if (unlikely(!pg))
208 return pte;
209
210 /* If the page clean, we move on */
211 if (test_bit(PG_arch_1, &pg->flags))
212 return pte;
213
214 /* If it's an exec fault, we flush the cache and make it clean */
215 if (is_exec_fault()) {
216 flush_dcache_icache_page(pg);
217 set_bit(PG_arch_1, &pg->flags);
218 return pte;
219 }
220
221 /* Else, we filter out _PAGE_EXEC */
222 return __pte(pte_val(pte) & ~_PAGE_EXEC);
184} 223}
185#endif 224
225static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
226 int dirty)
227{
228 struct page *pg;
229
230 /* So here, we only care about exec faults, as we use them
231 * to recover lost _PAGE_EXEC and perform I$/D$ coherency
232 * if necessary. Also if _PAGE_EXEC is already set, same deal,
233 * we just bail out
234 */
235 if (dirty || (pte_val(pte) & _PAGE_EXEC) || !is_exec_fault())
236 return pte;
237
238#ifdef CONFIG_DEBUG_VM
239 /* So this is an exec fault, _PAGE_EXEC is not set. If it was
240 * an error we would have bailed out earlier in do_page_fault()
241 * but let's make sure of it
242 */
243 if (WARN_ON(!(vma->vm_flags & VM_EXEC)))
244 return pte;
245#endif /* CONFIG_DEBUG_VM */
246
247 /* If you set _PAGE_EXEC on weird pages you're on your own */
248 pg = maybe_pte_to_page(pte);
249 if (unlikely(!pg))
250 goto bail;
251
252 /* If the page is already clean, we move on */
253 if (test_bit(PG_arch_1, &pg->flags))
254 goto bail;
255
256 /* Clean the page and set PG_arch_1 */
257 flush_dcache_icache_page(pg);
258 set_bit(PG_arch_1, &pg->flags);
259
260 bail:
261 return __pte(pte_val(pte) | _PAGE_EXEC);
262}
263
264#endif /* !(defined(CONFIG_PPC_STD_MMU) || _PAGE_EXEC == 0) */
186 265
187/* 266/*
188 * set_pte stores a linux PTE into the linux page table. 267 * set_pte stores a linux PTE into the linux page table.
189 */ 268 */
190void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) 269void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
270 pte_t pte)
191{ 271{
192#ifdef CONFIG_DEBUG_VM 272#ifdef CONFIG_DEBUG_VM
193 WARN_ON(pte_present(*ptep)); 273 WARN_ON(pte_present(*ptep));
@@ -196,9 +276,7 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte
196 * this context might not have been activated yet when this 276 * this context might not have been activated yet when this
197 * is called. 277 * is called.
198 */ 278 */
199 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); 279 pte = set_pte_filter(pte);
200 if (pte_need_exec_flush(pte, 1))
201 pte = do_dcache_icache_coherency(pte);
202 280
203 /* Perform the setting of the PTE */ 281 /* Perform the setting of the PTE */
204 __set_pte_at(mm, addr, ptep, pte, 0); 282 __set_pte_at(mm, addr, ptep, pte, 0);
@@ -215,8 +293,7 @@ int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address,
215 pte_t *ptep, pte_t entry, int dirty) 293 pte_t *ptep, pte_t entry, int dirty)
216{ 294{
217 int changed; 295 int changed;
218 if (!dirty && pte_need_exec_flush(entry, 0)) 296 entry = set_access_flags_filter(entry, vma, dirty);
219 entry = do_dcache_icache_coherency(entry);
220 changed = !pte_same(*(ptep), entry); 297 changed = !pte_same(*(ptep), entry);
221 if (changed) { 298 if (changed) {
222 if (!(vma->vm_flags & VM_HUGETLB)) 299 if (!(vma->vm_flags & VM_HUGETLB))
@@ -242,7 +319,7 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr)
242 BUG_ON(pud_none(*pud)); 319 BUG_ON(pud_none(*pud));
243 pmd = pmd_offset(pud, addr); 320 pmd = pmd_offset(pud, addr);
244 BUG_ON(!pmd_present(*pmd)); 321 BUG_ON(!pmd_present(*pmd));
245 BUG_ON(!spin_is_locked(pte_lockptr(mm, pmd))); 322 assert_spin_locked(pte_lockptr(mm, pmd));
246} 323}
247#endif /* CONFIG_DEBUG_VM */ 324#endif /* CONFIG_DEBUG_VM */
248 325
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 5422169626ba..cb96cb2e17cc 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -142,7 +142,7 @@ ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags)
142 flags |= _PAGE_DIRTY | _PAGE_HWWRITE; 142 flags |= _PAGE_DIRTY | _PAGE_HWWRITE;
143 143
144 /* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */ 144 /* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */
145 flags &= ~(_PAGE_USER | _PAGE_EXEC | _PAGE_HWEXEC); 145 flags &= ~(_PAGE_USER | _PAGE_EXEC);
146 146
147 return __ioremap_caller(addr, size, flags, __builtin_return_address(0)); 147 return __ioremap_caller(addr, size, flags, __builtin_return_address(0));
148} 148}
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index bfa7db6b2fd5..853d5565eed5 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -33,6 +33,8 @@
33#include <linux/stddef.h> 33#include <linux/stddef.h>
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/bootmem.h>
37#include <linux/lmb.h>
36 38
37#include <asm/pgalloc.h> 39#include <asm/pgalloc.h>
38#include <asm/page.h> 40#include <asm/page.h>
@@ -55,19 +57,36 @@
55 57
56unsigned long ioremap_bot = IOREMAP_BASE; 58unsigned long ioremap_bot = IOREMAP_BASE;
57 59
60
61#ifdef CONFIG_PPC_MMU_NOHASH
62static void *early_alloc_pgtable(unsigned long size)
63{
64 void *pt;
65
66 if (init_bootmem_done)
67 pt = __alloc_bootmem(size, size, __pa(MAX_DMA_ADDRESS));
68 else
69 pt = __va(lmb_alloc_base(size, size,
70 __pa(MAX_DMA_ADDRESS)));
71 memset(pt, 0, size);
72
73 return pt;
74}
75#endif /* CONFIG_PPC_MMU_NOHASH */
76
58/* 77/*
59 * map_io_page currently only called by __ioremap 78 * map_kernel_page currently only called by __ioremap
60 * map_io_page adds an entry to the ioremap page table 79 * map_kernel_page adds an entry to the ioremap page table
61 * and adds an entry to the HPT, possibly bolting it 80 * and adds an entry to the HPT, possibly bolting it
62 */ 81 */
63static int map_io_page(unsigned long ea, unsigned long pa, int flags) 82int map_kernel_page(unsigned long ea, unsigned long pa, int flags)
64{ 83{
65 pgd_t *pgdp; 84 pgd_t *pgdp;
66 pud_t *pudp; 85 pud_t *pudp;
67 pmd_t *pmdp; 86 pmd_t *pmdp;
68 pte_t *ptep; 87 pte_t *ptep;
69 88
70 if (mem_init_done) { 89 if (slab_is_available()) {
71 pgdp = pgd_offset_k(ea); 90 pgdp = pgd_offset_k(ea);
72 pudp = pud_alloc(&init_mm, pgdp, ea); 91 pudp = pud_alloc(&init_mm, pgdp, ea);
73 if (!pudp) 92 if (!pudp)
@@ -81,6 +100,35 @@ static int map_io_page(unsigned long ea, unsigned long pa, int flags)
81 set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, 100 set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT,
82 __pgprot(flags))); 101 __pgprot(flags)));
83 } else { 102 } else {
103#ifdef CONFIG_PPC_MMU_NOHASH
104 /* Warning ! This will blow up if bootmem is not initialized
105 * which our ppc64 code is keen to do that, we'll need to
106 * fix it and/or be more careful
107 */
108 pgdp = pgd_offset_k(ea);
109#ifdef PUD_TABLE_SIZE
110 if (pgd_none(*pgdp)) {
111 pudp = early_alloc_pgtable(PUD_TABLE_SIZE);
112 BUG_ON(pudp == NULL);
113 pgd_populate(&init_mm, pgdp, pudp);
114 }
115#endif /* PUD_TABLE_SIZE */
116 pudp = pud_offset(pgdp, ea);
117 if (pud_none(*pudp)) {
118 pmdp = early_alloc_pgtable(PMD_TABLE_SIZE);
119 BUG_ON(pmdp == NULL);
120 pud_populate(&init_mm, pudp, pmdp);
121 }
122 pmdp = pmd_offset(pudp, ea);
123 if (!pmd_present(*pmdp)) {
124 ptep = early_alloc_pgtable(PAGE_SIZE);
125 BUG_ON(ptep == NULL);
126 pmd_populate_kernel(&init_mm, pmdp, ptep);
127 }
128 ptep = pte_offset_kernel(pmdp, ea);
129 set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT,
130 __pgprot(flags)));
131#else /* CONFIG_PPC_MMU_NOHASH */
84 /* 132 /*
85 * If the mm subsystem is not fully up, we cannot create a 133 * If the mm subsystem is not fully up, we cannot create a
86 * linux page table entry for this mapping. Simply bolt an 134 * linux page table entry for this mapping. Simply bolt an
@@ -93,6 +141,7 @@ static int map_io_page(unsigned long ea, unsigned long pa, int flags)
93 "memory at %016lx !\n", pa); 141 "memory at %016lx !\n", pa);
94 return -ENOMEM; 142 return -ENOMEM;
95 } 143 }
144#endif /* !CONFIG_PPC_MMU_NOHASH */
96 } 145 }
97 return 0; 146 return 0;
98} 147}
@@ -124,7 +173,7 @@ void __iomem * __ioremap_at(phys_addr_t pa, void *ea, unsigned long size,
124 WARN_ON(size & ~PAGE_MASK); 173 WARN_ON(size & ~PAGE_MASK);
125 174
126 for (i = 0; i < size; i += PAGE_SIZE) 175 for (i = 0; i < size; i += PAGE_SIZE)
127 if (map_io_page((unsigned long)ea+i, pa+i, flags)) 176 if (map_kernel_page((unsigned long)ea+i, pa+i, flags))
128 return NULL; 177 return NULL;
129 178
130 return (void __iomem *)ea; 179 return (void __iomem *)ea;
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index a685652effeb..1d98ecc8eecd 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -191,7 +191,7 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
191 unsigned long slbie_data = 0; 191 unsigned long slbie_data = 0;
192 unsigned long pc = KSTK_EIP(tsk); 192 unsigned long pc = KSTK_EIP(tsk);
193 unsigned long stack = KSTK_ESP(tsk); 193 unsigned long stack = KSTK_ESP(tsk);
194 unsigned long unmapped_base; 194 unsigned long exec_base;
195 195
196 /* 196 /*
197 * We need interrupts hard-disabled here, not just soft-disabled, 197 * We need interrupts hard-disabled here, not just soft-disabled,
@@ -227,42 +227,44 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
227 227
228 /* 228 /*
229 * preload some userspace segments into the SLB. 229 * preload some userspace segments into the SLB.
230 * Almost all 32 and 64bit PowerPC executables are linked at
231 * 0x10000000 so it makes sense to preload this segment.
230 */ 232 */
231 if (test_tsk_thread_flag(tsk, TIF_32BIT)) 233 exec_base = 0x10000000;
232 unmapped_base = TASK_UNMAPPED_BASE_USER32;
233 else
234 unmapped_base = TASK_UNMAPPED_BASE_USER64;
235 234
236 if (is_kernel_addr(pc)) 235 if (is_kernel_addr(pc) || is_kernel_addr(stack) ||
237 return; 236 is_kernel_addr(exec_base))
238 slb_allocate(pc);
239
240 if (esids_match(pc,stack))
241 return; 237 return;
242 238
243 if (is_kernel_addr(stack)) 239 slb_allocate(pc);
244 return;
245 slb_allocate(stack);
246 240
247 if (esids_match(pc,unmapped_base) || esids_match(stack,unmapped_base)) 241 if (!esids_match(pc, stack))
248 return; 242 slb_allocate(stack);
249 243
250 if (is_kernel_addr(unmapped_base)) 244 if (!esids_match(pc, exec_base) &&
251 return; 245 !esids_match(stack, exec_base))
252 slb_allocate(unmapped_base); 246 slb_allocate(exec_base);
253} 247}
254 248
255static inline void patch_slb_encoding(unsigned int *insn_addr, 249static inline void patch_slb_encoding(unsigned int *insn_addr,
256 unsigned int immed) 250 unsigned int immed)
257{ 251{
258 /* Assume the instruction had a "0" immediate value, just 252 *insn_addr = (*insn_addr & 0xffff0000) | immed;
259 * "or" in the new value
260 */
261 *insn_addr |= immed;
262 flush_icache_range((unsigned long)insn_addr, 4+ 253 flush_icache_range((unsigned long)insn_addr, 4+
263 (unsigned long)insn_addr); 254 (unsigned long)insn_addr);
264} 255}
265 256
257void slb_set_size(u16 size)
258{
259 extern unsigned int *slb_compare_rr_to_size;
260
261 if (mmu_slb_size == size)
262 return;
263
264 mmu_slb_size = size;
265 patch_slb_encoding(slb_compare_rr_to_size, mmu_slb_size);
266}
267
266void slb_initialize(void) 268void slb_initialize(void)
267{ 269{
268 unsigned long linear_llp, vmalloc_llp, io_llp; 270 unsigned long linear_llp, vmalloc_llp, io_llp;
diff --git a/arch/powerpc/mm/stab.c b/arch/powerpc/mm/stab.c
index ab5fb48b3e90..687fddaa24c5 100644
--- a/arch/powerpc/mm/stab.c
+++ b/arch/powerpc/mm/stab.c
@@ -31,7 +31,7 @@ struct stab_entry {
31 31
32#define NR_STAB_CACHE_ENTRIES 8 32#define NR_STAB_CACHE_ENTRIES 8
33static DEFINE_PER_CPU(long, stab_cache_ptr); 33static DEFINE_PER_CPU(long, stab_cache_ptr);
34static DEFINE_PER_CPU(long, stab_cache[NR_STAB_CACHE_ENTRIES]); 34static DEFINE_PER_CPU(long [NR_STAB_CACHE_ENTRIES], stab_cache);
35 35
36/* 36/*
37 * Create a segment table entry for the given esid/vsid pair. 37 * Create a segment table entry for the given esid/vsid pair.
diff --git a/arch/powerpc/mm/tlb_hash32.c b/arch/powerpc/mm/tlb_hash32.c
index 65190587a365..8aaa8b7eb324 100644
--- a/arch/powerpc/mm/tlb_hash32.c
+++ b/arch/powerpc/mm/tlb_hash32.c
@@ -71,6 +71,9 @@ void tlb_flush(struct mmu_gather *tlb)
71 */ 71 */
72 _tlbia(); 72 _tlbia();
73 } 73 }
74
75 /* Push out batch of freed page tables */
76 pte_free_finish();
74} 77}
75 78
76/* 79/*
diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c
index 937eb90677d9..2b2f35f6985e 100644
--- a/arch/powerpc/mm/tlb_hash64.c
+++ b/arch/powerpc/mm/tlb_hash64.c
@@ -33,11 +33,6 @@
33 33
34DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); 34DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
35 35
36/* This is declared as we are using the more or less generic
37 * arch/powerpc/include/asm/tlb.h file -- tgall
38 */
39DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
40
41/* 36/*
42 * A linux PTE was changed and the corresponding hash table entry 37 * A linux PTE was changed and the corresponding hash table entry
43 * neesd to be flushed. This function will either perform the flush 38 * neesd to be flushed. This function will either perform the flush
@@ -154,6 +149,21 @@ void __flush_tlb_pending(struct ppc64_tlb_batch *batch)
154 batch->index = 0; 149 batch->index = 0;
155} 150}
156 151
152void tlb_flush(struct mmu_gather *tlb)
153{
154 struct ppc64_tlb_batch *tlbbatch = &__get_cpu_var(ppc64_tlb_batch);
155
156 /* If there's a TLB batch pending, then we must flush it because the
157 * pages are going to be freed and we really don't want to have a CPU
158 * access a freed page because it has a stale TLB
159 */
160 if (tlbbatch->index)
161 __flush_tlb_pending(tlbbatch);
162
163 /* Push out batch of freed page tables */
164 pte_free_finish();
165}
166
157/** 167/**
158 * __flush_hash_table_range - Flush all HPTEs for a given address range 168 * __flush_hash_table_range - Flush all HPTEs for a given address range
159 * from the hash table (and the TLB). But keeps 169 * from the hash table (and the TLB). But keeps
diff --git a/arch/powerpc/mm/tlb_low_64e.S b/arch/powerpc/mm/tlb_low_64e.S
new file mode 100644
index 000000000000..ef1cccf71173
--- /dev/null
+++ b/arch/powerpc/mm/tlb_low_64e.S
@@ -0,0 +1,770 @@
1/*
2 * Low leve TLB miss handlers for Book3E
3 *
4 * Copyright (C) 2008-2009
5 * Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <asm/processor.h>
14#include <asm/reg.h>
15#include <asm/page.h>
16#include <asm/mmu.h>
17#include <asm/ppc_asm.h>
18#include <asm/asm-offsets.h>
19#include <asm/cputable.h>
20#include <asm/pgtable.h>
21#include <asm/reg.h>
22#include <asm/exception-64e.h>
23#include <asm/ppc-opcode.h>
24
25#ifdef CONFIG_PPC_64K_PAGES
26#define VPTE_PMD_SHIFT (PTE_INDEX_SIZE+1)
27#else
28#define VPTE_PMD_SHIFT (PTE_INDEX_SIZE)
29#endif
30#define VPTE_PUD_SHIFT (VPTE_PMD_SHIFT + PMD_INDEX_SIZE)
31#define VPTE_PGD_SHIFT (VPTE_PUD_SHIFT + PUD_INDEX_SIZE)
32#define VPTE_INDEX_SIZE (VPTE_PGD_SHIFT + PGD_INDEX_SIZE)
33
34
35/**********************************************************************
36 * *
37 * TLB miss handling for Book3E with TLB reservation and HES support *
38 * *
39 **********************************************************************/
40
41
42/* Data TLB miss */
43 START_EXCEPTION(data_tlb_miss)
44 TLB_MISS_PROLOG
45
46 /* Now we handle the fault proper. We only save DEAR in normal
47 * fault case since that's the only interesting values here.
48 * We could probably also optimize by not saving SRR0/1 in the
49 * linear mapping case but I'll leave that for later
50 */
51 mfspr r14,SPRN_ESR
52 mfspr r16,SPRN_DEAR /* get faulting address */
53 srdi r15,r16,60 /* get region */
54 cmpldi cr0,r15,0xc /* linear mapping ? */
55 TLB_MISS_STATS_SAVE_INFO
56 beq tlb_load_linear /* yes -> go to linear map load */
57
58 /* The page tables are mapped virtually linear. At this point, though,
59 * we don't know whether we are trying to fault in a first level
60 * virtual address or a virtual page table address. We can get that
61 * from bit 0x1 of the region ID which we have set for a page table
62 */
63 andi. r10,r15,0x1
64 bne- virt_page_table_tlb_miss
65
66 std r14,EX_TLB_ESR(r12); /* save ESR */
67 std r16,EX_TLB_DEAR(r12); /* save DEAR */
68
69 /* We need _PAGE_PRESENT and _PAGE_ACCESSED set */
70 li r11,_PAGE_PRESENT
71 oris r11,r11,_PAGE_ACCESSED@h
72
73 /* We do the user/kernel test for the PID here along with the RW test
74 */
75 cmpldi cr0,r15,0 /* Check for user region */
76
77 /* We pre-test some combination of permissions to avoid double
78 * faults:
79 *
80 * We move the ESR:ST bit into the position of _PAGE_BAP_SW in the PTE
81 * ESR_ST is 0x00800000
82 * _PAGE_BAP_SW is 0x00000010
83 * So the shift is >> 19. This tests for supervisor writeability.
84 * If the page happens to be supervisor writeable and not user
85 * writeable, we will take a new fault later, but that should be
86 * a rare enough case.
87 *
88 * We also move ESR_ST in _PAGE_DIRTY position
89 * _PAGE_DIRTY is 0x00001000 so the shift is >> 11
90 *
91 * MAS1 is preset for all we need except for TID that needs to
92 * be cleared for kernel translations
93 */
94 rlwimi r11,r14,32-19,27,27
95 rlwimi r11,r14,32-16,19,19
96 beq normal_tlb_miss
97 /* XXX replace the RMW cycles with immediate loads + writes */
981: mfspr r10,SPRN_MAS1
99 cmpldi cr0,r15,8 /* Check for vmalloc region */
100 rlwinm r10,r10,0,16,1 /* Clear TID */
101 mtspr SPRN_MAS1,r10
102 beq+ normal_tlb_miss
103
104 /* We got a crappy address, just fault with whatever DEAR and ESR
105 * are here
106 */
107 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
108 TLB_MISS_EPILOG_ERROR
109 b exc_data_storage_book3e
110
111/* Instruction TLB miss */
112 START_EXCEPTION(instruction_tlb_miss)
113 TLB_MISS_PROLOG
114
115 /* If we take a recursive fault, the second level handler may need
116 * to know whether we are handling a data or instruction fault in
117 * order to get to the right store fault handler. We provide that
118 * info by writing a crazy value in ESR in our exception frame
119 */
120 li r14,-1 /* store to exception frame is done later */
121
122 /* Now we handle the fault proper. We only save DEAR in the non
123 * linear mapping case since we know the linear mapping case will
124 * not re-enter. We could indeed optimize and also not save SRR0/1
125 * in the linear mapping case but I'll leave that for later
126 *
127 * Faulting address is SRR0 which is already in r16
128 */
129 srdi r15,r16,60 /* get region */
130 cmpldi cr0,r15,0xc /* linear mapping ? */
131 TLB_MISS_STATS_SAVE_INFO
132 beq tlb_load_linear /* yes -> go to linear map load */
133
134 /* We do the user/kernel test for the PID here along with the RW test
135 */
136 li r11,_PAGE_PRESENT|_PAGE_EXEC /* Base perm */
137 oris r11,r11,_PAGE_ACCESSED@h
138
139 cmpldi cr0,r15,0 /* Check for user region */
140 std r14,EX_TLB_ESR(r12) /* write crazy -1 to frame */
141 beq normal_tlb_miss
142 /* XXX replace the RMW cycles with immediate loads + writes */
1431: mfspr r10,SPRN_MAS1
144 cmpldi cr0,r15,8 /* Check for vmalloc region */
145 rlwinm r10,r10,0,16,1 /* Clear TID */
146 mtspr SPRN_MAS1,r10
147 beq+ normal_tlb_miss
148
149 /* We got a crappy address, just fault */
150 TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
151 TLB_MISS_EPILOG_ERROR
152 b exc_instruction_storage_book3e
153
154/*
155 * This is the guts of the first-level TLB miss handler for direct
156 * misses. We are entered with:
157 *
158 * r16 = faulting address
159 * r15 = region ID
160 * r14 = crap (free to use)
161 * r13 = PACA
162 * r12 = TLB exception frame in PACA
163 * r11 = PTE permission mask
164 * r10 = crap (free to use)
165 */
166normal_tlb_miss:
167 /* So we first construct the page table address. We do that by
168 * shifting the bottom of the address (not the region ID) by
169 * PAGE_SHIFT-3, clearing the bottom 3 bits (get a PTE ptr) and
170 * or'ing the fourth high bit.
171 *
172 * NOTE: For 64K pages, we do things slightly differently in
173 * order to handle the weird page table format used by linux
174 */
175 ori r10,r15,0x1
176#ifdef CONFIG_PPC_64K_PAGES
177 /* For the top bits, 16 bytes per PTE */
178 rldicl r14,r16,64-(PAGE_SHIFT-4),PAGE_SHIFT-4+4
179 /* Now create the bottom bits as 0 in position 0x8000 and
180 * the rest calculated for 8 bytes per PTE
181 */
182 rldicl r15,r16,64-(PAGE_SHIFT-3),64-15
183 /* Insert the bottom bits in */
184 rlwimi r14,r15,0,16,31
185#else
186 rldicl r14,r16,64-(PAGE_SHIFT-3),PAGE_SHIFT-3+4
187#endif
188 sldi r15,r10,60
189 clrrdi r14,r14,3
190 or r10,r15,r14
191
192BEGIN_MMU_FTR_SECTION
193 /* Set the TLB reservation and seach for existing entry. Then load
194 * the entry.
195 */
196 PPC_TLBSRX_DOT(0,r16)
197 ld r14,0(r10)
198 beq normal_tlb_miss_done
199MMU_FTR_SECTION_ELSE
200 ld r14,0(r10)
201ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_USE_TLBRSRV)
202
203finish_normal_tlb_miss:
204 /* Check if required permissions are met */
205 andc. r15,r11,r14
206 bne- normal_tlb_miss_access_fault
207
208 /* Now we build the MAS:
209 *
210 * MAS 0 : Fully setup with defaults in MAS4 and TLBnCFG
211 * MAS 1 : Almost fully setup
212 * - PID already updated by caller if necessary
213 * - TSIZE need change if !base page size, not
214 * yet implemented for now
215 * MAS 2 : Defaults not useful, need to be redone
216 * MAS 3+7 : Needs to be done
217 *
218 * TODO: mix up code below for better scheduling
219 */
220 clrrdi r11,r16,12 /* Clear low crap in EA */
221 rlwimi r11,r14,32-19,27,31 /* Insert WIMGE */
222 mtspr SPRN_MAS2,r11
223
224 /* Check page size, if not standard, update MAS1 */
225 rldicl r11,r14,64-8,64-8
226#ifdef CONFIG_PPC_64K_PAGES
227 cmpldi cr0,r11,BOOK3E_PAGESZ_64K
228#else
229 cmpldi cr0,r11,BOOK3E_PAGESZ_4K
230#endif
231 beq- 1f
232 mfspr r11,SPRN_MAS1
233 rlwimi r11,r14,31,21,24
234 rlwinm r11,r11,0,21,19
235 mtspr SPRN_MAS1,r11
2361:
237 /* Move RPN in position */
238 rldicr r11,r14,64-(PTE_RPN_SHIFT-PAGE_SHIFT),63-PAGE_SHIFT
239 clrldi r15,r11,12 /* Clear crap at the top */
240 rlwimi r15,r14,32-8,22,25 /* Move in U bits */
241 rlwimi r15,r14,32-2,26,31 /* Move in BAP bits */
242
243 /* Mask out SW and UW if !DIRTY (XXX optimize this !) */
244 andi. r11,r14,_PAGE_DIRTY
245 bne 1f
246 li r11,MAS3_SW|MAS3_UW
247 andc r15,r15,r11
2481:
249BEGIN_MMU_FTR_SECTION
250 srdi r16,r15,32
251 mtspr SPRN_MAS3,r15
252 mtspr SPRN_MAS7,r16
253MMU_FTR_SECTION_ELSE
254 mtspr SPRN_MAS7_MAS3,r15
255ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
256
257 tlbwe
258
259normal_tlb_miss_done:
260 /* We don't bother with restoring DEAR or ESR since we know we are
261 * level 0 and just going back to userland. They are only needed
262 * if you are going to take an access fault
263 */
264 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_NORM_OK)
265 TLB_MISS_EPILOG_SUCCESS
266 rfi
267
268normal_tlb_miss_access_fault:
269 /* We need to check if it was an instruction miss */
270 andi. r10,r11,_PAGE_EXEC
271 bne 1f
272 ld r14,EX_TLB_DEAR(r12)
273 ld r15,EX_TLB_ESR(r12)
274 mtspr SPRN_DEAR,r14
275 mtspr SPRN_ESR,r15
276 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
277 TLB_MISS_EPILOG_ERROR
278 b exc_data_storage_book3e
2791: TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
280 TLB_MISS_EPILOG_ERROR
281 b exc_instruction_storage_book3e
282
283
284/*
285 * This is the guts of the second-level TLB miss handler for direct
286 * misses. We are entered with:
287 *
288 * r16 = virtual page table faulting address
289 * r15 = region (top 4 bits of address)
290 * r14 = crap (free to use)
291 * r13 = PACA
292 * r12 = TLB exception frame in PACA
293 * r11 = crap (free to use)
294 * r10 = crap (free to use)
295 *
296 * Note that this should only ever be called as a second level handler
297 * with the current scheme when using SW load.
298 * That means we can always get the original fault DEAR at
299 * EX_TLB_DEAR-EX_TLB_SIZE(r12)
300 *
301 * It can be re-entered by the linear mapping miss handler. However, to
302 * avoid too much complication, it will restart the whole fault at level
303 * 0 so we don't care too much about clobbers
304 *
305 * XXX That code was written back when we couldn't clobber r14. We can now,
306 * so we could probably optimize things a bit
307 */
308virt_page_table_tlb_miss:
309 /* Are we hitting a kernel page table ? */
310 andi. r10,r15,0x8
311
312 /* The cool thing now is that r10 contains 0 for user and 8 for kernel,
313 * and we happen to have the swapper_pg_dir at offset 8 from the user
314 * pgdir in the PACA :-).
315 */
316 add r11,r10,r13
317
318 /* If kernel, we need to clear MAS1 TID */
319 beq 1f
320 /* XXX replace the RMW cycles with immediate loads + writes */
321 mfspr r10,SPRN_MAS1
322 rlwinm r10,r10,0,16,1 /* Clear TID */
323 mtspr SPRN_MAS1,r10
3241:
325BEGIN_MMU_FTR_SECTION
326 /* Search if we already have a TLB entry for that virtual address, and
327 * if we do, bail out.
328 */
329 PPC_TLBSRX_DOT(0,r16)
330 beq virt_page_table_tlb_miss_done
331END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_TLBRSRV)
332
333 /* Now, we need to walk the page tables. First check if we are in
334 * range.
335 */
336 rldicl. r10,r16,64-(VPTE_INDEX_SIZE+3),VPTE_INDEX_SIZE+3+4
337 bne- virt_page_table_tlb_miss_fault
338
339 /* Get the PGD pointer */
340 ld r15,PACAPGD(r11)
341 cmpldi cr0,r15,0
342 beq- virt_page_table_tlb_miss_fault
343
344 /* Get to PGD entry */
345 rldicl r11,r16,64-VPTE_PGD_SHIFT,64-PGD_INDEX_SIZE-3
346 clrrdi r10,r11,3
347 ldx r15,r10,r15
348 cmpldi cr0,r15,0
349 beq virt_page_table_tlb_miss_fault
350
351#ifndef CONFIG_PPC_64K_PAGES
352 /* Get to PUD entry */
353 rldicl r11,r16,64-VPTE_PUD_SHIFT,64-PUD_INDEX_SIZE-3
354 clrrdi r10,r11,3
355 ldx r15,r10,r15
356 cmpldi cr0,r15,0
357 beq virt_page_table_tlb_miss_fault
358#endif /* CONFIG_PPC_64K_PAGES */
359
360 /* Get to PMD entry */
361 rldicl r11,r16,64-VPTE_PMD_SHIFT,64-PMD_INDEX_SIZE-3
362 clrrdi r10,r11,3
363 ldx r15,r10,r15
364 cmpldi cr0,r15,0
365 beq virt_page_table_tlb_miss_fault
366
367 /* Ok, we're all right, we can now create a kernel translation for
368 * a 4K or 64K page from r16 -> r15.
369 */
370 /* Now we build the MAS:
371 *
372 * MAS 0 : Fully setup with defaults in MAS4 and TLBnCFG
373 * MAS 1 : Almost fully setup
374 * - PID already updated by caller if necessary
375 * - TSIZE for now is base page size always
376 * MAS 2 : Use defaults
377 * MAS 3+7 : Needs to be done
378 *
379 * So we only do MAS 2 and 3 for now...
380 */
381 clrldi r11,r15,4 /* remove region ID from RPN */
382 ori r10,r11,1 /* Or-in SR */
383
384BEGIN_MMU_FTR_SECTION
385 srdi r16,r10,32
386 mtspr SPRN_MAS3,r10
387 mtspr SPRN_MAS7,r16
388MMU_FTR_SECTION_ELSE
389 mtspr SPRN_MAS7_MAS3,r10
390ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
391
392 tlbwe
393
394BEGIN_MMU_FTR_SECTION
395virt_page_table_tlb_miss_done:
396
397 /* We have overriden MAS2:EPN but currently our primary TLB miss
398 * handler will always restore it so that should not be an issue,
399 * if we ever optimize the primary handler to not write MAS2 on
400 * some cases, we'll have to restore MAS2:EPN here based on the
401 * original fault's DEAR. If we do that we have to modify the
402 * ITLB miss handler to also store SRR0 in the exception frame
403 * as DEAR.
404 *
405 * However, one nasty thing we did is we cleared the reservation
406 * (well, potentially we did). We do a trick here thus if we
407 * are not a level 0 exception (we interrupted the TLB miss) we
408 * offset the return address by -4 in order to replay the tlbsrx
409 * instruction there
410 */
411 subf r10,r13,r12
412 cmpldi cr0,r10,PACA_EXTLB+EX_TLB_SIZE
413 bne- 1f
414 ld r11,PACA_EXTLB+EX_TLB_SIZE+EX_TLB_SRR0(r13)
415 addi r10,r11,-4
416 std r10,PACA_EXTLB+EX_TLB_SIZE+EX_TLB_SRR0(r13)
4171:
418END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_TLBRSRV)
419 /* Return to caller, normal case */
420 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_PT_OK);
421 TLB_MISS_EPILOG_SUCCESS
422 rfi
423
424virt_page_table_tlb_miss_fault:
425 /* If we fault here, things are a little bit tricky. We need to call
426 * either data or instruction store fault, and we need to retreive
427 * the original fault address and ESR (for data).
428 *
429 * The thing is, we know that in normal circumstances, this is
430 * always called as a second level tlb miss for SW load or as a first
431 * level TLB miss for HW load, so we should be able to peek at the
432 * relevant informations in the first exception frame in the PACA.
433 *
434 * However, we do need to double check that, because we may just hit
435 * a stray kernel pointer or a userland attack trying to hit those
436 * areas. If that is the case, we do a data fault. (We can't get here
437 * from an instruction tlb miss anyway).
438 *
439 * Note also that when going to a fault, we must unwind the previous
440 * level as well. Since we are doing that, we don't need to clear or
441 * restore the TLB reservation neither.
442 */
443 subf r10,r13,r12
444 cmpldi cr0,r10,PACA_EXTLB+EX_TLB_SIZE
445 bne- virt_page_table_tlb_miss_whacko_fault
446
447 /* We dig the original DEAR and ESR from slot 0 */
448 ld r15,EX_TLB_DEAR+PACA_EXTLB(r13)
449 ld r16,EX_TLB_ESR+PACA_EXTLB(r13)
450
451 /* We check for the "special" ESR value for instruction faults */
452 cmpdi cr0,r16,-1
453 beq 1f
454 mtspr SPRN_DEAR,r15
455 mtspr SPRN_ESR,r16
456 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_PT_FAULT);
457 TLB_MISS_EPILOG_ERROR
458 b exc_data_storage_book3e
4591: TLB_MISS_STATS_I(MMSTAT_TLB_MISS_PT_FAULT);
460 TLB_MISS_EPILOG_ERROR
461 b exc_instruction_storage_book3e
462
463virt_page_table_tlb_miss_whacko_fault:
464 /* The linear fault will restart everything so ESR and DEAR will
465 * not have been clobbered, let's just fault with what we have
466 */
467 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_PT_FAULT);
468 TLB_MISS_EPILOG_ERROR
469 b exc_data_storage_book3e
470
471
472/**************************************************************
473 * *
474 * TLB miss handling for Book3E with hw page table support *
475 * *
476 **************************************************************/
477
478
479/* Data TLB miss */
480 START_EXCEPTION(data_tlb_miss_htw)
481 TLB_MISS_PROLOG
482
483 /* Now we handle the fault proper. We only save DEAR in normal
484 * fault case since that's the only interesting values here.
485 * We could probably also optimize by not saving SRR0/1 in the
486 * linear mapping case but I'll leave that for later
487 */
488 mfspr r14,SPRN_ESR
489 mfspr r16,SPRN_DEAR /* get faulting address */
490 srdi r11,r16,60 /* get region */
491 cmpldi cr0,r11,0xc /* linear mapping ? */
492 TLB_MISS_STATS_SAVE_INFO
493 beq tlb_load_linear /* yes -> go to linear map load */
494
495 /* We do the user/kernel test for the PID here along with the RW test
496 */
497 cmpldi cr0,r11,0 /* Check for user region */
498 ld r15,PACAPGD(r13) /* Load user pgdir */
499 beq htw_tlb_miss
500
501 /* XXX replace the RMW cycles with immediate loads + writes */
5021: mfspr r10,SPRN_MAS1
503 cmpldi cr0,r11,8 /* Check for vmalloc region */
504 rlwinm r10,r10,0,16,1 /* Clear TID */
505 mtspr SPRN_MAS1,r10
506 ld r15,PACA_KERNELPGD(r13) /* Load kernel pgdir */
507 beq+ htw_tlb_miss
508
509 /* We got a crappy address, just fault with whatever DEAR and ESR
510 * are here
511 */
512 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_NORM_FAULT)
513 TLB_MISS_EPILOG_ERROR
514 b exc_data_storage_book3e
515
516/* Instruction TLB miss */
517 START_EXCEPTION(instruction_tlb_miss_htw)
518 TLB_MISS_PROLOG
519
520 /* If we take a recursive fault, the second level handler may need
521 * to know whether we are handling a data or instruction fault in
522 * order to get to the right store fault handler. We provide that
523 * info by keeping a crazy value for ESR in r14
524 */
525 li r14,-1 /* store to exception frame is done later */
526
527 /* Now we handle the fault proper. We only save DEAR in the non
528 * linear mapping case since we know the linear mapping case will
529 * not re-enter. We could indeed optimize and also not save SRR0/1
530 * in the linear mapping case but I'll leave that for later
531 *
532 * Faulting address is SRR0 which is already in r16
533 */
534 srdi r11,r16,60 /* get region */
535 cmpldi cr0,r11,0xc /* linear mapping ? */
536 TLB_MISS_STATS_SAVE_INFO
537 beq tlb_load_linear /* yes -> go to linear map load */
538
539 /* We do the user/kernel test for the PID here along with the RW test
540 */
541 cmpldi cr0,r11,0 /* Check for user region */
542 ld r15,PACAPGD(r13) /* Load user pgdir */
543 beq htw_tlb_miss
544
545 /* XXX replace the RMW cycles with immediate loads + writes */
5461: mfspr r10,SPRN_MAS1
547 cmpldi cr0,r11,8 /* Check for vmalloc region */
548 rlwinm r10,r10,0,16,1 /* Clear TID */
549 mtspr SPRN_MAS1,r10
550 ld r15,PACA_KERNELPGD(r13) /* Load kernel pgdir */
551 beq+ htw_tlb_miss
552
553 /* We got a crappy address, just fault */
554 TLB_MISS_STATS_I(MMSTAT_TLB_MISS_NORM_FAULT)
555 TLB_MISS_EPILOG_ERROR
556 b exc_instruction_storage_book3e
557
558
559/*
560 * This is the guts of the second-level TLB miss handler for direct
561 * misses. We are entered with:
562 *
563 * r16 = virtual page table faulting address
564 * r15 = PGD pointer
565 * r14 = ESR
566 * r13 = PACA
567 * r12 = TLB exception frame in PACA
568 * r11 = crap (free to use)
569 * r10 = crap (free to use)
570 *
571 * It can be re-entered by the linear mapping miss handler. However, to
572 * avoid too much complication, it will save/restore things for us
573 */
574htw_tlb_miss:
575 /* Search if we already have a TLB entry for that virtual address, and
576 * if we do, bail out.
577 *
578 * MAS1:IND should be already set based on MAS4
579 */
580 PPC_TLBSRX_DOT(0,r16)
581 beq htw_tlb_miss_done
582
583 /* Now, we need to walk the page tables. First check if we are in
584 * range.
585 */
586 rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4
587 bne- htw_tlb_miss_fault
588
589 /* Get the PGD pointer */
590 cmpldi cr0,r15,0
591 beq- htw_tlb_miss_fault
592
593 /* Get to PGD entry */
594 rldicl r11,r16,64-(PGDIR_SHIFT-3),64-PGD_INDEX_SIZE-3
595 clrrdi r10,r11,3
596 ldx r15,r10,r15
597 cmpldi cr0,r15,0
598 beq htw_tlb_miss_fault
599
600#ifndef CONFIG_PPC_64K_PAGES
601 /* Get to PUD entry */
602 rldicl r11,r16,64-(PUD_SHIFT-3),64-PUD_INDEX_SIZE-3
603 clrrdi r10,r11,3
604 ldx r15,r10,r15
605 cmpldi cr0,r15,0
606 beq htw_tlb_miss_fault
607#endif /* CONFIG_PPC_64K_PAGES */
608
609 /* Get to PMD entry */
610 rldicl r11,r16,64-(PMD_SHIFT-3),64-PMD_INDEX_SIZE-3
611 clrrdi r10,r11,3
612 ldx r15,r10,r15
613 cmpldi cr0,r15,0
614 beq htw_tlb_miss_fault
615
616 /* Ok, we're all right, we can now create an indirect entry for
617 * a 1M or 256M page.
618 *
619 * The last trick is now that because we use "half" pages for
620 * the HTW (1M IND is 2K and 256M IND is 32K) we need to account
621 * for an added LSB bit to the RPN. For 64K pages, there is no
622 * problem as we already use 32K arrays (half PTE pages), but for
623 * 4K page we need to extract a bit from the virtual address and
624 * insert it into the "PA52" bit of the RPN.
625 */
626#ifndef CONFIG_PPC_64K_PAGES
627 rlwimi r15,r16,32-9,20,20
628#endif
629 /* Now we build the MAS:
630 *
631 * MAS 0 : Fully setup with defaults in MAS4 and TLBnCFG
632 * MAS 1 : Almost fully setup
633 * - PID already updated by caller if necessary
634 * - TSIZE for now is base ind page size always
635 * MAS 2 : Use defaults
636 * MAS 3+7 : Needs to be done
637 */
638#ifdef CONFIG_PPC_64K_PAGES
639 ori r10,r15,(BOOK3E_PAGESZ_64K << MAS3_SPSIZE_SHIFT)
640#else
641 ori r10,r15,(BOOK3E_PAGESZ_4K << MAS3_SPSIZE_SHIFT)
642#endif
643
644BEGIN_MMU_FTR_SECTION
645 srdi r16,r10,32
646 mtspr SPRN_MAS3,r10
647 mtspr SPRN_MAS7,r16
648MMU_FTR_SECTION_ELSE
649 mtspr SPRN_MAS7_MAS3,r10
650ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
651
652 tlbwe
653
654htw_tlb_miss_done:
655 /* We don't bother with restoring DEAR or ESR since we know we are
656 * level 0 and just going back to userland. They are only needed
657 * if you are going to take an access fault
658 */
659 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_PT_OK)
660 TLB_MISS_EPILOG_SUCCESS
661 rfi
662
663htw_tlb_miss_fault:
664 /* We need to check if it was an instruction miss. We know this
665 * though because r14 would contain -1
666 */
667 cmpdi cr0,r14,-1
668 beq 1f
669 mtspr SPRN_DEAR,r16
670 mtspr SPRN_ESR,r14
671 TLB_MISS_STATS_D(MMSTAT_TLB_MISS_PT_FAULT)
672 TLB_MISS_EPILOG_ERROR
673 b exc_data_storage_book3e
6741: TLB_MISS_STATS_I(MMSTAT_TLB_MISS_PT_FAULT)
675 TLB_MISS_EPILOG_ERROR
676 b exc_instruction_storage_book3e
677
678/*
679 * This is the guts of "any" level TLB miss handler for kernel linear
680 * mapping misses. We are entered with:
681 *
682 *
683 * r16 = faulting address
684 * r15 = crap (free to use)
685 * r14 = ESR (data) or -1 (instruction)
686 * r13 = PACA
687 * r12 = TLB exception frame in PACA
688 * r11 = crap (free to use)
689 * r10 = crap (free to use)
690 *
691 * In addition we know that we will not re-enter, so in theory, we could
692 * use a simpler epilog not restoring SRR0/1 etc.. but we'll do that later.
693 *
694 * We also need to be careful about MAS registers here & TLB reservation,
695 * as we know we'll have clobbered them if we interrupt the main TLB miss
696 * handlers in which case we probably want to do a full restart at level
697 * 0 rather than saving / restoring the MAS.
698 *
699 * Note: If we care about performance of that core, we can easily shuffle
700 * a few things around
701 */
702tlb_load_linear:
703 /* For now, we assume the linear mapping is contiguous and stops at
704 * linear_map_top. We also assume the size is a multiple of 1G, thus
705 * we only use 1G pages for now. That might have to be changed in a
706 * final implementation, especially when dealing with hypervisors
707 */
708 ld r11,PACATOC(r13)
709 ld r11,linear_map_top@got(r11)
710 ld r10,0(r11)
711 cmpld cr0,r10,r16
712 bge tlb_load_linear_fault
713
714 /* MAS1 need whole new setup. */
715 li r15,(BOOK3E_PAGESZ_1GB<<MAS1_TSIZE_SHIFT)
716 oris r15,r15,MAS1_VALID@h /* MAS1 needs V and TSIZE */
717 mtspr SPRN_MAS1,r15
718
719 /* Already somebody there ? */
720 PPC_TLBSRX_DOT(0,r16)
721 beq tlb_load_linear_done
722
723 /* Now we build the remaining MAS. MAS0 and 2 should be fine
724 * with their defaults, which leaves us with MAS 3 and 7. The
725 * mapping is linear, so we just take the address, clear the
726 * region bits, and or in the permission bits which are currently
727 * hard wired
728 */
729 clrrdi r10,r16,30 /* 1G page index */
730 clrldi r10,r10,4 /* clear region bits */
731 ori r10,r10,MAS3_SR|MAS3_SW|MAS3_SX
732
733BEGIN_MMU_FTR_SECTION
734 srdi r16,r10,32
735 mtspr SPRN_MAS3,r10
736 mtspr SPRN_MAS7,r16
737MMU_FTR_SECTION_ELSE
738 mtspr SPRN_MAS7_MAS3,r10
739ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_PAIRED_MAS)
740
741 tlbwe
742
743tlb_load_linear_done:
744 /* We use the "error" epilog for success as we do want to
745 * restore to the initial faulting context, whatever it was.
746 * We do that because we can't resume a fault within a TLB
747 * miss handler, due to MAS and TLB reservation being clobbered.
748 */
749 TLB_MISS_STATS_X(MMSTAT_TLB_MISS_LINEAR)
750 TLB_MISS_EPILOG_ERROR
751 rfi
752
753tlb_load_linear_fault:
754 /* We keep the DEAR and ESR around, this shouldn't have happened */
755 cmpdi cr0,r14,-1
756 beq 1f
757 TLB_MISS_EPILOG_ERROR_SPECIAL
758 b exc_data_storage_book3e
7591: TLB_MISS_EPILOG_ERROR_SPECIAL
760 b exc_instruction_storage_book3e
761
762
763#ifdef CONFIG_BOOK3E_MMU_TLB_STATS
764.tlb_stat_inc:
7651: ldarx r8,0,r9
766 addi r8,r8,1
767 stdcx. r8,0,r9
768 bne- 1b
769 blr
770#endif
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index ad2eb4d34dd4..2fbc680c2c71 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -7,8 +7,8 @@
7 * 7 *
8 * -- BenH 8 * -- BenH
9 * 9 *
10 * Copyright 2008 Ben Herrenschmidt <benh@kernel.crashing.org> 10 * Copyright 2008,2009 Ben Herrenschmidt <benh@kernel.crashing.org>
11 * IBM Corp. 11 * IBM Corp.
12 * 12 *
13 * Derived from arch/ppc/mm/init.c: 13 * Derived from arch/ppc/mm/init.c:
14 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 14 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
@@ -34,12 +34,71 @@
34#include <linux/pagemap.h> 34#include <linux/pagemap.h>
35#include <linux/preempt.h> 35#include <linux/preempt.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/lmb.h>
37 38
38#include <asm/tlbflush.h> 39#include <asm/tlbflush.h>
39#include <asm/tlb.h> 40#include <asm/tlb.h>
41#include <asm/code-patching.h>
40 42
41#include "mmu_decl.h" 43#include "mmu_decl.h"
42 44
45#ifdef CONFIG_PPC_BOOK3E
46struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT] = {
47 [MMU_PAGE_4K] = {
48 .shift = 12,
49 .enc = BOOK3E_PAGESZ_4K,
50 },
51 [MMU_PAGE_16K] = {
52 .shift = 14,
53 .enc = BOOK3E_PAGESZ_16K,
54 },
55 [MMU_PAGE_64K] = {
56 .shift = 16,
57 .enc = BOOK3E_PAGESZ_64K,
58 },
59 [MMU_PAGE_1M] = {
60 .shift = 20,
61 .enc = BOOK3E_PAGESZ_1M,
62 },
63 [MMU_PAGE_16M] = {
64 .shift = 24,
65 .enc = BOOK3E_PAGESZ_16M,
66 },
67 [MMU_PAGE_256M] = {
68 .shift = 28,
69 .enc = BOOK3E_PAGESZ_256M,
70 },
71 [MMU_PAGE_1G] = {
72 .shift = 30,
73 .enc = BOOK3E_PAGESZ_1GB,
74 },
75};
76static inline int mmu_get_tsize(int psize)
77{
78 return mmu_psize_defs[psize].enc;
79}
80#else
81static inline int mmu_get_tsize(int psize)
82{
83 /* This isn't used on !Book3E for now */
84 return 0;
85}
86#endif
87
88/* The variables below are currently only used on 64-bit Book3E
89 * though this will probably be made common with other nohash
90 * implementations at some point
91 */
92#ifdef CONFIG_PPC64
93
94int mmu_linear_psize; /* Page size used for the linear mapping */
95int mmu_pte_psize; /* Page size used for PTE pages */
96int mmu_vmemmap_psize; /* Page size used for the virtual mem map */
97int book3e_htw_enabled; /* Is HW tablewalk enabled ? */
98unsigned long linear_map_top; /* Top of linear mapping */
99
100#endif /* CONFIG_PPC64 */
101
43/* 102/*
44 * Base TLB flushing operations: 103 * Base TLB flushing operations:
45 * 104 *
@@ -67,18 +126,24 @@ void local_flush_tlb_mm(struct mm_struct *mm)
67} 126}
68EXPORT_SYMBOL(local_flush_tlb_mm); 127EXPORT_SYMBOL(local_flush_tlb_mm);
69 128
70void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr) 129void __local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
130 int tsize, int ind)
71{ 131{
72 unsigned int pid; 132 unsigned int pid;
73 133
74 preempt_disable(); 134 preempt_disable();
75 pid = vma ? vma->vm_mm->context.id : 0; 135 pid = mm ? mm->context.id : 0;
76 if (pid != MMU_NO_CONTEXT) 136 if (pid != MMU_NO_CONTEXT)
77 _tlbil_va(vmaddr, pid); 137 _tlbil_va(vmaddr, pid, tsize, ind);
78 preempt_enable(); 138 preempt_enable();
79} 139}
80EXPORT_SYMBOL(local_flush_tlb_page);
81 140
141void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
142{
143 __local_flush_tlb_page(vma ? vma->vm_mm : NULL, vmaddr,
144 mmu_get_tsize(mmu_virtual_psize), 0);
145}
146EXPORT_SYMBOL(local_flush_tlb_page);
82 147
83/* 148/*
84 * And here are the SMP non-local implementations 149 * And here are the SMP non-local implementations
@@ -87,9 +152,17 @@ EXPORT_SYMBOL(local_flush_tlb_page);
87 152
88static DEFINE_SPINLOCK(tlbivax_lock); 153static DEFINE_SPINLOCK(tlbivax_lock);
89 154
155static int mm_is_core_local(struct mm_struct *mm)
156{
157 return cpumask_subset(mm_cpumask(mm),
158 topology_thread_cpumask(smp_processor_id()));
159}
160
90struct tlb_flush_param { 161struct tlb_flush_param {
91 unsigned long addr; 162 unsigned long addr;
92 unsigned int pid; 163 unsigned int pid;
164 unsigned int tsize;
165 unsigned int ind;
93}; 166};
94 167
95static void do_flush_tlb_mm_ipi(void *param) 168static void do_flush_tlb_mm_ipi(void *param)
@@ -103,7 +176,7 @@ static void do_flush_tlb_page_ipi(void *param)
103{ 176{
104 struct tlb_flush_param *p = param; 177 struct tlb_flush_param *p = param;
105 178
106 _tlbil_va(p->addr, p->pid); 179 _tlbil_va(p->addr, p->pid, p->tsize, p->ind);
107} 180}
108 181
109 182
@@ -131,7 +204,7 @@ void flush_tlb_mm(struct mm_struct *mm)
131 pid = mm->context.id; 204 pid = mm->context.id;
132 if (unlikely(pid == MMU_NO_CONTEXT)) 205 if (unlikely(pid == MMU_NO_CONTEXT))
133 goto no_context; 206 goto no_context;
134 if (!cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) { 207 if (!mm_is_core_local(mm)) {
135 struct tlb_flush_param p = { .pid = pid }; 208 struct tlb_flush_param p = { .pid = pid };
136 /* Ignores smp_processor_id() even if set. */ 209 /* Ignores smp_processor_id() even if set. */
137 smp_call_function_many(mm_cpumask(mm), 210 smp_call_function_many(mm_cpumask(mm),
@@ -143,37 +216,49 @@ void flush_tlb_mm(struct mm_struct *mm)
143} 216}
144EXPORT_SYMBOL(flush_tlb_mm); 217EXPORT_SYMBOL(flush_tlb_mm);
145 218
146void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr) 219void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
220 int tsize, int ind)
147{ 221{
148 struct cpumask *cpu_mask; 222 struct cpumask *cpu_mask;
149 unsigned int pid; 223 unsigned int pid;
150 224
151 preempt_disable(); 225 preempt_disable();
152 pid = vma ? vma->vm_mm->context.id : 0; 226 pid = mm ? mm->context.id : 0;
153 if (unlikely(pid == MMU_NO_CONTEXT)) 227 if (unlikely(pid == MMU_NO_CONTEXT))
154 goto bail; 228 goto bail;
155 cpu_mask = mm_cpumask(vma->vm_mm); 229 cpu_mask = mm_cpumask(mm);
156 if (!cpumask_equal(cpu_mask, cpumask_of(smp_processor_id()))) { 230 if (!mm_is_core_local(mm)) {
157 /* If broadcast tlbivax is supported, use it */ 231 /* If broadcast tlbivax is supported, use it */
158 if (mmu_has_feature(MMU_FTR_USE_TLBIVAX_BCAST)) { 232 if (mmu_has_feature(MMU_FTR_USE_TLBIVAX_BCAST)) {
159 int lock = mmu_has_feature(MMU_FTR_LOCK_BCAST_INVAL); 233 int lock = mmu_has_feature(MMU_FTR_LOCK_BCAST_INVAL);
160 if (lock) 234 if (lock)
161 spin_lock(&tlbivax_lock); 235 spin_lock(&tlbivax_lock);
162 _tlbivax_bcast(vmaddr, pid); 236 _tlbivax_bcast(vmaddr, pid, tsize, ind);
163 if (lock) 237 if (lock)
164 spin_unlock(&tlbivax_lock); 238 spin_unlock(&tlbivax_lock);
165 goto bail; 239 goto bail;
166 } else { 240 } else {
167 struct tlb_flush_param p = { .pid = pid, .addr = vmaddr }; 241 struct tlb_flush_param p = {
242 .pid = pid,
243 .addr = vmaddr,
244 .tsize = tsize,
245 .ind = ind,
246 };
168 /* Ignores smp_processor_id() even if set in cpu_mask */ 247 /* Ignores smp_processor_id() even if set in cpu_mask */
169 smp_call_function_many(cpu_mask, 248 smp_call_function_many(cpu_mask,
170 do_flush_tlb_page_ipi, &p, 1); 249 do_flush_tlb_page_ipi, &p, 1);
171 } 250 }
172 } 251 }
173 _tlbil_va(vmaddr, pid); 252 _tlbil_va(vmaddr, pid, tsize, ind);
174 bail: 253 bail:
175 preempt_enable(); 254 preempt_enable();
176} 255}
256
257void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
258{
259 __flush_tlb_page(vma ? vma->vm_mm : NULL, vmaddr,
260 mmu_get_tsize(mmu_virtual_psize), 0);
261}
177EXPORT_SYMBOL(flush_tlb_page); 262EXPORT_SYMBOL(flush_tlb_page);
178 263
179#endif /* CONFIG_SMP */ 264#endif /* CONFIG_SMP */
@@ -207,3 +292,156 @@ void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
207 flush_tlb_mm(vma->vm_mm); 292 flush_tlb_mm(vma->vm_mm);
208} 293}
209EXPORT_SYMBOL(flush_tlb_range); 294EXPORT_SYMBOL(flush_tlb_range);
295
296void tlb_flush(struct mmu_gather *tlb)
297{
298 flush_tlb_mm(tlb->mm);
299
300 /* Push out batch of freed page tables */
301 pte_free_finish();
302}
303
304/*
305 * Below are functions specific to the 64-bit variant of Book3E though that
306 * may change in the future
307 */
308
309#ifdef CONFIG_PPC64
310
311/*
312 * Handling of virtual linear page tables or indirect TLB entries
313 * flushing when PTE pages are freed
314 */
315void tlb_flush_pgtable(struct mmu_gather *tlb, unsigned long address)
316{
317 int tsize = mmu_psize_defs[mmu_pte_psize].enc;
318
319 if (book3e_htw_enabled) {
320 unsigned long start = address & PMD_MASK;
321 unsigned long end = address + PMD_SIZE;
322 unsigned long size = 1UL << mmu_psize_defs[mmu_pte_psize].shift;
323
324 /* This isn't the most optimal, ideally we would factor out the
325 * while preempt & CPU mask mucking around, or even the IPI but
326 * it will do for now
327 */
328 while (start < end) {
329 __flush_tlb_page(tlb->mm, start, tsize, 1);
330 start += size;
331 }
332 } else {
333 unsigned long rmask = 0xf000000000000000ul;
334 unsigned long rid = (address & rmask) | 0x1000000000000000ul;
335 unsigned long vpte = address & ~rmask;
336
337#ifdef CONFIG_PPC_64K_PAGES
338 vpte = (vpte >> (PAGE_SHIFT - 4)) & ~0xfffful;
339#else
340 vpte = (vpte >> (PAGE_SHIFT - 3)) & ~0xffful;
341#endif
342 vpte |= rid;
343 __flush_tlb_page(tlb->mm, vpte, tsize, 0);
344 }
345}
346
347/*
348 * Early initialization of the MMU TLB code
349 */
350static void __early_init_mmu(int boot_cpu)
351{
352 extern unsigned int interrupt_base_book3e;
353 extern unsigned int exc_data_tlb_miss_htw_book3e;
354 extern unsigned int exc_instruction_tlb_miss_htw_book3e;
355
356 unsigned int *ibase = &interrupt_base_book3e;
357 unsigned int mas4;
358
359 /* XXX This will have to be decided at runtime, but right
360 * now our boot and TLB miss code hard wires it. Ideally
361 * we should find out a suitable page size and patch the
362 * TLB miss code (either that or use the PACA to store
363 * the value we want)
364 */
365 mmu_linear_psize = MMU_PAGE_1G;
366
367 /* XXX This should be decided at runtime based on supported
368 * page sizes in the TLB, but for now let's assume 16M is
369 * always there and a good fit (which it probably is)
370 */
371 mmu_vmemmap_psize = MMU_PAGE_16M;
372
373 /* Check if HW tablewalk is present, and if yes, enable it by:
374 *
375 * - patching the TLB miss handlers to branch to the
376 * one dedicates to it
377 *
378 * - setting the global book3e_htw_enabled
379 *
380 * - Set MAS4:INDD and default page size
381 */
382
383 /* XXX This code only checks for TLB 0 capabilities and doesn't
384 * check what page size combos are supported by the HW. It
385 * also doesn't handle the case where a separate array holds
386 * the IND entries from the array loaded by the PT.
387 */
388 if (boot_cpu) {
389 unsigned int tlb0cfg = mfspr(SPRN_TLB0CFG);
390
391 /* Check if HW loader is supported */
392 if ((tlb0cfg & TLBnCFG_IND) &&
393 (tlb0cfg & TLBnCFG_PT)) {
394 patch_branch(ibase + (0x1c0 / 4),
395 (unsigned long)&exc_data_tlb_miss_htw_book3e, 0);
396 patch_branch(ibase + (0x1e0 / 4),
397 (unsigned long)&exc_instruction_tlb_miss_htw_book3e, 0);
398 book3e_htw_enabled = 1;
399 }
400 pr_info("MMU: Book3E Page Tables %s\n",
401 book3e_htw_enabled ? "Enabled" : "Disabled");
402 }
403
404 /* Set MAS4 based on page table setting */
405
406 mas4 = 0x4 << MAS4_WIMGED_SHIFT;
407 if (book3e_htw_enabled) {
408 mas4 |= mas4 | MAS4_INDD;
409#ifdef CONFIG_PPC_64K_PAGES
410 mas4 |= BOOK3E_PAGESZ_256M << MAS4_TSIZED_SHIFT;
411 mmu_pte_psize = MMU_PAGE_256M;
412#else
413 mas4 |= BOOK3E_PAGESZ_1M << MAS4_TSIZED_SHIFT;
414 mmu_pte_psize = MMU_PAGE_1M;
415#endif
416 } else {
417#ifdef CONFIG_PPC_64K_PAGES
418 mas4 |= BOOK3E_PAGESZ_64K << MAS4_TSIZED_SHIFT;
419#else
420 mas4 |= BOOK3E_PAGESZ_4K << MAS4_TSIZED_SHIFT;
421#endif
422 mmu_pte_psize = mmu_virtual_psize;
423 }
424 mtspr(SPRN_MAS4, mas4);
425
426 /* Set the global containing the top of the linear mapping
427 * for use by the TLB miss code
428 */
429 linear_map_top = lmb_end_of_DRAM();
430
431 /* A sync won't hurt us after mucking around with
432 * the MMU configuration
433 */
434 mb();
435}
436
437void __init early_init_mmu(void)
438{
439 __early_init_mmu(1);
440}
441
442void __cpuinit early_init_mmu_secondary(void)
443{
444 __early_init_mmu(0);
445}
446
447#endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/tlb_nohash_low.S
index 3037911279b1..bbdc5b577b85 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -39,7 +39,7 @@
39/* 39/*
40 * 40x implementation needs only tlbil_va 40 * 40x implementation needs only tlbil_va
41 */ 41 */
42_GLOBAL(_tlbil_va) 42_GLOBAL(__tlbil_va)
43 /* We run the search with interrupts disabled because we have to change 43 /* We run the search with interrupts disabled because we have to change
44 * the PID and I don't want to preempt when that happens. 44 * the PID and I don't want to preempt when that happens.
45 */ 45 */
@@ -71,7 +71,7 @@ _GLOBAL(_tlbil_va)
71 * 440 implementation uses tlbsx/we for tlbil_va and a full sweep 71 * 440 implementation uses tlbsx/we for tlbil_va and a full sweep
72 * of the TLB for everything else. 72 * of the TLB for everything else.
73 */ 73 */
74_GLOBAL(_tlbil_va) 74_GLOBAL(__tlbil_va)
75 mfspr r5,SPRN_MMUCR 75 mfspr r5,SPRN_MMUCR
76 rlwimi r5,r4,0,24,31 /* Set TID */ 76 rlwimi r5,r4,0,24,31 /* Set TID */
77 77
@@ -124,8 +124,6 @@ _GLOBAL(_tlbil_pid)
124 * to have the larger code path before the _SECTION_ELSE 124 * to have the larger code path before the _SECTION_ELSE
125 */ 125 */
126 126
127#define MMUCSR0_TLBFI (MMUCSR0_TLB0FI | MMUCSR0_TLB1FI | \
128 MMUCSR0_TLB2FI | MMUCSR0_TLB3FI)
129/* 127/*
130 * Flush MMU TLB on the local processor 128 * Flush MMU TLB on the local processor
131 */ 129 */
@@ -170,7 +168,7 @@ ALT_MMU_FTR_SECTION_END_IFSET(MMU_FTR_USE_TLBILX)
170 * Flush MMU TLB for a particular address, but only on the local processor 168 * Flush MMU TLB for a particular address, but only on the local processor
171 * (no broadcast) 169 * (no broadcast)
172 */ 170 */
173_GLOBAL(_tlbil_va) 171_GLOBAL(__tlbil_va)
174 mfmsr r10 172 mfmsr r10
175 wrteei 0 173 wrteei 0
176 slwi r4,r4,16 174 slwi r4,r4,16
@@ -191,6 +189,85 @@ ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_USE_TLBILX)
191 isync 189 isync
1921: wrtee r10 1901: wrtee r10
193 blr 191 blr
192#elif defined(CONFIG_PPC_BOOK3E)
193/*
194 * New Book3E (>= 2.06) implementation
195 *
196 * Note: We may be able to get away without the interrupt masking stuff
197 * if we save/restore MAS6 on exceptions that might modify it
198 */
199_GLOBAL(_tlbil_pid)
200 slwi r4,r3,MAS6_SPID_SHIFT
201 mfmsr r10
202 wrteei 0
203 mtspr SPRN_MAS6,r4
204 PPC_TLBILX_PID(0,0)
205 wrtee r10
206 msync
207 isync
208 blr
209
210_GLOBAL(_tlbil_pid_noind)
211 slwi r4,r3,MAS6_SPID_SHIFT
212 mfmsr r10
213 ori r4,r4,MAS6_SIND
214 wrteei 0
215 mtspr SPRN_MAS6,r4
216 PPC_TLBILX_PID(0,0)
217 wrtee r10
218 msync
219 isync
220 blr
221
222_GLOBAL(_tlbil_all)
223 PPC_TLBILX_ALL(0,0)
224 msync
225 isync
226 blr
227
228_GLOBAL(_tlbil_va)
229 mfmsr r10
230 wrteei 0
231 cmpwi cr0,r6,0
232 slwi r4,r4,MAS6_SPID_SHIFT
233 rlwimi r4,r5,MAS6_ISIZE_SHIFT,MAS6_ISIZE_MASK
234 beq 1f
235 rlwimi r4,r6,MAS6_SIND_SHIFT,MAS6_SIND
2361: mtspr SPRN_MAS6,r4 /* assume AS=0 for now */
237 PPC_TLBILX_VA(0,r3)
238 msync
239 isync
240 wrtee r10
241 blr
242
243_GLOBAL(_tlbivax_bcast)
244 mfmsr r10
245 wrteei 0
246 cmpwi cr0,r6,0
247 slwi r4,r4,MAS6_SPID_SHIFT
248 rlwimi r4,r5,MAS6_ISIZE_SHIFT,MAS6_ISIZE_MASK
249 beq 1f
250 rlwimi r4,r6,MAS6_SIND_SHIFT,MAS6_SIND
2511: mtspr SPRN_MAS6,r4 /* assume AS=0 for now */
252 PPC_TLBIVAX(0,r3)
253 eieio
254 tlbsync
255 sync
256 wrtee r10
257 blr
258
259_GLOBAL(set_context)
260#ifdef CONFIG_BDI_SWITCH
261 /* Context switch the PTE pointer for the Abatron BDI2000.
262 * The PGDIR is the second parameter.
263 */
264 lis r5, abatron_pteptrs@h
265 ori r5, r5, abatron_pteptrs@l
266 stw r4, 0x4(r5)
267#endif
268 mtspr SPRN_PID,r3
269 isync /* Force context change */
270 blr
194#else 271#else
195#error Unsupported processor type ! 272#error Unsupported processor type !
196#endif 273#endif
diff --git a/arch/powerpc/platforms/40x/Kconfig b/arch/powerpc/platforms/40x/Kconfig
index a6e43cb6f825..ec64264f7a50 100644
--- a/arch/powerpc/platforms/40x/Kconfig
+++ b/arch/powerpc/platforms/40x/Kconfig
@@ -40,6 +40,16 @@ config HCU4
40 help 40 help
41 This option enables support for the Nestal Maschinen HCU4 board. 41 This option enables support for the Nestal Maschinen HCU4 board.
42 42
43config HOTFOOT
44 bool "Hotfoot"
45 depends on 40x
46 default n
47 select 405EP
48 select PPC40x_SIMPLE
49 select PCI
50 help
51 This option enables support for the ESTEEM 195E Hotfoot board.
52
43config KILAUEA 53config KILAUEA
44 bool "Kilauea" 54 bool "Kilauea"
45 depends on 40x 55 depends on 40x
diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c b/arch/powerpc/platforms/40x/ppc40x_simple.c
index 5fd5a5974001..546bbc229d19 100644
--- a/arch/powerpc/platforms/40x/ppc40x_simple.c
+++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
@@ -54,7 +54,8 @@ static char *board[] __initdata = {
54 "amcc,acadia", 54 "amcc,acadia",
55 "amcc,haleakala", 55 "amcc,haleakala",
56 "amcc,kilauea", 56 "amcc,kilauea",
57 "amcc,makalu" 57 "amcc,makalu",
58 "est,hotfoot"
58}; 59};
59 60
60static int __init ppc40x_probe(void) 61static int __init ppc40x_probe(void)
diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig
index 90e3192611a4..7486bffd3ebb 100644
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -129,6 +129,18 @@ config REDWOOD
129 help 129 help
130 This option enables support for the AMCC PPC460SX Redwood board. 130 This option enables support for the AMCC PPC460SX Redwood board.
131 131
132config EIGER
133 bool "Eiger"
134 depends on 44x
135 default n
136 select PPC44x_SIMPLE
137 select 460SX
138 select PCI
139 select PPC4xx_PCI_EXPRESS
140 select IBM_NEW_EMAC_RGMII
141 help
142 This option enables support for the AMCC PPC460SX evaluation board.
143
132config YOSEMITE 144config YOSEMITE
133 bool "Yosemite" 145 bool "Yosemite"
134 depends on 44x 146 depends on 44x
diff --git a/arch/powerpc/platforms/44x/ppc44x_simple.c b/arch/powerpc/platforms/44x/ppc44x_simple.c
index 5bcd441885e8..e8c23ccaa1fc 100644
--- a/arch/powerpc/platforms/44x/ppc44x_simple.c
+++ b/arch/powerpc/platforms/44x/ppc44x_simple.c
@@ -55,6 +55,7 @@ static char *board[] __initdata = {
55 "amcc,canyonlands", 55 "amcc,canyonlands",
56 "amcc,glacier", 56 "amcc,glacier",
57 "ibm,ebony", 57 "ibm,ebony",
58 "amcc,eiger",
58 "amcc,katmai", 59 "amcc,katmai",
59 "amcc,rainier", 60 "amcc,rainier",
60 "amcc,redwood", 61 "amcc,redwood",
diff --git a/arch/powerpc/platforms/82xx/mgcoge.c b/arch/powerpc/platforms/82xx/mgcoge.c
index c2af169c1d1d..7a5de9eb3c73 100644
--- a/arch/powerpc/platforms/82xx/mgcoge.c
+++ b/arch/powerpc/platforms/82xx/mgcoge.c
@@ -50,16 +50,63 @@ struct cpm_pin {
50static __initdata struct cpm_pin mgcoge_pins[] = { 50static __initdata struct cpm_pin mgcoge_pins[] = {
51 51
52 /* SMC2 */ 52 /* SMC2 */
53 {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 53 {0, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
54 {1, 9, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 54 {0, 9, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
55 55
56 /* SCC4 */ 56 /* SCC4 */
57 {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 57 {2, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
58 {3, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 58 {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
59 {3, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 59 {2, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
60 {3, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 60 {2, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
61 {4, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, 61 {3, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
62 {4, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, 62 {3, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
63
64 /* FCC1 */
65 {0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
66 {0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
67 {0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
68 {0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
69 {0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
70 {0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
71 {0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
72 {0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
73 {0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
74 {0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
75 {0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
76 {0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
77 {0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
78 {0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},
79
80 {2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
81 {2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
82
83 /* FCC2 */
84 {1, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
85 {1, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
86 {1, 20, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
87 {1, 21, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
88 {1, 22, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
89 {1, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
90 {1, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
91 {1, 25, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
92 {1, 26, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
93 {1, 27, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
94 {1, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
95 {1, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},
96 {1, 30, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
97 {1, 31, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
98
99 {2, 18, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
100 {2, 19, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
101
102 /* MDC */
103 {0, 13, CPM_PIN_OUTPUT | CPM_PIN_GPIO},
104
105#if defined(CONFIG_I2C_CPM)
106 /* I2C */
107 {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
108 {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
109#endif
63}; 110};
64 111
65static void __init init_ioports(void) 112static void __init init_ioports(void)
@@ -68,12 +115,16 @@ static void __init init_ioports(void)
68 115
69 for (i = 0; i < ARRAY_SIZE(mgcoge_pins); i++) { 116 for (i = 0; i < ARRAY_SIZE(mgcoge_pins); i++) {
70 const struct cpm_pin *pin = &mgcoge_pins[i]; 117 const struct cpm_pin *pin = &mgcoge_pins[i];
71 cpm2_set_pin(pin->port - 1, pin->pin, pin->flags); 118 cpm2_set_pin(pin->port, pin->pin, pin->flags);
72 } 119 }
73 120
74 cpm2_smc_clk_setup(CPM_CLK_SMC2, CPM_BRG8); 121 cpm2_smc_clk_setup(CPM_CLK_SMC2, CPM_BRG8);
75 cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK7, CPM_CLK_RX); 122 cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK7, CPM_CLK_RX);
76 cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK8, CPM_CLK_TX); 123 cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK8, CPM_CLK_TX);
124 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_RX);
125 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_TX);
126 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK13, CPM_CLK_RX);
127 cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK14, CPM_CLK_TX);
77} 128}
78 129
79static void __init mgcoge_setup_arch(void) 130static void __init mgcoge_setup_arch(void)
diff --git a/arch/powerpc/platforms/82xx/mpc8272_ads.c b/arch/powerpc/platforms/82xx/mpc8272_ads.c
index 8054c685d323..30394b409b3f 100644
--- a/arch/powerpc/platforms/82xx/mpc8272_ads.c
+++ b/arch/powerpc/platforms/82xx/mpc8272_ads.c
@@ -29,7 +29,6 @@
29#include <sysdev/fsl_soc.h> 29#include <sysdev/fsl_soc.h>
30#include <sysdev/cpm2_pic.h> 30#include <sysdev/cpm2_pic.h>
31 31
32#include "pq2ads.h"
33#include "pq2.h" 32#include "pq2.h"
34 33
35static void __init mpc8272_ads_pic_init(void) 34static void __init mpc8272_ads_pic_init(void)
@@ -100,6 +99,15 @@ static struct cpm_pin mpc8272_ads_pins[] = {
100 /* I2C */ 99 /* I2C */
101 {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN}, 100 {3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
102 {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN}, 101 {3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
102
103 /* USB */
104 {2, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
105 {2, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
106 {2, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
107 {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
108 {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
109 {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
110 {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
103}; 111};
104 112
105static void __init init_ioports(void) 113static void __init init_ioports(void)
@@ -113,6 +121,8 @@ static void __init init_ioports(void)
113 121
114 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX); 122 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);
115 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX); 123 cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);
124 cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_RX);
125 cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_TX);
116 cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_RX); 126 cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_RX);
117 cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_TX); 127 cpm2_clk_setup(CPM_CLK_SCC4, CPM_BRG4, CPM_CLK_TX);
118 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK11, CPM_CLK_RX); 128 cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK11, CPM_CLK_RX);
@@ -144,12 +154,22 @@ static void __init mpc8272_ads_setup_arch(void)
144 return; 154 return;
145 } 155 }
146 156
157#define BCSR1_FETHIEN 0x08000000
158#define BCSR1_FETH_RST 0x04000000
159#define BCSR1_RS232_EN1 0x02000000
160#define BCSR1_RS232_EN2 0x01000000
161#define BCSR3_USB_nEN 0x80000000
162#define BCSR3_FETHIEN2 0x10000000
163#define BCSR3_FETH2_RST 0x08000000
164
147 clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN); 165 clrbits32(&bcsr[1], BCSR1_RS232_EN1 | BCSR1_RS232_EN2 | BCSR1_FETHIEN);
148 setbits32(&bcsr[1], BCSR1_FETH_RST); 166 setbits32(&bcsr[1], BCSR1_FETH_RST);
149 167
150 clrbits32(&bcsr[3], BCSR3_FETHIEN2); 168 clrbits32(&bcsr[3], BCSR3_FETHIEN2);
151 setbits32(&bcsr[3], BCSR3_FETH2_RST); 169 setbits32(&bcsr[3], BCSR3_FETH2_RST);
152 170
171 clrbits32(&bcsr[3], BCSR3_USB_nEN);
172
153 iounmap(bcsr); 173 iounmap(bcsr);
154 174
155 init_ioports(); 175 init_ioports();
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 083ebee9a16d..f49a2548c5ff 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -75,11 +75,11 @@ config MPC837x_MDS
75 This option enables support for the MPC837x MDS Processor Board. 75 This option enables support for the MPC837x MDS Processor Board.
76 76
77config MPC837x_RDB 77config MPC837x_RDB
78 bool "Freescale MPC837x RDB" 78 bool "Freescale MPC837x RDB/WLAN"
79 select DEFAULT_UIMAGE 79 select DEFAULT_UIMAGE
80 select PPC_MPC837x 80 select PPC_MPC837x
81 help 81 help
82 This option enables support for the MPC837x RDB Board. 82 This option enables support for the MPC837x RDB and WLAN Boards.
83 83
84config SBC834x 84config SBC834x
85 bool "Wind River SBC834x" 85 bool "Wind River SBC834x"
diff --git a/arch/powerpc/platforms/83xx/mpc837x_rdb.c b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
index 76f3b32a155e..a1908d261240 100644
--- a/arch/powerpc/platforms/83xx/mpc837x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
@@ -17,10 +17,32 @@
17#include <asm/time.h> 17#include <asm/time.h>
18#include <asm/ipic.h> 18#include <asm/ipic.h>
19#include <asm/udbg.h> 19#include <asm/udbg.h>
20#include <sysdev/fsl_soc.h>
20#include <sysdev/fsl_pci.h> 21#include <sysdev/fsl_pci.h>
21 22
22#include "mpc83xx.h" 23#include "mpc83xx.h"
23 24
25static void mpc837x_rdb_sd_cfg(void)
26{
27 void __iomem *im;
28
29 im = ioremap(get_immrbase(), 0x1000);
30 if (!im) {
31 WARN_ON(1);
32 return;
33 }
34
35 /*
36 * On RDB boards (in contrast to MDS) USBB pins are used for SD only,
37 * so we can safely mux them away from the USB block.
38 */
39 clrsetbits_be32(im + MPC83XX_SICRL_OFFS, MPC837X_SICRL_USBB_MASK,
40 MPC837X_SICRL_SD);
41 clrsetbits_be32(im + MPC83XX_SICRH_OFFS, MPC837X_SICRH_SPI_MASK,
42 MPC837X_SICRH_SD);
43 iounmap(im);
44}
45
24/* ************************************************************************ 46/* ************************************************************************
25 * 47 *
26 * Setup the architecture 48 * Setup the architecture
@@ -42,6 +64,7 @@ static void __init mpc837x_rdb_setup_arch(void)
42 mpc83xx_add_bridge(np); 64 mpc83xx_add_bridge(np);
43#endif 65#endif
44 mpc837x_usb_cfg(); 66 mpc837x_usb_cfg();
67 mpc837x_rdb_sd_cfg();
45} 68}
46 69
47static struct of_device_id mpc837x_ids[] = { 70static struct of_device_id mpc837x_ids[] = {
@@ -86,11 +109,12 @@ static int __init mpc837x_rdb_probe(void)
86 109
87 return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") || 110 return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") ||
88 of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") || 111 of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") ||
89 of_flat_dt_is_compatible(root, "fsl,mpc8379rdb"); 112 of_flat_dt_is_compatible(root, "fsl,mpc8379rdb") ||
113 of_flat_dt_is_compatible(root, "fsl,mpc8377wlan");
90} 114}
91 115
92define_machine(mpc837x_rdb) { 116define_machine(mpc837x_rdb) {
93 .name = "MPC837x RDB", 117 .name = "MPC837x RDB/WLAN",
94 .probe = mpc837x_rdb_probe, 118 .probe = mpc837x_rdb_probe,
95 .setup_arch = mpc837x_rdb_setup_arch, 119 .setup_arch = mpc837x_rdb_setup_arch,
96 .init_IRQ = mpc837x_rdb_init_IRQ, 120 .init_IRQ = mpc837x_rdb_init_IRQ,
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index d1dc5b0b4fbf..0fea8811d45b 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -30,6 +30,8 @@
30#define MPC8315_SICRL_USB_ULPI 0x00000054 30#define MPC8315_SICRL_USB_ULPI 0x00000054
31#define MPC837X_SICRL_USB_MASK 0xf0000000 31#define MPC837X_SICRL_USB_MASK 0xf0000000
32#define MPC837X_SICRL_USB_ULPI 0x50000000 32#define MPC837X_SICRL_USB_ULPI 0x50000000
33#define MPC837X_SICRL_USBB_MASK 0x30000000
34#define MPC837X_SICRL_SD 0x20000000
33 35
34/* system i/o configuration register high */ 36/* system i/o configuration register high */
35#define MPC83XX_SICRH_OFFS 0x118 37#define MPC83XX_SICRH_OFFS 0x118
@@ -38,6 +40,8 @@
38#define MPC831X_SICRH_USB_ULPI 0x000000a0 40#define MPC831X_SICRH_USB_ULPI 0x000000a0
39#define MPC8315_SICRH_USB_MASK 0x0000ff00 41#define MPC8315_SICRH_USB_MASK 0x0000ff00
40#define MPC8315_SICRH_USB_ULPI 0x00000000 42#define MPC8315_SICRH_USB_ULPI 0x00000000
43#define MPC837X_SICRH_SPI_MASK 0x00000003
44#define MPC837X_SICRH_SD 0x00000001
41 45
42/* USB Control Register */ 46/* USB Control Register */
43#define FSL_USB2_CONTROL_OFFS 0x500 47#define FSL_USB2_CONTROL_OFFS 0x500
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index a9b416688975..d3a975e8fd3e 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -55,6 +55,15 @@ config MPC85xx_DS
55 help 55 help
56 This option enables support for the MPC85xx DS (MPC8544 DS) board 56 This option enables support for the MPC85xx DS (MPC8544 DS) board
57 57
58config MPC85xx_RDB
59 bool "Freescale MPC85xx RDB"
60 select PPC_I8259
61 select DEFAULT_UIMAGE
62 select FSL_ULI1575
63 select SWIOTLB
64 help
65 This option enables support for the MPC85xx RDB (P2020 RDB) board
66
58config SOCRATES 67config SOCRATES
59 bool "Socrates" 68 bool "Socrates"
60 select DEFAULT_UIMAGE 69 select DEFAULT_UIMAGE
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 835733f2b12c..9098aea0cf32 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -9,10 +9,11 @@ obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
9obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o 9obj-$(CONFIG_MPC8536_DS) += mpc8536_ds.o
10obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o 10obj-$(CONFIG_MPC85xx_DS) += mpc85xx_ds.o
11obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o 11obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
12obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o
12obj-$(CONFIG_STX_GP3) += stx_gp3.o 13obj-$(CONFIG_STX_GP3) += stx_gp3.o
13obj-$(CONFIG_TQM85xx) += tqm85xx.o 14obj-$(CONFIG_TQM85xx) += tqm85xx.o
14obj-$(CONFIG_SBC8560) += sbc8560.o 15obj-$(CONFIG_SBC8560) += sbc8560.o
15obj-$(CONFIG_SBC8548) += sbc8548.o 16obj-$(CONFIG_SBC8548) += sbc8548.o
16obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o 17obj-$(CONFIG_SOCRATES) += socrates.o socrates_fpga_pic.o
17obj-$(CONFIG_KSI8560) += ksi8560.o 18obj-$(CONFIG_KSI8560) += ksi8560.o
18obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o \ No newline at end of file 19obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 055ff417bae9..004b7d36cdb7 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -96,7 +96,8 @@ static void __init mpc8536_ds_setup_arch(void)
96#ifdef CONFIG_SWIOTLB 96#ifdef CONFIG_SWIOTLB
97 if (lmb_end_of_DRAM() > max) { 97 if (lmb_end_of_DRAM() > max) {
98 ppc_swiotlb_enable = 1; 98 ppc_swiotlb_enable = 1;
99 set_pci_dma_ops(&swiotlb_pci_dma_ops); 99 set_pci_dma_ops(&swiotlb_dma_ops);
100 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
100 } 101 }
101#endif 102#endif
102 103
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 849c0ac0025f..544011a562fb 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -192,7 +192,8 @@ static void __init mpc85xx_ds_setup_arch(void)
192#ifdef CONFIG_SWIOTLB 192#ifdef CONFIG_SWIOTLB
193 if (lmb_end_of_DRAM() > max) { 193 if (lmb_end_of_DRAM() > max) {
194 ppc_swiotlb_enable = 1; 194 ppc_swiotlb_enable = 1;
195 set_pci_dma_ops(&swiotlb_pci_dma_ops); 195 set_pci_dma_ops(&swiotlb_dma_ops);
196 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
196 } 197 }
197#endif 198#endif
198 199
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index bfb32834ab0c..3909d57b86e3 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -47,6 +47,7 @@
47#include <asm/udbg.h> 47#include <asm/udbg.h>
48#include <sysdev/fsl_soc.h> 48#include <sysdev/fsl_soc.h>
49#include <sysdev/fsl_pci.h> 49#include <sysdev/fsl_pci.h>
50#include <sysdev/simple_gpio.h>
50#include <asm/qe.h> 51#include <asm/qe.h>
51#include <asm/qe_ic.h> 52#include <asm/qe_ic.h>
52#include <asm/mpic.h> 53#include <asm/mpic.h>
@@ -254,7 +255,8 @@ static void __init mpc85xx_mds_setup_arch(void)
254#ifdef CONFIG_SWIOTLB 255#ifdef CONFIG_SWIOTLB
255 if (lmb_end_of_DRAM() > max) { 256 if (lmb_end_of_DRAM() > max) {
256 ppc_swiotlb_enable = 1; 257 ppc_swiotlb_enable = 1;
257 set_pci_dma_ops(&swiotlb_pci_dma_ops); 258 set_pci_dma_ops(&swiotlb_dma_ops);
259 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
258 } 260 }
259#endif 261#endif
260} 262}
@@ -304,6 +306,9 @@ static struct of_device_id mpc85xx_ids[] = {
304 306
305static int __init mpc85xx_publish_devices(void) 307static int __init mpc85xx_publish_devices(void)
306{ 308{
309 if (machine_is(mpc8569_mds))
310 simple_gpiochip_init("fsl,mpc8569mds-bcsr-gpio");
311
307 /* Publish the QE devices */ 312 /* Publish the QE devices */
308 of_platform_bus_probe(NULL, mpc85xx_ids, NULL); 313 of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
309 314
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
new file mode 100644
index 000000000000..c8468de4acf6
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -0,0 +1,141 @@
1/*
2 * MPC85xx RDB Board Setup
3 *
4 * Copyright 2009 Freescale Semiconductor Inc.
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
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/pci.h>
15#include <linux/kdev_t.h>
16#include <linux/delay.h>
17#include <linux/seq_file.h>
18#include <linux/interrupt.h>
19#include <linux/of_platform.h>
20
21#include <asm/system.h>
22#include <asm/time.h>
23#include <asm/machdep.h>
24#include <asm/pci-bridge.h>
25#include <mm/mmu_decl.h>
26#include <asm/prom.h>
27#include <asm/udbg.h>
28#include <asm/mpic.h>
29
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32
33#undef DEBUG
34
35#ifdef DEBUG
36#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
37#else
38#define DBG(fmt, args...)
39#endif
40
41
42void __init mpc85xx_rdb_pic_init(void)
43{
44 struct mpic *mpic;
45 struct resource r;
46 struct device_node *np;
47
48 np = of_find_node_by_type(NULL, "open-pic");
49 if (np == NULL) {
50 printk(KERN_ERR "Could not find open-pic node\n");
51 return;
52 }
53
54 if (of_address_to_resource(np, 0, &r)) {
55 printk(KERN_ERR "Failed to map mpic register space\n");
56 of_node_put(np);
57 return;
58 }
59
60 mpic = mpic_alloc(np, r.start,
61 MPIC_PRIMARY | MPIC_WANTS_RESET |
62 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
63 MPIC_SINGLE_DEST_CPU,
64 0, 256, " OpenPIC ");
65
66 BUG_ON(mpic == NULL);
67 of_node_put(np);
68
69 mpic_init(mpic);
70
71}
72
73/*
74 * Setup the architecture
75 */
76#ifdef CONFIG_SMP
77extern void __init mpc85xx_smp_init(void);
78#endif
79static void __init mpc85xx_rdb_setup_arch(void)
80{
81#ifdef CONFIG_PCI
82 struct device_node *np;
83#endif
84
85 if (ppc_md.progress)
86 ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
87
88#ifdef CONFIG_PCI
89 for_each_node_by_type(np, "pci") {
90 if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
91 fsl_add_bridge(np, 0);
92 }
93
94#endif
95
96#ifdef CONFIG_SMP
97 mpc85xx_smp_init();
98#endif
99
100 printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
101}
102
103static struct of_device_id __initdata mpc85xxrdb_ids[] = {
104 { .type = "soc", },
105 { .compatible = "soc", },
106 { .compatible = "simple-bus", },
107 { .compatible = "gianfar", },
108 {},
109};
110
111static int __init mpc85xxrdb_publish_devices(void)
112{
113 return of_platform_bus_probe(NULL, mpc85xxrdb_ids, NULL);
114}
115machine_device_initcall(p2020_rdb, mpc85xxrdb_publish_devices);
116
117/*
118 * Called very early, device-tree isn't unflattened
119 */
120static int __init p2020_rdb_probe(void)
121{
122 unsigned long root = of_get_flat_dt_root();
123
124 if (of_flat_dt_is_compatible(root, "fsl,P2020RDB"))
125 return 1;
126 return 0;
127}
128
129define_machine(p2020_rdb) {
130 .name = "P2020 RDB",
131 .probe = p2020_rdb_probe,
132 .setup_arch = mpc85xx_rdb_setup_arch,
133 .init_IRQ = mpc85xx_rdb_pic_init,
134#ifdef CONFIG_PCI
135 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
136#endif
137 .get_irq = mpic_get_irq,
138 .restart = fsl_rstcr_restart,
139 .calibrate_decr = generic_calibrate_decr,
140 .progress = udbg_progress,
141};
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index cc27807a8b64..a5ad1c7794bf 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -267,6 +267,43 @@ arch_initcall(sbc8560_rtc_init);
267 267
268#endif /* M48T59 */ 268#endif /* M48T59 */
269 269
270static __u8 __iomem *brstcr;
271
272static int __init sbc8560_bdrstcr_init(void)
273{
274 struct device_node *np;
275 struct resource res;
276
277 np = of_find_compatible_node(NULL, NULL, "wrs,sbc8560-brstcr");
278 if (np == NULL) {
279 printk(KERN_WARNING "sbc8560: No board specific RSTCR in DTB.\n");
280 return -ENODEV;
281 }
282
283 of_address_to_resource(np, 0, &res);
284
285 printk(KERN_INFO "sbc8560: Found BRSTCR at i/o 0x%x\n", res.start);
286
287 brstcr = ioremap(res.start, res.end - res.start);
288 if(!brstcr)
289 printk(KERN_WARNING "sbc8560: ioremap of brstcr failed.\n");
290
291 of_node_put(np);
292
293 return 0;
294}
295
296arch_initcall(sbc8560_bdrstcr_init);
297
298void sbc8560_rstcr_restart(char * cmd)
299{
300 local_irq_disable();
301 if(brstcr)
302 clrbits8(brstcr, 0x80);
303
304 while(1);
305}
306
270define_machine(sbc8560) { 307define_machine(sbc8560) {
271 .name = "SBC8560", 308 .name = "SBC8560",
272 .probe = sbc8560_probe, 309 .probe = sbc8560_probe,
@@ -274,7 +311,7 @@ define_machine(sbc8560) {
274 .init_IRQ = sbc8560_pic_init, 311 .init_IRQ = sbc8560_pic_init,
275 .show_cpuinfo = sbc8560_show_cpuinfo, 312 .show_cpuinfo = sbc8560_show_cpuinfo,
276 .get_irq = mpic_get_irq, 313 .get_irq = mpic_get_irq,
277 .restart = fsl_rstcr_restart, 314 .restart = sbc8560_rstcr_restart,
278 .calibrate_decr = generic_calibrate_decr, 315 .calibrate_decr = generic_calibrate_decr,
279 .progress = udbg_progress, 316 .progress = udbg_progress,
280}; 317};
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 62c592ede641..04160a4cc699 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -25,7 +25,6 @@
25 25
26#include <sysdev/fsl_soc.h> 26#include <sysdev/fsl_soc.h>
27 27
28extern volatile unsigned long __secondary_hold_acknowledge;
29extern void __early_start(void); 28extern void __early_start(void);
30 29
31#define BOOT_ENTRY_ADDR_UPPER 0 30#define BOOT_ENTRY_ADDR_UPPER 0
@@ -80,46 +79,24 @@ smp_85xx_kick_cpu(int nr)
80} 79}
81 80
82static void __init 81static void __init
83smp_85xx_basic_setup(int cpu_nr)
84{
85 /* Clear any pending timer interrupts */
86 mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
87
88 /* Enable decrementer interrupt */
89 mtspr(SPRN_TCR, TCR_DIE);
90}
91
92static void __init
93smp_85xx_setup_cpu(int cpu_nr) 82smp_85xx_setup_cpu(int cpu_nr)
94{ 83{
95 mpic_setup_this_cpu(); 84 mpic_setup_this_cpu();
96
97 smp_85xx_basic_setup(cpu_nr);
98} 85}
99 86
100struct smp_ops_t smp_85xx_ops = { 87struct smp_ops_t smp_85xx_ops = {
101 .kick_cpu = smp_85xx_kick_cpu, 88 .kick_cpu = smp_85xx_kick_cpu,
102}; 89};
103 90
104static int __init smp_dummy_probe(void)
105{
106 return NR_CPUS;
107}
108
109void __init mpc85xx_smp_init(void) 91void __init mpc85xx_smp_init(void)
110{ 92{
111 struct device_node *np; 93 struct device_node *np;
112 94
113 smp_85xx_ops.message_pass = NULL;
114
115 np = of_find_node_by_type(NULL, "open-pic"); 95 np = of_find_node_by_type(NULL, "open-pic");
116 if (np) { 96 if (np) {
117 smp_85xx_ops.probe = smp_mpic_probe; 97 smp_85xx_ops.probe = smp_mpic_probe;
118 smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu; 98 smp_85xx_ops.setup_cpu = smp_85xx_setup_cpu;
119 smp_85xx_ops.message_pass = smp_mpic_message_pass; 99 smp_85xx_ops.message_pass = smp_mpic_message_pass;
120 } else {
121 smp_85xx_ops.probe = smp_dummy_probe;
122 smp_85xx_ops.setup_cpu = smp_85xx_basic_setup;
123 } 100 }
124 101
125 if (cpu_has_feature(CPU_FTR_DBELL)) 102 if (cpu_has_feature(CPU_FTR_DBELL))
diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c b/arch/powerpc/platforms/86xx/gef_ppc9a.c
index 2efa052975e6..287f7bd17dd9 100644
--- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
+++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
@@ -102,8 +102,8 @@ static unsigned int gef_ppc9a_get_pcb_rev(void)
102{ 102{
103 unsigned int reg; 103 unsigned int reg;
104 104
105 reg = ioread32(ppc9a_regs); 105 reg = ioread32be(ppc9a_regs);
106 return (reg >> 8) & 0xff; 106 return (reg >> 16) & 0xff;
107} 107}
108 108
109/* Return the board (software) revision */ 109/* Return the board (software) revision */
@@ -111,8 +111,8 @@ static unsigned int gef_ppc9a_get_board_rev(void)
111{ 111{
112 unsigned int reg; 112 unsigned int reg;
113 113
114 reg = ioread32(ppc9a_regs); 114 reg = ioread32be(ppc9a_regs);
115 return (reg >> 16) & 0xff; 115 return (reg >> 8) & 0xff;
116} 116}
117 117
118/* Return the FPGA revision */ 118/* Return the FPGA revision */
@@ -120,8 +120,26 @@ static unsigned int gef_ppc9a_get_fpga_rev(void)
120{ 120{
121 unsigned int reg; 121 unsigned int reg;
122 122
123 reg = ioread32(ppc9a_regs); 123 reg = ioread32be(ppc9a_regs);
124 return (reg >> 24) & 0xf; 124 return reg & 0xf;
125}
126
127/* Return VME Geographical Address */
128static unsigned int gef_ppc9a_get_vme_geo_addr(void)
129{
130 unsigned int reg;
131
132 reg = ioread32be(ppc9a_regs + 0x4);
133 return reg & 0x1f;
134}
135
136/* Return VME System Controller Status */
137static unsigned int gef_ppc9a_get_vme_is_syscon(void)
138{
139 unsigned int reg;
140
141 reg = ioread32be(ppc9a_regs + 0x4);
142 return (reg >> 9) & 0x1;
125} 143}
126 144
127static void gef_ppc9a_show_cpuinfo(struct seq_file *m) 145static void gef_ppc9a_show_cpuinfo(struct seq_file *m)
@@ -131,10 +149,15 @@ static void gef_ppc9a_show_cpuinfo(struct seq_file *m)
131 seq_printf(m, "Vendor\t\t: GE Fanuc Intelligent Platforms\n"); 149 seq_printf(m, "Vendor\t\t: GE Fanuc Intelligent Platforms\n");
132 150
133 seq_printf(m, "Revision\t: %u%c\n", gef_ppc9a_get_pcb_rev(), 151 seq_printf(m, "Revision\t: %u%c\n", gef_ppc9a_get_pcb_rev(),
134 ('A' + gef_ppc9a_get_board_rev() - 1)); 152 ('A' + gef_ppc9a_get_board_rev()));
135 seq_printf(m, "FPGA Revision\t: %u\n", gef_ppc9a_get_fpga_rev()); 153 seq_printf(m, "FPGA Revision\t: %u\n", gef_ppc9a_get_fpga_rev());
136 154
137 seq_printf(m, "SVR\t\t: 0x%x\n", svid); 155 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
156
157 seq_printf(m, "VME geo. addr\t: %u\n", gef_ppc9a_get_vme_geo_addr());
158
159 seq_printf(m, "VME syscon\t: %s\n",
160 gef_ppc9a_get_vme_is_syscon() ? "yes" : "no");
138} 161}
139 162
140static void __init gef_ppc9a_nec_fixup(struct pci_dev *pdev) 163static void __init gef_ppc9a_nec_fixup(struct pci_dev *pdev)
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 66327024a6a6..2aa69a69bcc8 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -105,7 +105,8 @@ mpc86xx_hpcn_setup_arch(void)
105#ifdef CONFIG_SWIOTLB 105#ifdef CONFIG_SWIOTLB
106 if (lmb_end_of_DRAM() > max) { 106 if (lmb_end_of_DRAM() > max) {
107 ppc_swiotlb_enable = 1; 107 ppc_swiotlb_enable = 1;
108 set_pci_dma_ops(&swiotlb_pci_dma_ops); 108 set_pci_dma_ops(&swiotlb_dma_ops);
109 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
109 } 110 }
110#endif 111#endif
111} 112}
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_smp.c b/arch/powerpc/platforms/86xx/mpc86xx_smp.c
index d84bbb508ee7..eacea0e3fcc8 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_smp.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_smp.c
@@ -27,7 +27,6 @@
27#include "mpc86xx.h" 27#include "mpc86xx.h"
28 28
29extern void __secondary_start_mpc86xx(void); 29extern void __secondary_start_mpc86xx(void);
30extern unsigned long __secondary_hold_acknowledge;
31 30
32#define MCM_PORT_CONFIG_OFFSET 0x10 31#define MCM_PORT_CONFIG_OFFSET 0x10
33 32
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 61187bec7506..9efc8bda01b4 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -57,15 +57,35 @@ config E200
57 57
58endchoice 58endchoice
59 59
60config PPC_BOOK3S_64 60choice
61 def_bool y 61 prompt "Processor Type"
62 depends on PPC64 62 depends on PPC64
63 help
64 There are two families of 64 bit PowerPC chips supported.
65 The most common ones are the desktop and server CPUs
66 (POWER3, RS64, POWER4, POWER5, POWER5+, POWER6, ...)
67
68 The other are the "embedded" processors compliant with the
69 "Book 3E" variant of the architecture
70
71config PPC_BOOK3S_64
72 bool "Server processors"
63 select PPC_FPU 73 select PPC_FPU
64 74
75config PPC_BOOK3E_64
76 bool "Embedded processors"
77 select PPC_FPU # Make it a choice ?
78
79endchoice
80
65config PPC_BOOK3S 81config PPC_BOOK3S
66 def_bool y 82 def_bool y
67 depends on PPC_BOOK3S_32 || PPC_BOOK3S_64 83 depends on PPC_BOOK3S_32 || PPC_BOOK3S_64
68 84
85config PPC_BOOK3E
86 def_bool y
87 depends on PPC_BOOK3E_64
88
69config POWER4_ONLY 89config POWER4_ONLY
70 bool "Optimize for POWER4" 90 bool "Optimize for POWER4"
71 depends on PPC64 && PPC_BOOK3S 91 depends on PPC64 && PPC_BOOK3S
@@ -125,7 +145,7 @@ config 4xx
125 145
126config BOOKE 146config BOOKE
127 bool 147 bool
128 depends on E200 || E500 || 44x 148 depends on E200 || E500 || 44x || PPC_BOOK3E
129 default y 149 default y
130 150
131config FSL_BOOKE 151config FSL_BOOKE
@@ -223,9 +243,17 @@ config PPC_MMU_NOHASH
223 def_bool y 243 def_bool y
224 depends on !PPC_STD_MMU 244 depends on !PPC_STD_MMU
225 245
246config PPC_MMU_NOHASH_32
247 def_bool y
248 depends on PPC_MMU_NOHASH && PPC32
249
250config PPC_MMU_NOHASH_64
251 def_bool y
252 depends on PPC_MMU_NOHASH && PPC64
253
226config PPC_BOOK3E_MMU 254config PPC_BOOK3E_MMU
227 def_bool y 255 def_bool y
228 depends on FSL_BOOKE 256 depends on FSL_BOOKE || PPC_BOOK3E
229 257
230config PPC_MM_SLICES 258config PPC_MM_SLICES
231 bool 259 bool
@@ -257,7 +285,7 @@ config PPC_PERF_CTRS
257 This enables the powerpc-specific perf_counter back-end. 285 This enables the powerpc-specific perf_counter back-end.
258 286
259config SMP 287config SMP
260 depends on PPC_STD_MMU || FSL_BOOKE 288 depends on PPC_BOOK3S || PPC_BOOK3E || FSL_BOOKE
261 bool "Symmetric multi-processing support" 289 bool "Symmetric multi-processing support"
262 ---help--- 290 ---help---
263 This enables support for systems with more than one CPU. If you have 291 This enables support for systems with more than one CPU. If you have
diff --git a/arch/powerpc/platforms/amigaone/setup.c b/arch/powerpc/platforms/amigaone/setup.c
index 443035366c12..9290a7a442d0 100644
--- a/arch/powerpc/platforms/amigaone/setup.c
+++ b/arch/powerpc/platforms/amigaone/setup.c
@@ -110,13 +110,16 @@ void __init amigaone_init_IRQ(void)
110 irq_set_default_host(i8259_get_host()); 110 irq_set_default_host(i8259_get_host());
111} 111}
112 112
113void __init amigaone_init(void) 113static int __init request_isa_regions(void)
114{ 114{
115 request_region(0x00, 0x20, "dma1"); 115 request_region(0x00, 0x20, "dma1");
116 request_region(0x40, 0x20, "timer"); 116 request_region(0x40, 0x20, "timer");
117 request_region(0x80, 0x10, "dma page reg"); 117 request_region(0x80, 0x10, "dma page reg");
118 request_region(0xc0, 0x20, "dma2"); 118 request_region(0xc0, 0x20, "dma2");
119
120 return 0;
119} 121}
122machine_device_initcall(amigaone, request_isa_regions);
120 123
121void amigaone_restart(char *cmd) 124void amigaone_restart(char *cmd)
122{ 125{
@@ -161,7 +164,6 @@ define_machine(amigaone) {
161 .name = "AmigaOne", 164 .name = "AmigaOne",
162 .probe = amigaone_probe, 165 .probe = amigaone_probe,
163 .setup_arch = amigaone_setup_arch, 166 .setup_arch = amigaone_setup_arch,
164 .init = amigaone_init,
165 .show_cpuinfo = amigaone_show_cpuinfo, 167 .show_cpuinfo = amigaone_show_cpuinfo,
166 .init_IRQ = amigaone_init_IRQ, 168 .init_IRQ = amigaone_init_IRQ,
167 .restart = amigaone_restart, 169 .restart = amigaone_restart,
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
index 50f17bdd3c16..48cd7d2e1b75 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -80,13 +80,6 @@ config SPU_FS_64K_LS
80 uses 4K pages. This can improve performances of applications 80 uses 4K pages. This can improve performances of applications
81 using multiple SPEs by lowering the TLB pressure on them. 81 using multiple SPEs by lowering the TLB pressure on them.
82 82
83config SPU_TRACE
84 tristate "SPU event tracing support"
85 depends on SPU_FS && MARKERS
86 help
87 This option allows reading a trace of spu-related events through
88 the sputrace file in procfs.
89
90config SPU_BASE 83config SPU_BASE
91 bool 84 bool
92 default n 85 default n
diff --git a/arch/powerpc/platforms/cell/celleb_setup.c b/arch/powerpc/platforms/cell/celleb_setup.c
index 07c234f6b2b6..e53845579770 100644
--- a/arch/powerpc/platforms/cell/celleb_setup.c
+++ b/arch/powerpc/platforms/cell/celleb_setup.c
@@ -80,8 +80,7 @@ static void celleb_show_cpuinfo(struct seq_file *m)
80 80
81static int __init celleb_machine_type_hack(char *ptr) 81static int __init celleb_machine_type_hack(char *ptr)
82{ 82{
83 strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type)); 83 strlcpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
84 celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
85 return 0; 84 return 0;
86} 85}
87 86
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 5b34fc211f35..416db17eb18f 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)
642 642
643static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask); 643static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);
644 644
645struct dma_mapping_ops dma_iommu_fixed_ops = { 645struct dma_map_ops dma_iommu_fixed_ops = {
646 .alloc_coherent = dma_fixed_alloc_coherent, 646 .alloc_coherent = dma_fixed_alloc_coherent,
647 .free_coherent = dma_fixed_free_coherent, 647 .free_coherent = dma_fixed_free_coherent,
648 .map_sg = dma_fixed_map_sg, 648 .map_sg = dma_fixed_map_sg,
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index bc97fada48c6..f774530075b7 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -58,8 +58,6 @@
58 */ 58 */
59static cpumask_t of_spin_map; 59static cpumask_t of_spin_map;
60 60
61extern void generic_secondary_smp_init(unsigned long);
62
63/** 61/**
64 * smp_startup_cpu() - start the given cpu 62 * smp_startup_cpu() - start the given cpu
65 * 63 *
diff --git a/arch/powerpc/platforms/cell/spufs/Makefile b/arch/powerpc/platforms/cell/spufs/Makefile
index 99610a6361f2..b93f877ba504 100644
--- a/arch/powerpc/platforms/cell/spufs/Makefile
+++ b/arch/powerpc/platforms/cell/spufs/Makefile
@@ -4,7 +4,8 @@ spufs-y += inode.o file.o context.o syscalls.o coredump.o
4spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o 4spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o
5spufs-y += switch.o fault.o lscsa_alloc.o 5spufs-y += switch.o fault.o lscsa_alloc.o
6 6
7obj-$(CONFIG_SPU_TRACE) += sputrace.o 7# magic for the trace events
8CFLAGS_sched.o := -I$(src)
8 9
9# Rules to build switch.o with the help of SPU tool chain 10# Rules to build switch.o with the help of SPU tool chain
10SPU_CROSS := spu- 11SPU_CROSS := spu-
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index db5398c0339f..0c87bcd2452a 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -28,6 +28,7 @@
28#include <asm/spu.h> 28#include <asm/spu.h>
29#include <asm/spu_csa.h> 29#include <asm/spu_csa.h>
30#include "spufs.h" 30#include "spufs.h"
31#include "sputrace.h"
31 32
32 33
33atomic_t nr_spu_contexts = ATOMIC_INIT(0); 34atomic_t nr_spu_contexts = ATOMIC_INIT(0);
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index d6a519e6e1c1..ab8aef9bb8ea 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -38,6 +38,7 @@
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
39 39
40#include "spufs.h" 40#include "spufs.h"
41#include "sputrace.h"
41 42
42#define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000) 43#define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
43 44
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index f085369301b1..bb5b77c66d05 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -47,6 +47,8 @@
47#include <asm/spu_csa.h> 47#include <asm/spu_csa.h>
48#include <asm/spu_priv1.h> 48#include <asm/spu_priv1.h>
49#include "spufs.h" 49#include "spufs.h"
50#define CREATE_TRACE_POINTS
51#include "sputrace.h"
50 52
51struct spu_prio_array { 53struct spu_prio_array {
52 DECLARE_BITMAP(bitmap, MAX_PRIO); 54 DECLARE_BITMAP(bitmap, MAX_PRIO);
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index ae31573bea4a..c448bac65518 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -373,9 +373,4 @@ extern void spu_free_lscsa(struct spu_state *csa);
373extern void spuctx_switch_state(struct spu_context *ctx, 373extern void spuctx_switch_state(struct spu_context *ctx,
374 enum spu_utilization_state new_state); 374 enum spu_utilization_state new_state);
375 375
376#define spu_context_trace(name, ctx, spu) \
377 trace_mark(name, "ctx %p spu %p", ctx, spu);
378#define spu_context_nospu_trace(name, ctx) \
379 trace_mark(name, "ctx %p", ctx);
380
381#endif 376#endif
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c
deleted file mode 100644
index d0b1f3f4d9c8..000000000000
--- a/arch/powerpc/platforms/cell/spufs/sputrace.c
+++ /dev/null
@@ -1,272 +0,0 @@
1/*
2 * Copyright (C) 2007 IBM Deutschland Entwicklung GmbH
3 * Released under GPL v2.
4 *
5 * Partially based on net/ipv4/tcp_probe.c.
6 *
7 * Simple tracing facility for spu contexts.
8 */
9#include <linux/sched.h>
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/marker.h>
13#include <linux/proc_fs.h>
14#include <linux/wait.h>
15#include <asm/atomic.h>
16#include <asm/uaccess.h>
17#include "spufs.h"
18
19struct spu_probe {
20 const char *name;
21 const char *format;
22 marker_probe_func *probe_func;
23};
24
25struct sputrace {
26 ktime_t tstamp;
27 int owner_tid; /* owner */
28 int curr_tid;
29 const char *name;
30 int number;
31};
32
33static int bufsize __read_mostly = 16384;
34MODULE_PARM_DESC(bufsize, "Log buffer size (number of records)");
35module_param(bufsize, int, 0);
36
37
38static DEFINE_SPINLOCK(sputrace_lock);
39static DECLARE_WAIT_QUEUE_HEAD(sputrace_wait);
40static ktime_t sputrace_start;
41static unsigned long sputrace_head, sputrace_tail;
42static struct sputrace *sputrace_log;
43static int sputrace_logging;
44
45static int sputrace_used(void)
46{
47 return (sputrace_head - sputrace_tail) % bufsize;
48}
49
50static inline int sputrace_avail(void)
51{
52 return bufsize - sputrace_used();
53}
54
55static int sputrace_sprint(char *tbuf, int n)
56{
57 const struct sputrace *t = sputrace_log + sputrace_tail % bufsize;
58 struct timespec tv =
59 ktime_to_timespec(ktime_sub(t->tstamp, sputrace_start));
60
61 return snprintf(tbuf, n,
62 "[%lu.%09lu] %d: %s (ctxthread = %d, spu = %d)\n",
63 (unsigned long) tv.tv_sec,
64 (unsigned long) tv.tv_nsec,
65 t->curr_tid,
66 t->name,
67 t->owner_tid,
68 t->number);
69}
70
71static ssize_t sputrace_read(struct file *file, char __user *buf,
72 size_t len, loff_t *ppos)
73{
74 int error = 0, cnt = 0;
75
76 if (!buf || len < 0)
77 return -EINVAL;
78
79 while (cnt < len) {
80 char tbuf[128];
81 int width;
82
83 /* If we have data ready to return, don't block waiting
84 * for more */
85 if (cnt > 0 && sputrace_used() == 0)
86 break;
87
88 error = wait_event_interruptible(sputrace_wait,
89 sputrace_used() > 0);
90 if (error)
91 break;
92
93 spin_lock(&sputrace_lock);
94 if (sputrace_head == sputrace_tail) {
95 spin_unlock(&sputrace_lock);
96 continue;
97 }
98
99 width = sputrace_sprint(tbuf, sizeof(tbuf));
100 if (width < len)
101 sputrace_tail = (sputrace_tail + 1) % bufsize;
102 spin_unlock(&sputrace_lock);
103
104 if (width >= len)
105 break;
106
107 error = copy_to_user(buf + cnt, tbuf, width);
108 if (error)
109 break;
110 cnt += width;
111 }
112
113 return cnt == 0 ? error : cnt;
114}
115
116static int sputrace_open(struct inode *inode, struct file *file)
117{
118 int rc;
119
120 spin_lock(&sputrace_lock);
121 if (sputrace_logging) {
122 rc = -EBUSY;
123 goto out;
124 }
125
126 sputrace_logging = 1;
127 sputrace_head = sputrace_tail = 0;
128 sputrace_start = ktime_get();
129 rc = 0;
130
131out:
132 spin_unlock(&sputrace_lock);
133 return rc;
134}
135
136static int sputrace_release(struct inode *inode, struct file *file)
137{
138 spin_lock(&sputrace_lock);
139 sputrace_logging = 0;
140 spin_unlock(&sputrace_lock);
141 return 0;
142}
143
144static const struct file_operations sputrace_fops = {
145 .owner = THIS_MODULE,
146 .open = sputrace_open,
147 .read = sputrace_read,
148 .release = sputrace_release,
149};
150
151static void sputrace_log_item(const char *name, struct spu_context *ctx,
152 struct spu *spu)
153{
154 spin_lock(&sputrace_lock);
155
156 if (!sputrace_logging) {
157 spin_unlock(&sputrace_lock);
158 return;
159 }
160
161 if (sputrace_avail() > 1) {
162 struct sputrace *t = sputrace_log + sputrace_head;
163
164 t->tstamp = ktime_get();
165 t->owner_tid = ctx->tid;
166 t->name = name;
167 t->curr_tid = current->pid;
168 t->number = spu ? spu->number : -1;
169
170 sputrace_head = (sputrace_head + 1) % bufsize;
171 } else {
172 printk(KERN_WARNING
173 "sputrace: lost samples due to full buffer.\n");
174 }
175 spin_unlock(&sputrace_lock);
176
177 wake_up(&sputrace_wait);
178}
179
180static void spu_context_event(void *probe_private, void *call_data,
181 const char *format, va_list *args)
182{
183 struct spu_probe *p = probe_private;
184 struct spu_context *ctx;
185 struct spu *spu;
186
187 ctx = va_arg(*args, struct spu_context *);
188 spu = va_arg(*args, struct spu *);
189
190 sputrace_log_item(p->name, ctx, spu);
191}
192
193static void spu_context_nospu_event(void *probe_private, void *call_data,
194 const char *format, va_list *args)
195{
196 struct spu_probe *p = probe_private;
197 struct spu_context *ctx;
198
199 ctx = va_arg(*args, struct spu_context *);
200
201 sputrace_log_item(p->name, ctx, NULL);
202}
203
204struct spu_probe spu_probes[] = {
205 { "spu_bind_context__enter", "ctx %p spu %p", spu_context_event },
206 { "spu_unbind_context__enter", "ctx %p spu %p", spu_context_event },
207 { "spu_get_idle__enter", "ctx %p", spu_context_nospu_event },
208 { "spu_get_idle__found", "ctx %p spu %p", spu_context_event },
209 { "spu_get_idle__not_found", "ctx %p", spu_context_nospu_event },
210 { "spu_find_victim__enter", "ctx %p", spu_context_nospu_event },
211 { "spusched_tick__preempt", "ctx %p spu %p", spu_context_event },
212 { "spusched_tick__newslice", "ctx %p", spu_context_nospu_event },
213 { "spu_yield__enter", "ctx %p", spu_context_nospu_event },
214 { "spu_deactivate__enter", "ctx %p", spu_context_nospu_event },
215 { "__spu_deactivate__unload", "ctx %p spu %p", spu_context_event },
216 { "spufs_ps_fault__enter", "ctx %p", spu_context_nospu_event },
217 { "spufs_ps_fault__sleep", "ctx %p", spu_context_nospu_event },
218 { "spufs_ps_fault__wake", "ctx %p spu %p", spu_context_event },
219 { "spufs_ps_fault__insert", "ctx %p spu %p", spu_context_event },
220 { "spu_acquire_saved__enter", "ctx %p", spu_context_nospu_event },
221 { "destroy_spu_context__enter", "ctx %p", spu_context_nospu_event },
222 { "spufs_stop_callback__enter", "ctx %p spu %p", spu_context_event },
223};
224
225static int __init sputrace_init(void)
226{
227 struct proc_dir_entry *entry;
228 int i, error = -ENOMEM;
229
230 sputrace_log = kcalloc(bufsize, sizeof(struct sputrace), GFP_KERNEL);
231 if (!sputrace_log)
232 goto out;
233
234 entry = proc_create("sputrace", S_IRUSR, NULL, &sputrace_fops);
235 if (!entry)
236 goto out_free_log;
237
238 for (i = 0; i < ARRAY_SIZE(spu_probes); i++) {
239 struct spu_probe *p = &spu_probes[i];
240
241 error = marker_probe_register(p->name, p->format,
242 p->probe_func, p);
243 if (error)
244 printk(KERN_INFO "Unable to register probe %s\n",
245 p->name);
246 }
247
248 return 0;
249
250out_free_log:
251 kfree(sputrace_log);
252out:
253 return -ENOMEM;
254}
255
256static void __exit sputrace_exit(void)
257{
258 int i;
259
260 for (i = 0; i < ARRAY_SIZE(spu_probes); i++)
261 marker_probe_unregister(spu_probes[i].name,
262 spu_probes[i].probe_func, &spu_probes[i]);
263
264 remove_proc_entry("sputrace", NULL);
265 kfree(sputrace_log);
266 marker_synchronize_unregister();
267}
268
269module_init(sputrace_init);
270module_exit(sputrace_exit);
271
272MODULE_LICENSE("GPL");
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.h b/arch/powerpc/platforms/cell/spufs/sputrace.h
new file mode 100644
index 000000000000..db2656aa4103
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.h
@@ -0,0 +1,39 @@
1#if !defined(_TRACE_SPUFS_H) || defined(TRACE_HEADER_MULTI_READ)
2#define _TRACE_SPUFS_H
3
4#include <linux/tracepoint.h>
5
6#undef TRACE_SYSTEM
7#define TRACE_SYSTEM spufs
8
9TRACE_EVENT(spufs_context,
10 TP_PROTO(struct spu_context *ctx, struct spu *spu, const char *name),
11 TP_ARGS(ctx, spu, name),
12
13 TP_STRUCT__entry(
14 __field(const char *, name)
15 __field(int, owner_tid)
16 __field(int, number)
17 ),
18
19 TP_fast_assign(
20 __entry->name = name;
21 __entry->owner_tid = ctx->tid;
22 __entry->number = spu ? spu->number : -1;
23 ),
24
25 TP_printk("%s (ctxthread = %d, spu = %d)",
26 __entry->name, __entry->owner_tid, __entry->number)
27);
28
29#define spu_context_trace(name, ctx, spu) \
30 trace_spufs_context(ctx, spu, __stringify(name))
31#define spu_context_nospu_trace(name, ctx) \
32 trace_spufs_context(ctx, NULL, __stringify(name))
33
34#endif /* _TRACE_SPUFS_H */
35
36#undef TRACE_INCLUDE_PATH
37#define TRACE_INCLUDE_PATH .
38#define TRACE_INCLUDE_FILE sputrace
39#include <trace/define_trace.h>
diff --git a/arch/powerpc/platforms/iseries/exception.S b/arch/powerpc/platforms/iseries/exception.S
index 2f581521eb9b..5369653dcf6a 100644
--- a/arch/powerpc/platforms/iseries/exception.S
+++ b/arch/powerpc/platforms/iseries/exception.S
@@ -47,7 +47,7 @@ system_reset_iSeries:
47 LOAD_REG_ADDR(r13, paca) 47 LOAD_REG_ADDR(r13, paca)
48 mulli r0,r23,PACA_SIZE 48 mulli r0,r23,PACA_SIZE
49 add r13,r13,r0 49 add r13,r13,r0
50 mtspr SPRN_SPRG3,r13 /* Save it away for the future */ 50 mtspr SPRN_SPRG_PACA,r13 /* Save it away for the future */
51 mfmsr r24 51 mfmsr r24
52 ori r24,r24,MSR_RI 52 ori r24,r24,MSR_RI
53 mtmsrd r24 /* RI on */ 53 mtmsrd r24 /* RI on */
@@ -116,7 +116,7 @@ iSeries_secondary_smp_loop:
116#endif /* CONFIG_SMP */ 116#endif /* CONFIG_SMP */
117 li r0,-1 /* r0=-1 indicates a Hypervisor call */ 117 li r0,-1 /* r0=-1 indicates a Hypervisor call */
118 sc /* Invoke the hypervisor via a system call */ 118 sc /* Invoke the hypervisor via a system call */
119 mfspr r13,SPRN_SPRG3 /* Put r13 back ???? */ 119 mfspr r13,SPRN_SPRG_PACA /* Put r13 back ???? */
120 b 2b /* If SMP not configured, secondaries 120 b 2b /* If SMP not configured, secondaries
121 * loop forever */ 121 * loop forever */
122 122
@@ -126,34 +126,45 @@ iSeries_secondary_smp_loop:
126 126
127 .globl data_access_iSeries 127 .globl data_access_iSeries
128data_access_iSeries: 128data_access_iSeries:
129 mtspr SPRN_SPRG1,r13 129 mtspr SPRN_SPRG_SCRATCH0,r13
130BEGIN_FTR_SECTION 130BEGIN_FTR_SECTION
131 mtspr SPRN_SPRG2,r12 131 mfspr r13,SPRN_SPRG_PACA
132 mfspr r13,SPRN_DAR 132 std r9,PACA_EXSLB+EX_R9(r13)
133 mfspr r12,SPRN_DSISR 133 std r10,PACA_EXSLB+EX_R10(r13)
134 srdi r13,r13,60 134 mfspr r10,SPRN_DAR
135 rlwimi r13,r12,16,0x20 135 mfspr r9,SPRN_DSISR
136 mfcr r12 136 srdi r10,r10,60
137 cmpwi r13,0x2c 137 rlwimi r10,r9,16,0x20
138 mfcr r9
139 cmpwi r10,0x2c
138 beq .do_stab_bolted_iSeries 140 beq .do_stab_bolted_iSeries
139 mtcrf 0x80,r12 141 ld r10,PACA_EXSLB+EX_R10(r13)
140 mfspr r12,SPRN_SPRG2 142 std r11,PACA_EXGEN+EX_R11(r13)
141END_FTR_SECTION_IFCLR(CPU_FTR_SLB) 143 ld r11,PACA_EXSLB+EX_R9(r13)
144 std r12,PACA_EXGEN+EX_R12(r13)
145 mfspr r12,SPRN_SPRG_SCRATCH0
146 std r10,PACA_EXGEN+EX_R10(r13)
147 std r11,PACA_EXGEN+EX_R9(r13)
148 std r12,PACA_EXGEN+EX_R13(r13)
149 EXCEPTION_PROLOG_ISERIES_1
150FTR_SECTION_ELSE
142 EXCEPTION_PROLOG_1(PACA_EXGEN) 151 EXCEPTION_PROLOG_1(PACA_EXGEN)
143 EXCEPTION_PROLOG_ISERIES_1 152 EXCEPTION_PROLOG_ISERIES_1
153ALT_FTR_SECTION_END_IFCLR(CPU_FTR_SLB)
144 b data_access_common 154 b data_access_common
145 155
146.do_stab_bolted_iSeries: 156.do_stab_bolted_iSeries:
147 mtcrf 0x80,r12 157 std r11,PACA_EXSLB+EX_R11(r13)
148 mfspr r12,SPRN_SPRG2 158 std r12,PACA_EXSLB+EX_R12(r13)
149 EXCEPTION_PROLOG_1(PACA_EXSLB) 159 mfspr r10,SPRN_SPRG_SCRATCH0
160 std r10,PACA_EXSLB+EX_R13(r13)
150 EXCEPTION_PROLOG_ISERIES_1 161 EXCEPTION_PROLOG_ISERIES_1
151 b .do_stab_bolted 162 b .do_stab_bolted
152 163
153 .globl data_access_slb_iSeries 164 .globl data_access_slb_iSeries
154data_access_slb_iSeries: 165data_access_slb_iSeries:
155 mtspr SPRN_SPRG1,r13 /* save r13 */ 166 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
156 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ 167 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
157 std r3,PACA_EXSLB+EX_R3(r13) 168 std r3,PACA_EXSLB+EX_R3(r13)
158 mfspr r3,SPRN_DAR 169 mfspr r3,SPRN_DAR
159 std r9,PACA_EXSLB+EX_R9(r13) 170 std r9,PACA_EXSLB+EX_R9(r13)
@@ -165,7 +176,7 @@ data_access_slb_iSeries:
165 std r10,PACA_EXSLB+EX_R10(r13) 176 std r10,PACA_EXSLB+EX_R10(r13)
166 std r11,PACA_EXSLB+EX_R11(r13) 177 std r11,PACA_EXSLB+EX_R11(r13)
167 std r12,PACA_EXSLB+EX_R12(r13) 178 std r12,PACA_EXSLB+EX_R12(r13)
168 mfspr r10,SPRN_SPRG1 179 mfspr r10,SPRN_SPRG_SCRATCH0
169 std r10,PACA_EXSLB+EX_R13(r13) 180 std r10,PACA_EXSLB+EX_R13(r13)
170 ld r12,PACALPPACAPTR(r13) 181 ld r12,PACALPPACAPTR(r13)
171 ld r12,LPPACASRR1(r12) 182 ld r12,LPPACASRR1(r12)
@@ -175,8 +186,8 @@ data_access_slb_iSeries:
175 186
176 .globl instruction_access_slb_iSeries 187 .globl instruction_access_slb_iSeries
177instruction_access_slb_iSeries: 188instruction_access_slb_iSeries:
178 mtspr SPRN_SPRG1,r13 /* save r13 */ 189 mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
179 mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ 190 mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
180 std r3,PACA_EXSLB+EX_R3(r13) 191 std r3,PACA_EXSLB+EX_R3(r13)
181 ld r3,PACALPPACAPTR(r13) 192 ld r3,PACALPPACAPTR(r13)
182 ld r3,LPPACASRR0(r3) /* get SRR0 value */ 193 ld r3,LPPACASRR0(r3) /* get SRR0 value */
@@ -189,7 +200,7 @@ instruction_access_slb_iSeries:
189 std r10,PACA_EXSLB+EX_R10(r13) 200 std r10,PACA_EXSLB+EX_R10(r13)
190 std r11,PACA_EXSLB+EX_R11(r13) 201 std r11,PACA_EXSLB+EX_R11(r13)
191 std r12,PACA_EXSLB+EX_R12(r13) 202 std r12,PACA_EXSLB+EX_R12(r13)
192 mfspr r10,SPRN_SPRG1 203 mfspr r10,SPRN_SPRG_SCRATCH0
193 std r10,PACA_EXSLB+EX_R13(r13) 204 std r10,PACA_EXSLB+EX_R13(r13)
194 ld r12,PACALPPACAPTR(r13) 205 ld r12,PACALPPACAPTR(r13)
195 ld r12,LPPACASRR1(r12) 206 ld r12,LPPACASRR1(r12)
@@ -200,7 +211,7 @@ slb_miss_user_iseries:
200 std r10,PACA_EXGEN+EX_R10(r13) 211 std r10,PACA_EXGEN+EX_R10(r13)
201 std r11,PACA_EXGEN+EX_R11(r13) 212 std r11,PACA_EXGEN+EX_R11(r13)
202 std r12,PACA_EXGEN+EX_R12(r13) 213 std r12,PACA_EXGEN+EX_R12(r13)
203 mfspr r10,SPRG1 214 mfspr r10,SPRG_SCRATCH0
204 ld r11,PACA_EXSLB+EX_R9(r13) 215 ld r11,PACA_EXSLB+EX_R9(r13)
205 ld r12,PACA_EXSLB+EX_R3(r13) 216 ld r12,PACA_EXSLB+EX_R3(r13)
206 std r10,PACA_EXGEN+EX_R13(r13) 217 std r10,PACA_EXGEN+EX_R13(r13)
@@ -221,7 +232,7 @@ slb_miss_user_iseries:
221 .globl system_call_iSeries 232 .globl system_call_iSeries
222system_call_iSeries: 233system_call_iSeries:
223 mr r9,r13 234 mr r9,r13
224 mfspr r13,SPRN_SPRG3 235 mfspr r13,SPRN_SPRG_PACA
225 EXCEPTION_PROLOG_ISERIES_1 236 EXCEPTION_PROLOG_ISERIES_1
226 b system_call_common 237 b system_call_common
227 238
diff --git a/arch/powerpc/platforms/iseries/exception.h b/arch/powerpc/platforms/iseries/exception.h
index ced45a8fa1aa..bae3fba5ad8e 100644
--- a/arch/powerpc/platforms/iseries/exception.h
+++ b/arch/powerpc/platforms/iseries/exception.h
@@ -24,7 +24,7 @@
24 * as published by the Free Software Foundation; either version 24 * as published by the Free Software Foundation; either version
25 * 2 of the License, or (at your option) any later version. 25 * 2 of the License, or (at your option) any later version.
26 */ 26 */
27#include <asm/exception.h> 27#include <asm/exception-64s.h>
28 28
29#define EXCEPTION_PROLOG_ISERIES_1 \ 29#define EXCEPTION_PROLOG_ISERIES_1 \
30 mfmsr r10; \ 30 mfmsr r10; \
@@ -38,7 +38,7 @@
38 .globl label##_iSeries; \ 38 .globl label##_iSeries; \
39label##_iSeries: \ 39label##_iSeries: \
40 HMT_MEDIUM; \ 40 HMT_MEDIUM; \
41 mtspr SPRN_SPRG1,r13; /* save r13 */ \ 41 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \
42 EXCEPTION_PROLOG_1(area); \ 42 EXCEPTION_PROLOG_1(area); \
43 EXCEPTION_PROLOG_ISERIES_1; \ 43 EXCEPTION_PROLOG_ISERIES_1; \
44 b label##_common 44 b label##_common
@@ -47,7 +47,7 @@ label##_iSeries: \
47 .globl label##_iSeries; \ 47 .globl label##_iSeries; \
48label##_iSeries: \ 48label##_iSeries: \
49 HMT_MEDIUM; \ 49 HMT_MEDIUM; \
50 mtspr SPRN_SPRG1,r13; /* save r13 */ \ 50 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \
51 EXCEPTION_PROLOG_1(PACA_EXGEN); \ 51 EXCEPTION_PROLOG_1(PACA_EXGEN); \
52 lbz r10,PACASOFTIRQEN(r13); \ 52 lbz r10,PACASOFTIRQEN(r13); \
53 cmpwi 0,r10,0; \ 53 cmpwi 0,r10,0; \
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index fef4d5150517..0d9343df35bc 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -872,7 +872,7 @@ static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
872 count = 256 - off; 872 count = 256 - off;
873 873
874 dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE); 874 dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE);
875 if (dma_mapping_error(NULL, dma_addr)) 875 if (dma_addr == DMA_ERROR_CODE)
876 return -ENOMEM; 876 return -ENOMEM;
877 memset(page, 0, off + count); 877 memset(page, 0, off + count);
878 memset(&vsp_cmd, 0, sizeof(vsp_cmd)); 878 memset(&vsp_cmd, 0, sizeof(vsp_cmd));
diff --git a/arch/powerpc/platforms/pasemi/idle.c b/arch/powerpc/platforms/pasemi/idle.c
index 43911d8b0206..75b296bc51af 100644
--- a/arch/powerpc/platforms/pasemi/idle.c
+++ b/arch/powerpc/platforms/pasemi/idle.c
@@ -90,7 +90,7 @@ machine_late_initcall(pasemi, pasemi_idle_init);
90static int __init idle_param(char *p) 90static int __init idle_param(char *p)
91{ 91{
92 int i; 92 int i;
93 for (i = 0; i < sizeof(modes)/sizeof(struct sleep_mode); i++) { 93 for (i = 0; i < ARRAY_SIZE(modes); i++) {
94 if (!strcmp(modes[i].name, p)) { 94 if (!strcmp(modes[i].name, p)) {
95 current_mode = i; 95 current_mode = i;
96 break; 96 break;
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 65c585b8b00d..08d94e4cedd3 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -44,14 +44,6 @@
44 */ 44 */
45#undef DEBUG_FREQ 45#undef DEBUG_FREQ
46 46
47/*
48 * There is a problem with the core cpufreq code on SMP kernels,
49 * it won't recalculate the Bogomips properly
50 */
51#ifdef CONFIG_SMP
52#warning "WARNING, CPUFREQ not recommended on SMP kernels"
53#endif
54
55extern void low_choose_7447a_dfs(int dfs); 47extern void low_choose_7447a_dfs(int dfs);
56extern void low_choose_750fx_pll(int pll); 48extern void low_choose_750fx_pll(int pll);
57extern void low_sleep_handler(void); 49extern void low_sleep_handler(void);
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index e6c0040ee797..fbc9bbd74dbd 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -2419,13 +2419,13 @@ static int __init probe_motherboard(void)
2419 dt = of_find_node_by_name(NULL, "device-tree"); 2419 dt = of_find_node_by_name(NULL, "device-tree");
2420 if (dt != NULL) 2420 if (dt != NULL)
2421 model = of_get_property(dt, "model", NULL); 2421 model = of_get_property(dt, "model", NULL);
2422 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { 2422 for(i=0; model && i<ARRAY_SIZE(pmac_mb_defs); i++) {
2423 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { 2423 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
2424 pmac_mb = pmac_mb_defs[i]; 2424 pmac_mb = pmac_mb_defs[i];
2425 goto found; 2425 goto found;
2426 } 2426 }
2427 } 2427 }
2428 for(i=0; i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { 2428 for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) {
2429 if (machine_is_compatible(pmac_mb_defs[i].model_string)) { 2429 if (machine_is_compatible(pmac_mb_defs[i].model_string)) {
2430 pmac_mb = pmac_mb_defs[i]; 2430 pmac_mb = pmac_mb_defs[i];
2431 goto found; 2431 goto found;
@@ -2589,9 +2589,16 @@ static void __init probe_uninorth(void)
2589 if (address == 0) 2589 if (address == 0)
2590 return; 2590 return;
2591 uninorth_base = ioremap(address, 0x40000); 2591 uninorth_base = ioremap(address, 0x40000);
2592 if (uninorth_base == NULL)
2593 return;
2592 uninorth_rev = in_be32(UN_REG(UNI_N_VERSION)); 2594 uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
2593 if (uninorth_maj == 3 || uninorth_maj == 4) 2595 if (uninorth_maj == 3 || uninorth_maj == 4) {
2594 u3_ht_base = ioremap(address + U3_HT_CONFIG_BASE, 0x1000); 2596 u3_ht_base = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
2597 if (u3_ht_base == NULL) {
2598 iounmap(uninorth_base);
2599 return;
2600 }
2601 }
2595 2602
2596 printk(KERN_INFO "Found %s memory controller & host bridge" 2603 printk(KERN_INFO "Found %s memory controller & host bridge"
2597 " @ 0x%08x revision: 0x%02x\n", uninorth_maj == 3 ? "U3" : 2604 " @ 0x%08x revision: 0x%02x\n", uninorth_maj == 3 ? "U3" :
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 04cdd32624d4..e81403b245b5 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -1286,3 +1286,64 @@ static void fixup_k2_sata(struct pci_dev* dev)
1286} 1286}
1287DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS, 0x0240, fixup_k2_sata); 1287DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS, 0x0240, fixup_k2_sata);
1288 1288
1289/*
1290 * On U4 (aka CPC945) the PCIe root complex "P2P" bridge resource ranges aren't
1291 * configured by the firmware. The bridge itself seems to ignore them but it
1292 * causes problems with Linux which then re-assigns devices below the bridge,
1293 * thus changing addresses of those devices from what was in the device-tree,
1294 * which sucks when those are video cards using offb
1295 *
1296 * We could just mark it transparent but I prefer fixing up the resources to
1297 * properly show what's going on here, as I have some doubts about having them
1298 * badly configured potentially being an issue for DMA.
1299 *
1300 * We leave PIO alone, it seems to be fine
1301 *
1302 * Oh and there's another funny bug. The OF properties advertize the region
1303 * 0xf1000000..0xf1ffffff as being forwarded as memory space. But that's
1304 * actually not true, this region is the memory mapped config space. So we
1305 * also need to filter it out or we'll map things in the wrong place.
1306 */
1307static void fixup_u4_pcie(struct pci_dev* dev)
1308{
1309 struct pci_controller *host = pci_bus_to_host(dev->bus);
1310 struct resource *region = NULL;
1311 u32 reg;
1312 int i;
1313
1314 /* Only do that on PowerMac */
1315 if (!machine_is(powermac))
1316 return;
1317
1318 /* Find the largest MMIO region */
1319 for (i = 0; i < 3; i++) {
1320 struct resource *r = &host->mem_resources[i];
1321 if (!(r->flags & IORESOURCE_MEM))
1322 continue;
1323 /* Skip the 0xf0xxxxxx..f2xxxxxx regions, we know they
1324 * are reserved by HW for other things
1325 */
1326 if (r->start >= 0xf0000000 && r->start < 0xf3000000)
1327 continue;
1328 if (!region || (r->end - r->start) >
1329 (region->end - region->start))
1330 region = r;
1331 }
1332 /* Nothing found, bail */
1333 if (region == 0)
1334 return;
1335
1336 /* Print things out */
1337 printk(KERN_INFO "PCI: Fixup U4 PCIe bridge range: %pR\n", region);
1338
1339 /* Fixup bridge config space. We know it's a Mac, resource aren't
1340 * offset so let's just blast them as-is. We also know that they
1341 * fit in 32 bits
1342 */
1343 reg = ((region->start >> 16) & 0xfff0) | (region->end & 0xfff00000);
1344 pci_write_config_dword(dev, PCI_MEMORY_BASE, reg);
1345 pci_write_config_dword(dev, PCI_PREF_BASE_UPPER32, 0);
1346 pci_write_config_dword(dev, PCI_PREF_LIMIT_UPPER32, 0);
1347 pci_write_config_dword(dev, PCI_PREF_MEMORY_BASE, 0);
1348}
1349DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_U4_PCIE, fixup_u4_pcie);
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 6d4da7b46b41..937a38e73178 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -408,7 +408,7 @@ static void __init smp_psurge_setup_cpu(int cpu_nr)
408 /* reset the entry point so if we get another intr we won't 408 /* reset the entry point so if we get another intr we won't
409 * try to startup again */ 409 * try to startup again */
410 out_be32(psurge_start, 0x100); 410 out_be32(psurge_start, 0x100);
411 if (setup_irq(30, &psurge_irqaction)) 411 if (setup_irq(irq_create_mapping(NULL, 30), &psurge_irqaction))
412 printk(KERN_ERR "Couldn't get primary IPI interrupt"); 412 printk(KERN_ERR "Couldn't get primary IPI interrupt");
413} 413}
414 414
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 846eb8b57fd1..189a25b80735 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -23,8 +23,8 @@
23#include <linux/memory_hotplug.h> 23#include <linux/memory_hotplug.h>
24#include <linux/lmb.h> 24#include <linux/lmb.h>
25 25
26#include <asm/cell-regs.h>
26#include <asm/firmware.h> 27#include <asm/firmware.h>
27#include <asm/iommu.h>
28#include <asm/prom.h> 28#include <asm/prom.h>
29#include <asm/udbg.h> 29#include <asm/udbg.h>
30#include <asm/lv1call.h> 30#include <asm/lv1call.h>
diff --git a/arch/powerpc/platforms/ps3/smp.c b/arch/powerpc/platforms/ps3/smp.c
index f6e04bcc70ef..51ffde40af2b 100644
--- a/arch/powerpc/platforms/ps3/smp.c
+++ b/arch/powerpc/platforms/ps3/smp.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#define MSG_COUNT 4 39#define MSG_COUNT 4
40static DEFINE_PER_CPU(unsigned int, ps3_ipi_virqs[MSG_COUNT]); 40static DEFINE_PER_CPU(unsigned int [MSG_COUNT], ps3_ipi_virqs);
41 41
42static void do_message_pass(int target, int msg) 42static void do_message_pass(int target, int msg)
43{ 43{
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 3f763c5284ac..e34b305a7a52 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -27,7 +27,7 @@
27#include <asm/udbg.h> 27#include <asm/udbg.h>
28#include <asm/lv1call.h> 28#include <asm/lv1call.h>
29#include <asm/firmware.h> 29#include <asm/firmware.h>
30#include <asm/iommu.h> 30#include <asm/cell-regs.h>
31 31
32#include "platform.h" 32#include "platform.h"
33 33
@@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device *_dev, u64 mask)
694 return mask >= DMA_BIT_MASK(32); 694 return mask >= DMA_BIT_MASK(32);
695} 695}
696 696
697static struct dma_mapping_ops ps3_sb_dma_ops = { 697static struct dma_map_ops ps3_sb_dma_ops = {
698 .alloc_coherent = ps3_alloc_coherent, 698 .alloc_coherent = ps3_alloc_coherent,
699 .free_coherent = ps3_free_coherent, 699 .free_coherent = ps3_free_coherent,
700 .map_sg = ps3_sb_map_sg, 700 .map_sg = ps3_sb_map_sg,
@@ -704,7 +704,7 @@ static struct dma_mapping_ops ps3_sb_dma_ops = {
704 .unmap_page = ps3_unmap_page, 704 .unmap_page = ps3_unmap_page,
705}; 705};
706 706
707static struct dma_mapping_ops ps3_ioc0_dma_ops = { 707static struct dma_map_ops ps3_ioc0_dma_ops = {
708 .alloc_coherent = ps3_alloc_coherent, 708 .alloc_coherent = ps3_alloc_coherent,
709 .free_coherent = ps3_free_coherent, 709 .free_coherent = ps3_free_coherent,
710 .map_sg = ps3_ioc0_map_sg, 710 .map_sg = ps3_ioc0_map_sg,
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 989d6462c154..ccd8dd03b8c9 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -744,7 +744,15 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state stat
744 744
745static void __rtas_set_slot_reset(struct pci_dn *pdn) 745static void __rtas_set_slot_reset(struct pci_dn *pdn)
746{ 746{
747 rtas_pci_slot_reset (pdn, 1); 747 struct pci_dev *dev = pdn->pcidev;
748
749 /* Determine type of EEH reset required by device,
750 * default hot reset or fundamental reset
751 */
752 if (dev->needs_freset)
753 rtas_pci_slot_reset(pdn, 3);
754 else
755 rtas_pci_slot_reset(pdn, 1);
748 756
749 /* The PCI bus requires that the reset be held high for at least 757 /* The PCI bus requires that the reset be held high for at least
750 * a 100 milliseconds. We wait a bit longer 'just in case'. */ 758 * a 100 milliseconds. We wait a bit longer 'just in case'. */
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index ad152a0e3946..b6fa3e4b51b5 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -151,7 +151,7 @@ struct pci_controller * __devinit init_phb_dynamic(struct device_node *dn)
151 if (dn->child) 151 if (dn->child)
152 eeh_add_device_tree_early(dn); 152 eeh_add_device_tree_early(dn);
153 153
154 scan_phb(phb); 154 pcibios_scan_phb(phb, dn);
155 pcibios_finish_adding_to_bus(phb->bus); 155 pcibios_finish_adding_to_bus(phb->bus);
156 156
157 return phb; 157 return phb;
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index b6f1b137d427..2e2bbe120b90 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -20,6 +20,7 @@
20#include <asm/machdep.h> 20#include <asm/machdep.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22#include <asm/pSeries_reconfig.h> 22#include <asm/pSeries_reconfig.h>
23#include <asm/mmu.h>
23 24
24 25
25 26
@@ -439,9 +440,15 @@ static int do_update_property(char *buf, size_t bufsize)
439 if (!newprop) 440 if (!newprop)
440 return -ENOMEM; 441 return -ENOMEM;
441 442
443 if (!strcmp(name, "slb-size") || !strcmp(name, "ibm,slb-size"))
444 slb_set_size(*(int *)value);
445
442 oldprop = of_find_property(np, name,NULL); 446 oldprop = of_find_property(np, name,NULL);
443 if (!oldprop) 447 if (!oldprop) {
448 if (strlen(name))
449 return prom_add_property(np, newprop);
444 return -ENODEV; 450 return -ENODEV;
451 }
445 452
446 rc = prom_update_property(np, newprop, oldprop); 453 rc = prom_update_property(np, newprop, oldprop);
447 if (rc) 454 if (rc)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 8d75ea21296f..ca5f2e10972c 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -223,10 +223,6 @@ static void pseries_lpar_enable_pmcs(void)
223 set = 1UL << 63; 223 set = 1UL << 63;
224 reset = 0; 224 reset = 0;
225 plpar_hcall_norets(H_PERFMON, set, reset); 225 plpar_hcall_norets(H_PERFMON, set, reset);
226
227 /* instruct hypervisor to maintain PMCs */
228 if (firmware_has_feature(FW_FEATURE_SPLPAR))
229 get_lppaca()->pmcregs_in_use = 1;
230} 226}
231 227
232static void __init pseries_discover_pic(void) 228static void __init pseries_discover_pic(void)
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 1f8f6cfb94f7..440000cc7130 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -56,8 +56,6 @@
56 */ 56 */
57static cpumask_t of_spin_map; 57static cpumask_t of_spin_map;
58 58
59extern void generic_secondary_smp_init(unsigned long);
60
61/** 59/**
62 * smp_startup_cpu() - start the given cpu 60 * smp_startup_cpu() - start the given cpu
63 * 61 *
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index cbb3bed75d3c..757a83fe5e59 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1057,6 +1057,10 @@ int fsl_rio_setup(struct of_device *dev)
1057 law_start, law_size); 1057 law_start, law_size);
1058 1058
1059 ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL); 1059 ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL);
1060 if (!ops) {
1061 rc = -ENOMEM;
1062 goto err_ops;
1063 }
1060 ops->lcread = fsl_local_config_read; 1064 ops->lcread = fsl_local_config_read;
1061 ops->lcwrite = fsl_local_config_write; 1065 ops->lcwrite = fsl_local_config_write;
1062 ops->cread = fsl_rio_config_read; 1066 ops->cread = fsl_rio_config_read;
@@ -1064,6 +1068,10 @@ int fsl_rio_setup(struct of_device *dev)
1064 ops->dsend = fsl_rio_doorbell_send; 1068 ops->dsend = fsl_rio_doorbell_send;
1065 1069
1066 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL); 1070 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
1071 if (!port) {
1072 rc = -ENOMEM;
1073 goto err_port;
1074 }
1067 port->id = 0; 1075 port->id = 0;
1068 port->index = 0; 1076 port->index = 0;
1069 1077
@@ -1071,7 +1079,7 @@ int fsl_rio_setup(struct of_device *dev)
1071 if (!priv) { 1079 if (!priv) {
1072 printk(KERN_ERR "Can't alloc memory for 'priv'\n"); 1080 printk(KERN_ERR "Can't alloc memory for 'priv'\n");
1073 rc = -ENOMEM; 1081 rc = -ENOMEM;
1074 goto err; 1082 goto err_priv;
1075 } 1083 }
1076 1084
1077 INIT_LIST_HEAD(&port->dbells); 1085 INIT_LIST_HEAD(&port->dbells);
@@ -1169,11 +1177,13 @@ int fsl_rio_setup(struct of_device *dev)
1169 1177
1170 return 0; 1178 return 0;
1171err: 1179err:
1172 if (priv) 1180 iounmap(priv->regs_win);
1173 iounmap(priv->regs_win);
1174 kfree(ops);
1175 kfree(priv); 1181 kfree(priv);
1182err_priv:
1176 kfree(port); 1183 kfree(port);
1184err_port:
1185 kfree(ops);
1186err_ops:
1177 return rc; 1187 return rc;
1178} 1188}
1179 1189
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 95dbc643c4fc..adca4affcf1f 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -37,6 +37,7 @@
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/time.h> 38#include <asm/time.h>
39#include <asm/prom.h> 39#include <asm/prom.h>
40#include <asm/machdep.h>
40#include <sysdev/fsl_soc.h> 41#include <sysdev/fsl_soc.h>
41#include <mm/mmu_decl.h> 42#include <mm/mmu_decl.h>
42#include <asm/cpm2.h> 43#include <asm/cpm2.h>
@@ -383,8 +384,9 @@ static int __init setup_rstcr(void)
383 if (!rstcr) 384 if (!rstcr)
384 printk (KERN_EMERG "Error: reset control register " 385 printk (KERN_EMERG "Error: reset control register "
385 "not mapped!\n"); 386 "not mapped!\n");
386 } else 387 } else if (ppc_md.restart == fsl_rstcr_restart)
387 printk (KERN_INFO "rstcr compatible register does not exist!\n"); 388 printk(KERN_ERR "No RSTCR register, warm reboot won't work\n");
389
388 if (np) 390 if (np)
389 of_node_put(np); 391 of_node_put(np);
390 return 0; 392 return 0;
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 69e2630c9062..cb7689c4bfbd 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -735,8 +735,10 @@ struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
735 ipic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR, 735 ipic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
736 NR_IPIC_INTS, 736 NR_IPIC_INTS,
737 &ipic_host_ops, 0); 737 &ipic_host_ops, 0);
738 if (ipic->irqhost == NULL) 738 if (ipic->irqhost == NULL) {
739 kfree(ipic);
739 return NULL; 740 return NULL;
741 }
740 742
741 ipic->regs = ioremap(res.start, res.end - res.start + 1); 743 ipic->regs = ioremap(res.start, res.end - res.start + 1);
742 744
@@ -781,6 +783,9 @@ struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
781 primary_ipic = ipic; 783 primary_ipic = ipic;
782 irq_set_default_host(primary_ipic->irqhost); 784 irq_set_default_host(primary_ipic->irqhost);
783 785
786 ipic_write(ipic->regs, IPIC_SIMSR_H, 0);
787 ipic_write(ipic->regs, IPIC_SIMSR_L, 0);
788
784 printk ("IPIC (%d IRQ sources) at %p\n", NR_IPIC_INTS, 789 printk ("IPIC (%d IRQ sources) at %p\n", NR_IPIC_INTS,
785 primary_ipic->regs); 790 primary_ipic->regs);
786 791
diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c
index 7b49633a4bd0..207324209065 100644
--- a/arch/powerpc/sysdev/mmio_nvram.c
+++ b/arch/powerpc/sysdev/mmio_nvram.c
@@ -53,6 +53,23 @@ static ssize_t mmio_nvram_read(char *buf, size_t count, loff_t *index)
53 return count; 53 return count;
54} 54}
55 55
56static unsigned char mmio_nvram_read_val(int addr)
57{
58 unsigned long flags;
59 unsigned char val;
60
61 if (addr >= mmio_nvram_len)
62 return 0xff;
63
64 spin_lock_irqsave(&mmio_nvram_lock, flags);
65
66 val = ioread8(mmio_nvram_start + addr);
67
68 spin_unlock_irqrestore(&mmio_nvram_lock, flags);
69
70 return val;
71}
72
56static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index) 73static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index)
57{ 74{
58 unsigned long flags; 75 unsigned long flags;
@@ -72,6 +89,19 @@ static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index)
72 return count; 89 return count;
73} 90}
74 91
92void mmio_nvram_write_val(int addr, unsigned char val)
93{
94 unsigned long flags;
95
96 if (addr < mmio_nvram_len) {
97 spin_lock_irqsave(&mmio_nvram_lock, flags);
98
99 iowrite8(val, mmio_nvram_start + addr);
100
101 spin_unlock_irqrestore(&mmio_nvram_lock, flags);
102 }
103}
104
75static ssize_t mmio_nvram_get_size(void) 105static ssize_t mmio_nvram_get_size(void)
76{ 106{
77 return mmio_nvram_len; 107 return mmio_nvram_len;
@@ -114,6 +144,8 @@ int __init mmio_nvram_init(void)
114 printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n", 144 printk(KERN_INFO "mmio NVRAM, %luk at 0x%lx mapped to %p\n",
115 mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start); 145 mmio_nvram_len >> 10, nvram_addr, mmio_nvram_start);
116 146
147 ppc_md.nvram_read_val = mmio_nvram_read_val;
148 ppc_md.nvram_write_val = mmio_nvram_write_val;
117 ppc_md.nvram_read = mmio_nvram_read; 149 ppc_md.nvram_read = mmio_nvram_read;
118 ppc_md.nvram_write = mmio_nvram_write; 150 ppc_md.nvram_write = mmio_nvram_write;
119 ppc_md.nvram_size = mmio_nvram_get_size; 151 ppc_md.nvram_size = mmio_nvram_get_size;
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 3981ae4cb58e..30c44e6b0413 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -230,14 +230,16 @@ static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigne
230{ 230{
231 unsigned int isu = src_no >> mpic->isu_shift; 231 unsigned int isu = src_no >> mpic->isu_shift;
232 unsigned int idx = src_no & mpic->isu_mask; 232 unsigned int idx = src_no & mpic->isu_mask;
233 unsigned int val;
233 234
235 val = _mpic_read(mpic->reg_type, &mpic->isus[isu],
236 reg + (idx * MPIC_INFO(IRQ_STRIDE)));
234#ifdef CONFIG_MPIC_BROKEN_REGREAD 237#ifdef CONFIG_MPIC_BROKEN_REGREAD
235 if (reg == 0) 238 if (reg == 0)
236 return mpic->isu_reg0_shadow[idx]; 239 val = (val & (MPIC_VECPRI_MASK | MPIC_VECPRI_ACTIVITY)) |
237 else 240 mpic->isu_reg0_shadow[src_no];
238#endif 241#endif
239 return _mpic_read(mpic->reg_type, &mpic->isus[isu], 242 return val;
240 reg + (idx * MPIC_INFO(IRQ_STRIDE)));
241} 243}
242 244
243static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no, 245static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
@@ -251,7 +253,8 @@ static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
251 253
252#ifdef CONFIG_MPIC_BROKEN_REGREAD 254#ifdef CONFIG_MPIC_BROKEN_REGREAD
253 if (reg == 0) 255 if (reg == 0)
254 mpic->isu_reg0_shadow[idx] = value; 256 mpic->isu_reg0_shadow[src_no] =
257 value & ~(MPIC_VECPRI_MASK | MPIC_VECPRI_ACTIVITY);
255#endif 258#endif
256} 259}
257 260
diff --git a/arch/powerpc/sysdev/qe_lib/gpio.c b/arch/powerpc/sysdev/qe_lib/gpio.c
index 3485288dce31..8e7a7767dd5c 100644
--- a/arch/powerpc/sysdev/qe_lib/gpio.c
+++ b/arch/powerpc/sysdev/qe_lib/gpio.c
@@ -105,14 +105,14 @@ static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
105 struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); 105 struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc);
106 unsigned long flags; 106 unsigned long flags;
107 107
108 qe_gpio_set(gc, gpio, val);
109
108 spin_lock_irqsave(&qe_gc->lock, flags); 110 spin_lock_irqsave(&qe_gc->lock, flags);
109 111
110 __par_io_config_pin(mm_gc->regs, gpio, QE_PIO_DIR_OUT, 0, 0, 0); 112 __par_io_config_pin(mm_gc->regs, gpio, QE_PIO_DIR_OUT, 0, 0, 0);
111 113
112 spin_unlock_irqrestore(&qe_gc->lock, flags); 114 spin_unlock_irqrestore(&qe_gc->lock, flags);
113 115
114 qe_gpio_set(gc, gpio, val);
115
116 return 0; 116 return 0;
117} 117}
118 118
diff --git a/arch/powerpc/sysdev/qe_lib/qe_ic.c b/arch/powerpc/sysdev/qe_lib/qe_ic.c
index 074905c3ee5a..3faa42e03a85 100644
--- a/arch/powerpc/sysdev/qe_lib/qe_ic.c
+++ b/arch/powerpc/sysdev/qe_lib/qe_ic.c
@@ -339,8 +339,10 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,
339 339
340 qe_ic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR, 340 qe_ic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
341 NR_QE_IC_INTS, &qe_ic_host_ops, 0); 341 NR_QE_IC_INTS, &qe_ic_host_ops, 0);
342 if (qe_ic->irqhost == NULL) 342 if (qe_ic->irqhost == NULL) {
343 kfree(qe_ic);
343 return; 344 return;
345 }
344 346
345 qe_ic->regs = ioremap(res.start, res.end - res.start + 1); 347 qe_ic->regs = ioremap(res.start, res.end - res.start + 1);
346 348
@@ -352,6 +354,7 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,
352 354
353 if (qe_ic->virq_low == NO_IRQ) { 355 if (qe_ic->virq_low == NO_IRQ) {
354 printk(KERN_ERR "Failed to map QE_IC low IRQ\n"); 356 printk(KERN_ERR "Failed to map QE_IC low IRQ\n");
357 kfree(qe_ic);
355 return; 358 return;
356 } 359 }
357 360
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index 85ab97ab840a..faa81b6a6612 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -2,6 +2,8 @@
2 2
3subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror 3subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
4 4
5GCOV_PROFILE := n
6
5ifdef CONFIG_PPC64 7ifdef CONFIG_PPC64
6EXTRA_CFLAGS += -mno-minimal-toc 8EXTRA_CFLAGS += -mno-minimal-toc
7endif 9endif
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index e1f33a81e5e1..0e09a45ac79a 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2570,7 +2570,7 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
2570 printf("%s", after); 2570 printf("%s", after);
2571} 2571}
2572 2572
2573#ifdef CONFIG_PPC64 2573#ifdef CONFIG_PPC_BOOK3S_64
2574static void dump_slb(void) 2574static void dump_slb(void)
2575{ 2575{
2576 int i; 2576 int i;
diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h
index 408d60b4f75b..f7ad8719d02d 100644
--- a/arch/s390/include/asm/percpu.h
+++ b/arch/s390/include/asm/percpu.h
@@ -1,37 +1,21 @@
1#ifndef __ARCH_S390_PERCPU__ 1#ifndef __ARCH_S390_PERCPU__
2#define __ARCH_S390_PERCPU__ 2#define __ARCH_S390_PERCPU__
3 3
4#include <linux/compiler.h>
5#include <asm/lowcore.h>
6
7/* 4/*
8 * s390 uses its own implementation for per cpu data, the offset of 5 * s390 uses its own implementation for per cpu data, the offset of
9 * the cpu local data area is cached in the cpu's lowcore memory. 6 * the cpu local data area is cached in the cpu's lowcore memory.
10 * For 64 bit module code s390 forces the use of a GOT slot for the
11 * address of the per cpu variable. This is needed because the module
12 * may be more than 4G above the per cpu area.
13 */ 7 */
14#if defined(__s390x__) && defined(MODULE) 8#define __my_cpu_offset S390_lowcore.percpu_offset
15
16#define SHIFT_PERCPU_PTR(ptr,offset) (({ \
17 extern int simple_identifier_##var(void); \
18 unsigned long *__ptr; \
19 asm ( "larl %0, %1@GOTENT" \
20 : "=a" (__ptr) : "X" (ptr) ); \
21 (typeof(ptr))((*__ptr) + (offset)); }))
22
23#else
24
25#define SHIFT_PERCPU_PTR(ptr, offset) (({ \
26 extern int simple_identifier_##var(void); \
27 unsigned long __ptr; \
28 asm ( "" : "=a" (__ptr) : "0" (ptr) ); \
29 (typeof(ptr)) (__ptr + (offset)); }))
30 9
10/*
11 * For 64 bit module code, the module may be more than 4G above the
12 * per cpu area, use weak definitions to force the compiler to
13 * generate external references.
14 */
15#if defined(CONFIG_SMP) && defined(__s390x__) && defined(MODULE)
16#define ARCH_NEEDS_WEAK_PER_CPU
31#endif 17#endif
32 18
33#define __my_cpu_offset S390_lowcore.percpu_offset
34
35#include <asm-generic/percpu.h> 19#include <asm-generic/percpu.h>
36 20
37#endif /* __ARCH_S390_PERCPU__ */ 21#endif /* __ARCH_S390_PERCPU__ */
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 7315f9e67e1d..bc15ef93e656 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -84,13 +84,10 @@ SECTIONS
84 84
85 _end = . ; 85 _end = . ;
86 86
87 /* Sections to be discarded */
88 /DISCARD/ : {
89 EXIT_DATA
90 *(.exitcall.exit)
91 }
92
93 /* Debugging sections. */ 87 /* Debugging sections. */
94 STABS_DEBUG 88 STABS_DEBUG
95 DWARF_DEBUG 89 DWARF_DEBUG
90
91 /* Sections to be discarded */
92 DISCARDS
96} 93}
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index d3633f513ebc..4163950cd1c6 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -10,7 +10,6 @@
10 or architectures with incomplete PCI setup by the loader */ 10 or architectures with incomplete PCI setup by the loader */
11 11
12#define pcibios_assign_all_busses() 1 12#define pcibios_assign_all_busses() 1
13#define pcibios_scan_all_fns(a, b) 0
14 13
15/* 14/*
16 * A board can define one or more PCI channels that represent built-in (or 15 * A board can define one or more PCI channels that represent built-in (or
diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
index f53c76acaede..0ce254bca92f 100644
--- a/arch/sh/kernel/vmlinux.lds.S
+++ b/arch/sh/kernel/vmlinux.lds.S
@@ -163,16 +163,14 @@ SECTIONS
163 _end = . ; 163 _end = . ;
164 } 164 }
165 165
166 STABS_DEBUG
167 DWARF_DEBUG
168
166 /* 169 /*
167 * When something in the kernel is NOT compiled as a module, the 170 * When something in the kernel is NOT compiled as a module, the
168 * module cleanup code and data are put into these segments. Both 171 * module cleanup code and data are put into these segments. Both
169 * can then be thrown away, as cleanup code is never called unless 172 * can then be thrown away, as cleanup code is never called unless
170 * it's a module. 173 * it's a module.
171 */ 174 */
172 /DISCARD/ : { 175 DISCARDS
173 *(.exitcall.exit)
174 }
175
176 STABS_DEBUG
177 DWARF_DEBUG
178} 176}
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 2bd5c287538a..86b82348b97c 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -99,7 +99,7 @@ config AUDIT_ARCH
99config HAVE_SETUP_PER_CPU_AREA 99config HAVE_SETUP_PER_CPU_AREA
100 def_bool y if SPARC64 100 def_bool y if SPARC64
101 101
102config HAVE_DYNAMIC_PER_CPU_AREA 102config NEED_PER_CPU_EMBED_FIRST_CHUNK
103 def_bool y if SPARC64 103 def_bool y if SPARC64
104 104
105config GENERIC_HARDIRQS_NO__DO_IRQ 105config GENERIC_HARDIRQS_NO__DO_IRQ
diff --git a/arch/sparc/include/asm/agp.h b/arch/sparc/include/asm/agp.h
index c2456870b05c..70f52c1661bc 100644
--- a/arch/sparc/include/asm/agp.h
+++ b/arch/sparc/include/asm/agp.h
@@ -7,10 +7,6 @@
7#define unmap_page_from_agp(page) 7#define unmap_page_from_agp(page)
8#define flush_agp_cache() mb() 8#define flush_agp_cache() mb()
9 9
10/* Convert a physical address to an address suitable for the GART. */
11#define phys_to_gart(x) (x)
12#define gart_to_phys(x) (x)
13
14/* GATT allocation. Returns/accepts GATT kernel virtual address. */ 10/* GATT allocation. Returns/accepts GATT kernel virtual address. */
15#define alloc_gatt_pages(order) \ 11#define alloc_gatt_pages(order) \
16 ((char *)__get_free_pages(GFP_KERNEL, (order))) 12 ((char *)__get_free_pages(GFP_KERNEL, (order)))
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h
index ac0e8369fd97..e769f668a4b5 100644
--- a/arch/sparc/include/asm/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -10,7 +10,6 @@
10 * or architectures with incomplete PCI setup by the loader. 10 * or architectures with incomplete PCI setup by the loader.
11 */ 11 */
12#define pcibios_assign_all_busses() 0 12#define pcibios_assign_all_busses() 0
13#define pcibios_scan_all_fns(a, b) 0
14 13
15#define PCIBIOS_MIN_IO 0UL 14#define PCIBIOS_MIN_IO 0UL
16#define PCIBIOS_MIN_MEM 0UL 15#define PCIBIOS_MIN_MEM 0UL
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index 5cc9f6aa5494..b63e51c3c3ee 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -10,7 +10,6 @@
10 * or architectures with incomplete PCI setup by the loader. 10 * or architectures with incomplete PCI setup by the loader.
11 */ 11 */
12#define pcibios_assign_all_busses() 0 12#define pcibios_assign_all_busses() 0
13#define pcibios_scan_all_fns(a, b) 0
14 13
15#define PCIBIOS_MIN_IO 0UL 14#define PCIBIOS_MIN_IO 0UL
16#define PCIBIOS_MIN_MEM 0UL 15#define PCIBIOS_MIN_MEM 0UL
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 3691907a43b4..ff68373ce6d6 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1389,8 +1389,8 @@ void smp_send_stop(void)
1389 * RETURNS: 1389 * RETURNS:
1390 * Pointer to the allocated area on success, NULL on failure. 1390 * Pointer to the allocated area on success, NULL on failure.
1391 */ 1391 */
1392static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size, 1392static void * __init pcpu_alloc_bootmem(unsigned int cpu, size_t size,
1393 unsigned long align) 1393 size_t align)
1394{ 1394{
1395 const unsigned long goal = __pa(MAX_DMA_ADDRESS); 1395 const unsigned long goal = __pa(MAX_DMA_ADDRESS);
1396#ifdef CONFIG_NEED_MULTIPLE_NODES 1396#ifdef CONFIG_NEED_MULTIPLE_NODES
@@ -1415,127 +1415,35 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size,
1415#endif 1415#endif
1416} 1416}
1417 1417
1418static size_t pcpur_size __initdata; 1418static void __init pcpu_free_bootmem(void *ptr, size_t size)
1419static void **pcpur_ptrs __initdata;
1420
1421static struct page * __init pcpur_get_page(unsigned int cpu, int pageno)
1422{ 1419{
1423 size_t off = (size_t)pageno << PAGE_SHIFT; 1420 free_bootmem(__pa(ptr), size);
1424
1425 if (off >= pcpur_size)
1426 return NULL;
1427
1428 return virt_to_page(pcpur_ptrs[cpu] + off);
1429} 1421}
1430 1422
1431#define PCPU_CHUNK_SIZE (4UL * 1024UL * 1024UL) 1423static int pcpu_cpu_distance(unsigned int from, unsigned int to)
1432
1433static void __init pcpu_map_range(unsigned long start, unsigned long end,
1434 struct page *page)
1435{ 1424{
1436 unsigned long pfn = page_to_pfn(page); 1425 if (cpu_to_node(from) == cpu_to_node(to))
1437 unsigned long pte_base; 1426 return LOCAL_DISTANCE;
1438 1427 else
1439 BUG_ON((pfn<<PAGE_SHIFT)&(PCPU_CHUNK_SIZE - 1UL)); 1428 return REMOTE_DISTANCE;
1440
1441 pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4U |
1442 _PAGE_CP_4U | _PAGE_CV_4U |
1443 _PAGE_P_4U | _PAGE_W_4U);
1444 if (tlb_type == hypervisor)
1445 pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4V |
1446 _PAGE_CP_4V | _PAGE_CV_4V |
1447 _PAGE_P_4V | _PAGE_W_4V);
1448
1449 while (start < end) {
1450 pgd_t *pgd = pgd_offset_k(start);
1451 unsigned long this_end;
1452 pud_t *pud;
1453 pmd_t *pmd;
1454 pte_t *pte;
1455
1456 pud = pud_offset(pgd, start);
1457 if (pud_none(*pud)) {
1458 pmd_t *new;
1459
1460 new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
1461 pud_populate(&init_mm, pud, new);
1462 }
1463
1464 pmd = pmd_offset(pud, start);
1465 if (!pmd_present(*pmd)) {
1466 pte_t *new;
1467
1468 new = __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
1469 pmd_populate_kernel(&init_mm, pmd, new);
1470 }
1471
1472 pte = pte_offset_kernel(pmd, start);
1473 this_end = (start + PMD_SIZE) & PMD_MASK;
1474 if (this_end > end)
1475 this_end = end;
1476
1477 while (start < this_end) {
1478 unsigned long paddr = pfn << PAGE_SHIFT;
1479
1480 pte_val(*pte) = (paddr | pte_base);
1481
1482 start += PAGE_SIZE;
1483 pte++;
1484 pfn++;
1485 }
1486 }
1487} 1429}
1488 1430
1489void __init setup_per_cpu_areas(void) 1431void __init setup_per_cpu_areas(void)
1490{ 1432{
1491 size_t dyn_size, static_size = __per_cpu_end - __per_cpu_start; 1433 unsigned long delta;
1492 static struct vm_struct vm; 1434 unsigned int cpu;
1493 unsigned long delta, cpu; 1435 int rc;
1494 size_t pcpu_unit_size;
1495 size_t ptrs_size;
1496
1497 pcpur_size = PFN_ALIGN(static_size + PERCPU_MODULE_RESERVE +
1498 PERCPU_DYNAMIC_RESERVE);
1499 dyn_size = pcpur_size - static_size - PERCPU_MODULE_RESERVE;
1500
1501 1436
1502 ptrs_size = PFN_ALIGN(nr_cpu_ids * sizeof(pcpur_ptrs[0])); 1437 rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
1503 pcpur_ptrs = alloc_bootmem(ptrs_size); 1438 PERCPU_DYNAMIC_RESERVE, 4 << 20,
1504 1439 pcpu_cpu_distance, pcpu_alloc_bootmem,
1505 for_each_possible_cpu(cpu) { 1440 pcpu_free_bootmem);
1506 pcpur_ptrs[cpu] = pcpu_alloc_bootmem(cpu, PCPU_CHUNK_SIZE, 1441 if (rc)
1507 PCPU_CHUNK_SIZE); 1442 panic("failed to initialize first chunk (%d)", rc);
1508
1509 free_bootmem(__pa(pcpur_ptrs[cpu] + pcpur_size),
1510 PCPU_CHUNK_SIZE - pcpur_size);
1511
1512 memcpy(pcpur_ptrs[cpu], __per_cpu_load, static_size);
1513 }
1514
1515 /* allocate address and map */
1516 vm.flags = VM_ALLOC;
1517 vm.size = nr_cpu_ids * PCPU_CHUNK_SIZE;
1518 vm_area_register_early(&vm, PCPU_CHUNK_SIZE);
1519
1520 for_each_possible_cpu(cpu) {
1521 unsigned long start = (unsigned long) vm.addr;
1522 unsigned long end;
1523
1524 start += cpu * PCPU_CHUNK_SIZE;
1525 end = start + PCPU_CHUNK_SIZE;
1526 pcpu_map_range(start, end, virt_to_page(pcpur_ptrs[cpu]));
1527 }
1528
1529 pcpu_unit_size = pcpu_setup_first_chunk(pcpur_get_page, static_size,
1530 PERCPU_MODULE_RESERVE, dyn_size,
1531 PCPU_CHUNK_SIZE, vm.addr, NULL);
1532
1533 free_bootmem(__pa(pcpur_ptrs), ptrs_size);
1534 1443
1535 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start; 1444 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
1536 for_each_possible_cpu(cpu) { 1445 for_each_possible_cpu(cpu)
1537 __per_cpu_offset(cpu) = delta + cpu * pcpu_unit_size; 1446 __per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
1538 }
1539 1447
1540 /* Setup %g5 for the boot cpu. */ 1448 /* Setup %g5 for the boot cpu. */
1541 __local_per_cpu_offset = __per_cpu_offset(smp_processor_id()); 1449 __local_per_cpu_offset = __per_cpu_offset(smp_processor_id());
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index fcbbd000ec08..866390feb683 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -171,12 +171,8 @@ SECTIONS
171 } 171 }
172 _end = . ; 172 _end = . ;
173 173
174 /DISCARD/ : {
175 EXIT_TEXT
176 EXIT_DATA
177 *(.exitcall.exit)
178 }
179
180 STABS_DEBUG 174 STABS_DEBUG
181 DWARF_DEBUG 175 DWARF_DEBUG
176
177 DISCARDS
182} 178}
diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
index cb0248616d49..37ecc5577a9a 100644
--- a/arch/um/include/asm/common.lds.S
+++ b/arch/um/include/asm/common.lds.S
@@ -123,8 +123,3 @@
123 __initramfs_end = .; 123 __initramfs_end = .;
124 } 124 }
125 125
126 /* Sections to be discarded */
127 /DISCARD/ : {
128 *(.exitcall.exit)
129 }
130
diff --git a/arch/um/include/asm/pci.h b/arch/um/include/asm/pci.h
index 59923199cdc3..b44cf59ede1e 100644
--- a/arch/um/include/asm/pci.h
+++ b/arch/um/include/asm/pci.h
@@ -2,6 +2,5 @@
2#define __UM_PCI_H 2#define __UM_PCI_H
3 3
4#define PCI_DMA_BUS_IS_PHYS (1) 4#define PCI_DMA_BUS_IS_PHYS (1)
5#define pcibios_scan_all_fns(a, b) 0
6 5
7#endif 6#endif
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 9975e1ab44fb..715a188c0472 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -156,4 +156,6 @@ SECTIONS
156 STABS_DEBUG 156 STABS_DEBUG
157 157
158 DWARF_DEBUG 158 DWARF_DEBUG
159
160 DISCARDS
159} 161}
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 11b835248b86..2ebd39765db8 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -100,4 +100,6 @@ SECTIONS
100 STABS_DEBUG 100 STABS_DEBUG
101 101
102 DWARF_DEBUG 102 DWARF_DEBUG
103
104 DISCARDS
103} 105}
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index fc20fdc0f7f2..e98e81a04971 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -150,7 +150,10 @@ config ARCH_HAS_CACHE_LINE_SIZE
150config HAVE_SETUP_PER_CPU_AREA 150config HAVE_SETUP_PER_CPU_AREA
151 def_bool y 151 def_bool y
152 152
153config HAVE_DYNAMIC_PER_CPU_AREA 153config NEED_PER_CPU_EMBED_FIRST_CHUNK
154 def_bool y
155
156config NEED_PER_CPU_PAGE_FIRST_CHUNK
154 def_bool y 157 def_bool y
155 158
156config HAVE_CPUMASK_OF_CPU_MAP 159config HAVE_CPUMASK_OF_CPU_MAP
@@ -179,6 +182,10 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING
179config ARCH_SUPPORTS_DEBUG_PAGEALLOC 182config ARCH_SUPPORTS_DEBUG_PAGEALLOC
180 def_bool y 183 def_bool y
181 184
185config HAVE_INTEL_TXT
186 def_bool y
187 depends on EXPERIMENTAL && DMAR && ACPI
188
182# Use the generic interrupt handling code in kernel/irq/: 189# Use the generic interrupt handling code in kernel/irq/:
183config GENERIC_HARDIRQS 190config GENERIC_HARDIRQS
184 bool 191 bool
@@ -1413,6 +1420,10 @@ config X86_PAT
1413 1420
1414 If unsure, say Y. 1421 If unsure, say Y.
1415 1422
1423config ARCH_USES_PG_UNCACHED
1424 def_bool y
1425 depends on X86_PAT
1426
1416config EFI 1427config EFI
1417 bool "EFI runtime service support" 1428 bool "EFI runtime service support"
1418 depends on ACPI 1429 depends on ACPI
diff --git a/arch/x86/include/asm/agp.h b/arch/x86/include/asm/agp.h
index 9825cd64c9b6..eec2a70d4376 100644
--- a/arch/x86/include/asm/agp.h
+++ b/arch/x86/include/asm/agp.h
@@ -22,10 +22,6 @@
22 */ 22 */
23#define flush_agp_cache() wbinvd() 23#define flush_agp_cache() wbinvd()
24 24
25/* Convert a physical address to an address suitable for the GART. */
26#define phys_to_gart(x) (x)
27#define gart_to_phys(x) (x)
28
29/* GATT allocation. Returns/accepts GATT kernel virtual address. */ 25/* GATT allocation. Returns/accepts GATT kernel virtual address. */
30#define alloc_gatt_pages(order) \ 26#define alloc_gatt_pages(order) \
31 ((char *)__get_free_pages(GFP_KERNEL, (order))) 27 ((char *)__get_free_pages(GFP_KERNEL, (order)))
diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h
index 1724e8de317c..6ca20218dd72 100644
--- a/arch/x86/include/asm/bootparam.h
+++ b/arch/x86/include/asm/bootparam.h
@@ -85,7 +85,8 @@ struct efi_info {
85struct boot_params { 85struct boot_params {
86 struct screen_info screen_info; /* 0x000 */ 86 struct screen_info screen_info; /* 0x000 */
87 struct apm_bios_info apm_bios_info; /* 0x040 */ 87 struct apm_bios_info apm_bios_info; /* 0x040 */
88 __u8 _pad2[12]; /* 0x054 */ 88 __u8 _pad2[4]; /* 0x054 */
89 __u64 tboot_addr; /* 0x058 */
89 struct ist_info ist_info; /* 0x060 */ 90 struct ist_info ist_info; /* 0x060 */
90 __u8 _pad3[16]; /* 0x070 */ 91 __u8 _pad3[16]; /* 0x070 */
91 __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ 92 __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index e55dfc1ad453..b54f6afe7ec4 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -43,8 +43,58 @@ static inline void copy_from_user_page(struct vm_area_struct *vma,
43 memcpy(dst, src, len); 43 memcpy(dst, src, len);
44} 44}
45 45
46#define PG_non_WB PG_arch_1 46#define PG_WC PG_arch_1
47PAGEFLAG(NonWB, non_WB) 47PAGEFLAG(WC, WC)
48
49#ifdef CONFIG_X86_PAT
50/*
51 * X86 PAT uses page flags WC and Uncached together to keep track of
52 * memory type of pages that have backing page struct. X86 PAT supports 3
53 * different memory types, _PAGE_CACHE_WB, _PAGE_CACHE_WC and
54 * _PAGE_CACHE_UC_MINUS and fourth state where page's memory type has not
55 * been changed from its default (value of -1 used to denote this).
56 * Note we do not support _PAGE_CACHE_UC here.
57 *
58 * Caller must hold memtype_lock for atomicity.
59 */
60static inline unsigned long get_page_memtype(struct page *pg)
61{
62 if (!PageUncached(pg) && !PageWC(pg))
63 return -1;
64 else if (!PageUncached(pg) && PageWC(pg))
65 return _PAGE_CACHE_WC;
66 else if (PageUncached(pg) && !PageWC(pg))
67 return _PAGE_CACHE_UC_MINUS;
68 else
69 return _PAGE_CACHE_WB;
70}
71
72static inline void set_page_memtype(struct page *pg, unsigned long memtype)
73{
74 switch (memtype) {
75 case _PAGE_CACHE_WC:
76 ClearPageUncached(pg);
77 SetPageWC(pg);
78 break;
79 case _PAGE_CACHE_UC_MINUS:
80 SetPageUncached(pg);
81 ClearPageWC(pg);
82 break;
83 case _PAGE_CACHE_WB:
84 SetPageUncached(pg);
85 SetPageWC(pg);
86 break;
87 default:
88 case -1:
89 ClearPageUncached(pg);
90 ClearPageWC(pg);
91 break;
92 }
93}
94#else
95static inline unsigned long get_page_memtype(struct page *pg) { return -1; }
96static inline void set_page_memtype(struct page *pg, unsigned long memtype) { }
97#endif
48 98
49/* 99/*
50 * The set_memory_* API can be used to change various attributes of a virtual 100 * The set_memory_* API can be used to change various attributes of a virtual
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 7b2d71df39a6..14f9890eb495 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -132,6 +132,9 @@ enum fixed_addresses {
132#ifdef CONFIG_X86_32 132#ifdef CONFIG_X86_32
133 FIX_WP_TEST, 133 FIX_WP_TEST,
134#endif 134#endif
135#ifdef CONFIG_INTEL_TXT
136 FIX_TBOOT_BASE,
137#endif
135 __end_of_fixed_addresses 138 __end_of_fixed_addresses
136}; 139};
137 140
diff --git a/arch/x86/include/asm/iomap.h b/arch/x86/include/asm/iomap.h
index 0e9fe1d9d971..f35eb45d6576 100644
--- a/arch/x86/include/asm/iomap.h
+++ b/arch/x86/include/asm/iomap.h
@@ -26,13 +26,16 @@
26#include <asm/pgtable.h> 26#include <asm/pgtable.h>
27#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
28 28
29int
30is_io_mapping_possible(resource_size_t base, unsigned long size);
31
32void * 29void *
33iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); 30iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot);
34 31
35void 32void
36iounmap_atomic(void *kvaddr, enum km_type type); 33iounmap_atomic(void *kvaddr, enum km_type type);
37 34
35int
36iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot);
37
38void
39iomap_free(resource_size_t base, unsigned long size);
40
38#endif /* _ASM_X86_IOMAP_H */ 41#endif /* _ASM_X86_IOMAP_H */
diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h
index a51ada8467de..4365ffdb461f 100644
--- a/arch/x86/include/asm/mtrr.h
+++ b/arch/x86/include/asm/mtrr.h
@@ -121,6 +121,9 @@ extern int mtrr_del_page(int reg, unsigned long base, unsigned long size);
121extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); 121extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
122extern void mtrr_ap_init(void); 122extern void mtrr_ap_init(void);
123extern void mtrr_bp_init(void); 123extern void mtrr_bp_init(void);
124extern void set_mtrr_aps_delayed_init(void);
125extern void mtrr_aps_init(void);
126extern void mtrr_bp_restore(void);
124extern int mtrr_trim_uncached_memory(unsigned long end_pfn); 127extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
125extern int amd_special_default_mtrr(void); 128extern int amd_special_default_mtrr(void);
126# else 129# else
@@ -161,6 +164,9 @@ static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
161 164
162#define mtrr_ap_init() do {} while (0) 165#define mtrr_ap_init() do {} while (0)
163#define mtrr_bp_init() do {} while (0) 166#define mtrr_bp_init() do {} while (0)
167#define set_mtrr_aps_delayed_init() do {} while (0)
168#define mtrr_aps_init() do {} while (0)
169#define mtrr_bp_restore() do {} while (0)
164# endif 170# endif
165 171
166#ifdef CONFIG_COMPAT 172#ifdef CONFIG_COMPAT
diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h
index 7af14e512f97..e2c1668dde7a 100644
--- a/arch/x86/include/asm/pat.h
+++ b/arch/x86/include/asm/pat.h
@@ -19,4 +19,9 @@ extern int free_memtype(u64 start, u64 end);
19extern int kernel_map_sync_memtype(u64 base, unsigned long size, 19extern int kernel_map_sync_memtype(u64 base, unsigned long size,
20 unsigned long flag); 20 unsigned long flag);
21 21
22int io_reserve_memtype(resource_size_t start, resource_size_t end,
23 unsigned long *type);
24
25void io_free_memtype(resource_size_t start, resource_size_t end);
26
22#endif /* _ASM_X86_PAT_H */ 27#endif /* _ASM_X86_PAT_H */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 1ff685ca221c..f76a162c082c 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -48,7 +48,6 @@ extern unsigned int pcibios_assign_all_busses(void);
48#else 48#else
49#define pcibios_assign_all_busses() 0 49#define pcibios_assign_all_busses() 0
50#endif 50#endif
51#define pcibios_scan_all_fns(a, b) 0
52 51
53extern unsigned long pci_mem_start; 52extern unsigned long pci_mem_start;
54#define PCIBIOS_MIN_IO 0x1000 53#define PCIBIOS_MIN_IO 0x1000
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 04eacefcfd26..b65a36defeb7 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -168,15 +168,6 @@ do { \
168/* We can use this directly for local CPU (faster). */ 168/* We can use this directly for local CPU (faster). */
169DECLARE_PER_CPU(unsigned long, this_cpu_off); 169DECLARE_PER_CPU(unsigned long, this_cpu_off);
170 170
171#ifdef CONFIG_NEED_MULTIPLE_NODES
172void *pcpu_lpage_remapped(void *kaddr);
173#else
174static inline void *pcpu_lpage_remapped(void *kaddr)
175{
176 return NULL;
177}
178#endif
179
180#endif /* !__ASSEMBLY__ */ 171#endif /* !__ASSEMBLY__ */
181 172
182#ifdef CONFIG_SMP 173#ifdef CONFIG_SMP
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 430d5b24af7b..832cb838cb48 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_X86_DS_SELFTEST) += ds_selftest.o
52obj-$(CONFIG_X86_32) += tls.o 52obj-$(CONFIG_X86_32) += tls.o
53obj-$(CONFIG_IA32_EMULATION) += tls.o 53obj-$(CONFIG_IA32_EMULATION) += tls.o
54obj-y += step.o 54obj-y += step.o
55obj-$(CONFIG_INTEL_TXT) += tboot.o
55obj-$(CONFIG_STACKTRACE) += stacktrace.o 56obj-$(CONFIG_STACKTRACE) += stacktrace.o
56obj-y += cpu/ 57obj-y += cpu/
57obj-y += acpi/ 58obj-y += acpi/
diff --git a/arch/x86/kernel/cpu/cpu_debug.c b/arch/x86/kernel/cpu/cpu_debug.c
index 6b2a52dd0403..dca325c03999 100644
--- a/arch/x86/kernel/cpu/cpu_debug.c
+++ b/arch/x86/kernel/cpu/cpu_debug.c
@@ -30,8 +30,8 @@
30#include <asm/apic.h> 30#include <asm/apic.h>
31#include <asm/desc.h> 31#include <asm/desc.h>
32 32
33static DEFINE_PER_CPU(struct cpu_cpuX_base, cpu_arr[CPU_REG_ALL_BIT]); 33static DEFINE_PER_CPU(struct cpu_cpuX_base [CPU_REG_ALL_BIT], cpu_arr);
34static DEFINE_PER_CPU(struct cpu_private *, priv_arr[MAX_CPU_FILES]); 34static DEFINE_PER_CPU(struct cpu_private * [MAX_CPU_FILES], priv_arr);
35static DEFINE_PER_CPU(int, cpu_priv_count); 35static DEFINE_PER_CPU(int, cpu_priv_count);
36 36
37static DEFINE_MUTEX(cpu_debug_lock); 37static DEFINE_MUTEX(cpu_debug_lock);
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 9bfe9d2ea615..fdd51b554355 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1101,7 +1101,7 @@ void mce_log_therm_throt_event(__u64 status)
1101 */ 1101 */
1102static int check_interval = 5 * 60; /* 5 minutes */ 1102static int check_interval = 5 * 60; /* 5 minutes */
1103 1103
1104static DEFINE_PER_CPU(int, next_interval); /* in jiffies */ 1104static DEFINE_PER_CPU(int, mce_next_interval); /* in jiffies */
1105static DEFINE_PER_CPU(struct timer_list, mce_timer); 1105static DEFINE_PER_CPU(struct timer_list, mce_timer);
1106 1106
1107static void mcheck_timer(unsigned long data) 1107static void mcheck_timer(unsigned long data)
@@ -1120,7 +1120,7 @@ static void mcheck_timer(unsigned long data)
1120 * Alert userspace if needed. If we logged an MCE, reduce the 1120 * Alert userspace if needed. If we logged an MCE, reduce the
1121 * polling interval, otherwise increase the polling interval. 1121 * polling interval, otherwise increase the polling interval.
1122 */ 1122 */
1123 n = &__get_cpu_var(next_interval); 1123 n = &__get_cpu_var(mce_next_interval);
1124 if (mce_notify_irq()) 1124 if (mce_notify_irq())
1125 *n = max(*n/2, HZ/100); 1125 *n = max(*n/2, HZ/100);
1126 else 1126 else
@@ -1335,7 +1335,7 @@ static void mce_cpu_features(struct cpuinfo_x86 *c)
1335static void mce_init_timer(void) 1335static void mce_init_timer(void)
1336{ 1336{
1337 struct timer_list *t = &__get_cpu_var(mce_timer); 1337 struct timer_list *t = &__get_cpu_var(mce_timer);
1338 int *n = &__get_cpu_var(next_interval); 1338 int *n = &__get_cpu_var(mce_next_interval);
1339 1339
1340 if (mce_ignore_ce) 1340 if (mce_ignore_ce)
1341 return; 1341 return;
@@ -1935,7 +1935,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
1935 case CPU_DOWN_FAILED: 1935 case CPU_DOWN_FAILED:
1936 case CPU_DOWN_FAILED_FROZEN: 1936 case CPU_DOWN_FAILED_FROZEN:
1937 t->expires = round_jiffies(jiffies + 1937 t->expires = round_jiffies(jiffies +
1938 __get_cpu_var(next_interval)); 1938 __get_cpu_var(mce_next_interval));
1939 add_timer_on(t, cpu); 1939 add_timer_on(t, cpu);
1940 smp_call_function_single(cpu, mce_reenable_cpu, &action, 1); 1940 smp_call_function_single(cpu, mce_reenable_cpu, &action, 1);
1941 break; 1941 break;
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 1fecba404fd8..8cd5224943b5 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -69,7 +69,7 @@ struct threshold_bank {
69 struct threshold_block *blocks; 69 struct threshold_block *blocks;
70 cpumask_var_t cpus; 70 cpumask_var_t cpus;
71}; 71};
72static DEFINE_PER_CPU(struct threshold_bank *, threshold_banks[NR_BANKS]); 72static DEFINE_PER_CPU(struct threshold_bank * [NR_BANKS], threshold_banks);
73 73
74#ifdef CONFIG_SMP 74#ifdef CONFIG_SMP
75static unsigned char shared_bank[NR_BANKS] = { 75static unsigned char shared_bank[NR_BANKS] = {
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 7af0f88a4163..84e83de54575 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -58,6 +58,7 @@ unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES];
58static DEFINE_MUTEX(mtrr_mutex); 58static DEFINE_MUTEX(mtrr_mutex);
59 59
60u64 size_or_mask, size_and_mask; 60u64 size_or_mask, size_and_mask;
61static bool mtrr_aps_delayed_init;
61 62
62static struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM]; 63static struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
63 64
@@ -163,7 +164,10 @@ static void ipi_handler(void *info)
163 if (data->smp_reg != ~0U) { 164 if (data->smp_reg != ~0U) {
164 mtrr_if->set(data->smp_reg, data->smp_base, 165 mtrr_if->set(data->smp_reg, data->smp_base,
165 data->smp_size, data->smp_type); 166 data->smp_size, data->smp_type);
166 } else { 167 } else if (mtrr_aps_delayed_init) {
168 /*
169 * Initialize the MTRRs inaddition to the synchronisation.
170 */
167 mtrr_if->set_all(); 171 mtrr_if->set_all();
168 } 172 }
169 173
@@ -265,6 +269,8 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ
265 */ 269 */
266 if (reg != ~0U) 270 if (reg != ~0U)
267 mtrr_if->set(reg, base, size, type); 271 mtrr_if->set(reg, base, size, type);
272 else if (!mtrr_aps_delayed_init)
273 mtrr_if->set_all();
268 274
269 /* Wait for the others */ 275 /* Wait for the others */
270 while (atomic_read(&data.count)) 276 while (atomic_read(&data.count))
@@ -721,9 +727,7 @@ void __init mtrr_bp_init(void)
721 727
722void mtrr_ap_init(void) 728void mtrr_ap_init(void)
723{ 729{
724 unsigned long flags; 730 if (!use_intel() || mtrr_aps_delayed_init)
725
726 if (!mtrr_if || !use_intel())
727 return; 731 return;
728 /* 732 /*
729 * Ideally we should hold mtrr_mutex here to avoid mtrr entries 733 * Ideally we should hold mtrr_mutex here to avoid mtrr entries
@@ -738,11 +742,7 @@ void mtrr_ap_init(void)
738 * 2. cpu hotadd time. We let mtrr_add/del_page hold cpuhotplug 742 * 2. cpu hotadd time. We let mtrr_add/del_page hold cpuhotplug
739 * lock to prevent mtrr entry changes 743 * lock to prevent mtrr entry changes
740 */ 744 */
741 local_irq_save(flags); 745 set_mtrr(~0U, 0, 0, 0);
742
743 mtrr_if->set_all();
744
745 local_irq_restore(flags);
746} 746}
747 747
748/** 748/**
@@ -753,6 +753,34 @@ void mtrr_save_state(void)
753 smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1); 753 smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1);
754} 754}
755 755
756void set_mtrr_aps_delayed_init(void)
757{
758 if (!use_intel())
759 return;
760
761 mtrr_aps_delayed_init = true;
762}
763
764/*
765 * MTRR initialization for all AP's
766 */
767void mtrr_aps_init(void)
768{
769 if (!use_intel())
770 return;
771
772 set_mtrr(~0U, 0, 0, 0);
773 mtrr_aps_delayed_init = false;
774}
775
776void mtrr_bp_restore(void)
777{
778 if (!use_intel())
779 return;
780
781 mtrr_if->set_all();
782}
783
756static int __init mtrr_init_finialize(void) 784static int __init mtrr_init_finialize(void)
757{ 785{
758 if (!mtrr_if) 786 if (!mtrr_if)
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index f9cd0849bd42..2732e2c1e4d3 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -1211,7 +1211,7 @@ amd_pmu_disable_counter(struct hw_perf_counter *hwc, int idx)
1211 x86_pmu_disable_counter(hwc, idx); 1211 x86_pmu_disable_counter(hwc, idx);
1212} 1212}
1213 1213
1214static DEFINE_PER_CPU(u64, prev_left[X86_PMC_IDX_MAX]); 1214static DEFINE_PER_CPU(u64 [X86_PMC_IDX_MAX], pmc_prev_left);
1215 1215
1216/* 1216/*
1217 * Set the next IRQ period, based on the hwc->period_left value. 1217 * Set the next IRQ period, based on the hwc->period_left value.
@@ -1253,7 +1253,7 @@ x86_perf_counter_set_period(struct perf_counter *counter,
1253 if (left > x86_pmu.max_period) 1253 if (left > x86_pmu.max_period)
1254 left = x86_pmu.max_period; 1254 left = x86_pmu.max_period;
1255 1255
1256 per_cpu(prev_left[idx], smp_processor_id()) = left; 1256 per_cpu(pmc_prev_left[idx], smp_processor_id()) = left;
1257 1257
1258 /* 1258 /*
1259 * The hw counter starts counting from this counter offset, 1259 * The hw counter starts counting from this counter offset,
@@ -1470,7 +1470,7 @@ void perf_counter_print_debug(void)
1470 rdmsrl(x86_pmu.eventsel + idx, pmc_ctrl); 1470 rdmsrl(x86_pmu.eventsel + idx, pmc_ctrl);
1471 rdmsrl(x86_pmu.perfctr + idx, pmc_count); 1471 rdmsrl(x86_pmu.perfctr + idx, pmc_count);
1472 1472
1473 prev_left = per_cpu(prev_left[idx], cpu); 1473 prev_left = per_cpu(pmc_prev_left[idx], cpu);
1474 1474
1475 pr_info("CPU#%d: gen-PMC%d ctrl: %016llx\n", 1475 pr_info("CPU#%d: gen-PMC%d ctrl: %016llx\n",
1476 cpu, idx, pmc_ctrl); 1476 cpu, idx, pmc_ctrl);
@@ -2110,8 +2110,8 @@ void callchain_store(struct perf_callchain_entry *entry, u64 ip)
2110 entry->ip[entry->nr++] = ip; 2110 entry->ip[entry->nr++] = ip;
2111} 2111}
2112 2112
2113static DEFINE_PER_CPU(struct perf_callchain_entry, irq_entry); 2113static DEFINE_PER_CPU(struct perf_callchain_entry, pmc_irq_entry);
2114static DEFINE_PER_CPU(struct perf_callchain_entry, nmi_entry); 2114static DEFINE_PER_CPU(struct perf_callchain_entry, pmc_nmi_entry);
2115static DEFINE_PER_CPU(int, in_nmi_frame); 2115static DEFINE_PER_CPU(int, in_nmi_frame);
2116 2116
2117 2117
@@ -2264,9 +2264,9 @@ struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
2264 struct perf_callchain_entry *entry; 2264 struct perf_callchain_entry *entry;
2265 2265
2266 if (in_nmi()) 2266 if (in_nmi())
2267 entry = &__get_cpu_var(nmi_entry); 2267 entry = &__get_cpu_var(pmc_nmi_entry);
2268 else 2268 else
2269 entry = &__get_cpu_var(irq_entry); 2269 entry = &__get_cpu_var(pmc_irq_entry);
2270 2270
2271 entry->nr = 0; 2271 entry->nr = 0;
2272 2272
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index d71c8655905b..64b838eac18c 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -225,10 +225,8 @@ static __init int iommu_setup(char *p)
225 if (!strncmp(p, "soft", 4)) 225 if (!strncmp(p, "soft", 4))
226 swiotlb = 1; 226 swiotlb = 1;
227#endif 227#endif
228 if (!strncmp(p, "pt", 2)) { 228 if (!strncmp(p, "pt", 2))
229 iommu_pass_through = 1; 229 iommu_pass_through = 1;
230 return 1;
231 }
232 230
233 gart_parse_options(p); 231 gart_parse_options(p);
234 232
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index af71d06624bf..6c3b2c6fd772 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -508,7 +508,7 @@ static void __init quirk_amd_nb_node(struct pci_dev *dev)
508 508
509 pci_read_config_dword(nb_ht, 0x60, &val); 509 pci_read_config_dword(nb_ht, 0x60, &val);
510 set_dev_node(&dev->dev, val & 7); 510 set_dev_node(&dev->dev, val & 7);
511 pci_dev_put(dev); 511 pci_dev_put(nb_ht);
512} 512}
513 513
514DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB, 514DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB,
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index a06e8d101844..27349f92a6d7 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -4,6 +4,7 @@
4#include <linux/pm.h> 4#include <linux/pm.h>
5#include <linux/efi.h> 5#include <linux/efi.h>
6#include <linux/dmi.h> 6#include <linux/dmi.h>
7#include <linux/tboot.h>
7#include <acpi/reboot.h> 8#include <acpi/reboot.h>
8#include <asm/io.h> 9#include <asm/io.h>
9#include <asm/apic.h> 10#include <asm/apic.h>
@@ -508,6 +509,8 @@ static void native_machine_emergency_restart(void)
508 if (reboot_emergency) 509 if (reboot_emergency)
509 emergency_vmx_disable_all(); 510 emergency_vmx_disable_all();
510 511
512 tboot_shutdown(TB_SHUTDOWN_REBOOT);
513
511 /* Tell the BIOS if we want cold or warm reboot */ 514 /* Tell the BIOS if we want cold or warm reboot */
512 *((unsigned short *)__va(0x472)) = reboot_mode; 515 *((unsigned short *)__va(0x472)) = reboot_mode;
513 516
@@ -634,6 +637,8 @@ static void native_machine_halt(void)
634 /* stop other cpus and apics */ 637 /* stop other cpus and apics */
635 machine_shutdown(); 638 machine_shutdown();
636 639
640 tboot_shutdown(TB_SHUTDOWN_HALT);
641
637 /* stop this cpu */ 642 /* stop this cpu */
638 stop_this_cpu(NULL); 643 stop_this_cpu(NULL);
639} 644}
@@ -645,6 +650,8 @@ static void native_machine_power_off(void)
645 machine_shutdown(); 650 machine_shutdown();
646 pm_power_off(); 651 pm_power_off();
647 } 652 }
653 /* a fallback in case there is no PM info available */
654 tboot_shutdown(TB_SHUTDOWN_HALT);
648} 655}
649 656
650struct machine_ops machine_ops = { 657struct machine_ops machine_ops = {
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 63f32d220ef2..19f15c4076fb 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -66,6 +66,7 @@
66 66
67#include <linux/percpu.h> 67#include <linux/percpu.h>
68#include <linux/crash_dump.h> 68#include <linux/crash_dump.h>
69#include <linux/tboot.h>
69 70
70#include <video/edid.h> 71#include <video/edid.h>
71 72
@@ -711,6 +712,21 @@ void __init setup_arch(char **cmdline_p)
711 printk(KERN_INFO "Command line: %s\n", boot_command_line); 712 printk(KERN_INFO "Command line: %s\n", boot_command_line);
712#endif 713#endif
713 714
715 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
716 *cmdline_p = command_line;
717
718#ifdef CONFIG_X86_64
719 /*
720 * Must call this twice: Once just to detect whether hardware doesn't
721 * support NX (so that the early EHCI debug console setup can safely
722 * call set_fixmap(), and then again after parsing early parameters to
723 * honor the respective command line option.
724 */
725 check_efer();
726#endif
727
728 parse_early_param();
729
714 /* VMI may relocate the fixmap; do this before touching ioremap area */ 730 /* VMI may relocate the fixmap; do this before touching ioremap area */
715 vmi_init(); 731 vmi_init();
716 732
@@ -793,11 +809,6 @@ void __init setup_arch(char **cmdline_p)
793#endif 809#endif
794#endif 810#endif
795 811
796 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
797 *cmdline_p = command_line;
798
799 parse_early_param();
800
801#ifdef CONFIG_X86_64 812#ifdef CONFIG_X86_64
802 check_efer(); 813 check_efer();
803#endif 814#endif
@@ -977,6 +988,8 @@ void __init setup_arch(char **cmdline_p)
977 paravirt_pagetable_setup_done(swapper_pg_dir); 988 paravirt_pagetable_setup_done(swapper_pg_dir);
978 paravirt_post_allocator_init(); 989 paravirt_post_allocator_init();
979 990
991 tboot_probe();
992
980#ifdef CONFIG_X86_64 993#ifdef CONFIG_X86_64
981 map_vsyscall(); 994 map_vsyscall();
982#endif 995#endif
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 07d81916f212..d559af913e1f 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -55,6 +55,7 @@ EXPORT_SYMBOL(__per_cpu_offset);
55#define PERCPU_FIRST_CHUNK_RESERVE 0 55#define PERCPU_FIRST_CHUNK_RESERVE 0
56#endif 56#endif
57 57
58#ifdef CONFIG_X86_32
58/** 59/**
59 * pcpu_need_numa - determine percpu allocation needs to consider NUMA 60 * pcpu_need_numa - determine percpu allocation needs to consider NUMA
60 * 61 *
@@ -83,6 +84,7 @@ static bool __init pcpu_need_numa(void)
83#endif 84#endif
84 return false; 85 return false;
85} 86}
87#endif
86 88
87/** 89/**
88 * pcpu_alloc_bootmem - NUMA friendly alloc_bootmem wrapper for percpu 90 * pcpu_alloc_bootmem - NUMA friendly alloc_bootmem wrapper for percpu
@@ -124,308 +126,35 @@ static void * __init pcpu_alloc_bootmem(unsigned int cpu, unsigned long size,
124} 126}
125 127
126/* 128/*
127 * Large page remap allocator 129 * Helpers for first chunk memory allocation
128 *
129 * This allocator uses PMD page as unit. A PMD page is allocated for
130 * each cpu and each is remapped into vmalloc area using PMD mapping.
131 * As PMD page is quite large, only part of it is used for the first
132 * chunk. Unused part is returned to the bootmem allocator.
133 *
134 * So, the PMD pages are mapped twice - once to the physical mapping
135 * and to the vmalloc area for the first percpu chunk. The double
136 * mapping does add one more PMD TLB entry pressure but still is much
137 * better than only using 4k mappings while still being NUMA friendly.
138 */ 130 */
139#ifdef CONFIG_NEED_MULTIPLE_NODES 131static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align)
140struct pcpul_ent {
141 unsigned int cpu;
142 void *ptr;
143};
144
145static size_t pcpul_size;
146static struct pcpul_ent *pcpul_map;
147static struct vm_struct pcpul_vm;
148
149static struct page * __init pcpul_get_page(unsigned int cpu, int pageno)
150{ 132{
151 size_t off = (size_t)pageno << PAGE_SHIFT; 133 return pcpu_alloc_bootmem(cpu, size, align);
152
153 if (off >= pcpul_size)
154 return NULL;
155
156 return virt_to_page(pcpul_map[cpu].ptr + off);
157} 134}
158 135
159static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen) 136static void __init pcpu_fc_free(void *ptr, size_t size)
160{ 137{
161 size_t map_size, dyn_size; 138 free_bootmem(__pa(ptr), size);
162 unsigned int cpu;
163 int i, j;
164 ssize_t ret;
165
166 if (!chosen) {
167 size_t vm_size = VMALLOC_END - VMALLOC_START;
168 size_t tot_size = nr_cpu_ids * PMD_SIZE;
169
170 /* on non-NUMA, embedding is better */
171 if (!pcpu_need_numa())
172 return -EINVAL;
173
174 /* don't consume more than 20% of vmalloc area */
175 if (tot_size > vm_size / 5) {
176 pr_info("PERCPU: too large chunk size %zuMB for "
177 "large page remap\n", tot_size >> 20);
178 return -EINVAL;
179 }
180 }
181
182 /* need PSE */
183 if (!cpu_has_pse) {
184 pr_warning("PERCPU: lpage allocator requires PSE\n");
185 return -EINVAL;
186 }
187
188 /*
189 * Currently supports only single page. Supporting multiple
190 * pages won't be too difficult if it ever becomes necessary.
191 */
192 pcpul_size = PFN_ALIGN(static_size + PERCPU_MODULE_RESERVE +
193 PERCPU_DYNAMIC_RESERVE);
194 if (pcpul_size > PMD_SIZE) {
195 pr_warning("PERCPU: static data is larger than large page, "
196 "can't use large page\n");
197 return -EINVAL;
198 }
199 dyn_size = pcpul_size - static_size - PERCPU_FIRST_CHUNK_RESERVE;
200
201 /* allocate pointer array and alloc large pages */
202 map_size = PFN_ALIGN(nr_cpu_ids * sizeof(pcpul_map[0]));
203 pcpul_map = alloc_bootmem(map_size);
204
205 for_each_possible_cpu(cpu) {
206 pcpul_map[cpu].cpu = cpu;
207 pcpul_map[cpu].ptr = pcpu_alloc_bootmem(cpu, PMD_SIZE,
208 PMD_SIZE);
209 if (!pcpul_map[cpu].ptr) {
210 pr_warning("PERCPU: failed to allocate large page "
211 "for cpu%u\n", cpu);
212 goto enomem;
213 }
214
215 /*
216 * Only use pcpul_size bytes and give back the rest.
217 *
218 * Ingo: The 2MB up-rounding bootmem is needed to make
219 * sure the partial 2MB page is still fully RAM - it's
220 * not well-specified to have a PAT-incompatible area
221 * (unmapped RAM, device memory, etc.) in that hole.
222 */
223 free_bootmem(__pa(pcpul_map[cpu].ptr + pcpul_size),
224 PMD_SIZE - pcpul_size);
225
226 memcpy(pcpul_map[cpu].ptr, __per_cpu_load, static_size);
227 }
228
229 /* allocate address and map */
230 pcpul_vm.flags = VM_ALLOC;
231 pcpul_vm.size = nr_cpu_ids * PMD_SIZE;
232 vm_area_register_early(&pcpul_vm, PMD_SIZE);
233
234 for_each_possible_cpu(cpu) {
235 pmd_t *pmd, pmd_v;
236
237 pmd = populate_extra_pmd((unsigned long)pcpul_vm.addr +
238 cpu * PMD_SIZE);
239 pmd_v = pfn_pmd(page_to_pfn(virt_to_page(pcpul_map[cpu].ptr)),
240 PAGE_KERNEL_LARGE);
241 set_pmd(pmd, pmd_v);
242 }
243
244 /* we're ready, commit */
245 pr_info("PERCPU: Remapped at %p with large pages, static data "
246 "%zu bytes\n", pcpul_vm.addr, static_size);
247
248 ret = pcpu_setup_first_chunk(pcpul_get_page, static_size,
249 PERCPU_FIRST_CHUNK_RESERVE, dyn_size,
250 PMD_SIZE, pcpul_vm.addr, NULL);
251
252 /* sort pcpul_map array for pcpu_lpage_remapped() */
253 for (i = 0; i < nr_cpu_ids - 1; i++)
254 for (j = i + 1; j < nr_cpu_ids; j++)
255 if (pcpul_map[i].ptr > pcpul_map[j].ptr) {
256 struct pcpul_ent tmp = pcpul_map[i];
257 pcpul_map[i] = pcpul_map[j];
258 pcpul_map[j] = tmp;
259 }
260
261 return ret;
262
263enomem:
264 for_each_possible_cpu(cpu)
265 if (pcpul_map[cpu].ptr)
266 free_bootmem(__pa(pcpul_map[cpu].ptr), pcpul_size);
267 free_bootmem(__pa(pcpul_map), map_size);
268 return -ENOMEM;
269} 139}
270 140
271/** 141static int __init pcpu_cpu_distance(unsigned int from, unsigned int to)
272 * pcpu_lpage_remapped - determine whether a kaddr is in pcpul recycled area
273 * @kaddr: the kernel address in question
274 *
275 * Determine whether @kaddr falls in the pcpul recycled area. This is
276 * used by pageattr to detect VM aliases and break up the pcpu PMD
277 * mapping such that the same physical page is not mapped under
278 * different attributes.
279 *
280 * The recycled area is always at the tail of a partially used PMD
281 * page.
282 *
283 * RETURNS:
284 * Address of corresponding remapped pcpu address if match is found;
285 * otherwise, NULL.
286 */
287void *pcpu_lpage_remapped(void *kaddr)
288{ 142{
289 void *pmd_addr = (void *)((unsigned long)kaddr & PMD_MASK); 143#ifdef CONFIG_NEED_MULTIPLE_NODES
290 unsigned long offset = (unsigned long)kaddr & ~PMD_MASK; 144 if (early_cpu_to_node(from) == early_cpu_to_node(to))
291 int left = 0, right = nr_cpu_ids - 1; 145 return LOCAL_DISTANCE;
292 int pos; 146 else
293 147 return REMOTE_DISTANCE;
294 /* pcpul in use at all? */
295 if (!pcpul_map)
296 return NULL;
297
298 /* okay, perform binary search */
299 while (left <= right) {
300 pos = (left + right) / 2;
301
302 if (pcpul_map[pos].ptr < pmd_addr)
303 left = pos + 1;
304 else if (pcpul_map[pos].ptr > pmd_addr)
305 right = pos - 1;
306 else {
307 /* it shouldn't be in the area for the first chunk */
308 WARN_ON(offset < pcpul_size);
309
310 return pcpul_vm.addr +
311 pcpul_map[pos].cpu * PMD_SIZE + offset;
312 }
313 }
314
315 return NULL;
316}
317#else 148#else
318static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen) 149 return LOCAL_DISTANCE;
319{
320 return -EINVAL;
321}
322#endif 150#endif
323
324/*
325 * Embedding allocator
326 *
327 * The first chunk is sized to just contain the static area plus
328 * module and dynamic reserves and embedded into linear physical
329 * mapping so that it can use PMD mapping without additional TLB
330 * pressure.
331 */
332static ssize_t __init setup_pcpu_embed(size_t static_size, bool chosen)
333{
334 size_t reserve = PERCPU_MODULE_RESERVE + PERCPU_DYNAMIC_RESERVE;
335
336 /*
337 * If large page isn't supported, there's no benefit in doing
338 * this. Also, embedding allocation doesn't play well with
339 * NUMA.
340 */
341 if (!chosen && (!cpu_has_pse || pcpu_need_numa()))
342 return -EINVAL;
343
344 return pcpu_embed_first_chunk(static_size, PERCPU_FIRST_CHUNK_RESERVE,
345 reserve - PERCPU_FIRST_CHUNK_RESERVE, -1);
346} 151}
347 152
348/* 153static void __init pcpup_populate_pte(unsigned long addr)
349 * 4k page allocator
350 *
351 * This is the basic allocator. Static percpu area is allocated
352 * page-by-page and most of initialization is done by the generic
353 * setup function.
354 */
355static struct page **pcpu4k_pages __initdata;
356static int pcpu4k_nr_static_pages __initdata;
357
358static struct page * __init pcpu4k_get_page(unsigned int cpu, int pageno)
359{
360 if (pageno < pcpu4k_nr_static_pages)
361 return pcpu4k_pages[cpu * pcpu4k_nr_static_pages + pageno];
362 return NULL;
363}
364
365static void __init pcpu4k_populate_pte(unsigned long addr)
366{ 154{
367 populate_extra_pte(addr); 155 populate_extra_pte(addr);
368} 156}
369 157
370static ssize_t __init setup_pcpu_4k(size_t static_size)
371{
372 size_t pages_size;
373 unsigned int cpu;
374 int i, j;
375 ssize_t ret;
376
377 pcpu4k_nr_static_pages = PFN_UP(static_size);
378
379 /* unaligned allocations can't be freed, round up to page size */
380 pages_size = PFN_ALIGN(pcpu4k_nr_static_pages * nr_cpu_ids
381 * sizeof(pcpu4k_pages[0]));
382 pcpu4k_pages = alloc_bootmem(pages_size);
383
384 /* allocate and copy */
385 j = 0;
386 for_each_possible_cpu(cpu)
387 for (i = 0; i < pcpu4k_nr_static_pages; i++) {
388 void *ptr;
389
390 ptr = pcpu_alloc_bootmem(cpu, PAGE_SIZE, PAGE_SIZE);
391 if (!ptr) {
392 pr_warning("PERCPU: failed to allocate "
393 "4k page for cpu%u\n", cpu);
394 goto enomem;
395 }
396
397 memcpy(ptr, __per_cpu_load + i * PAGE_SIZE, PAGE_SIZE);
398 pcpu4k_pages[j++] = virt_to_page(ptr);
399 }
400
401 /* we're ready, commit */
402 pr_info("PERCPU: Allocated %d 4k pages, static data %zu bytes\n",
403 pcpu4k_nr_static_pages, static_size);
404
405 ret = pcpu_setup_first_chunk(pcpu4k_get_page, static_size,
406 PERCPU_FIRST_CHUNK_RESERVE, -1,
407 -1, NULL, pcpu4k_populate_pte);
408 goto out_free_ar;
409
410enomem:
411 while (--j >= 0)
412 free_bootmem(__pa(page_address(pcpu4k_pages[j])), PAGE_SIZE);
413 ret = -ENOMEM;
414out_free_ar:
415 free_bootmem(__pa(pcpu4k_pages), pages_size);
416 return ret;
417}
418
419/* for explicit first chunk allocator selection */
420static char pcpu_chosen_alloc[16] __initdata;
421
422static int __init percpu_alloc_setup(char *str)
423{
424 strncpy(pcpu_chosen_alloc, str, sizeof(pcpu_chosen_alloc) - 1);
425 return 0;
426}
427early_param("percpu_alloc", percpu_alloc_setup);
428
429static inline void setup_percpu_segment(int cpu) 158static inline void setup_percpu_segment(int cpu)
430{ 159{
431#ifdef CONFIG_X86_32 160#ifdef CONFIG_X86_32
@@ -441,52 +170,49 @@ static inline void setup_percpu_segment(int cpu)
441 170
442void __init setup_per_cpu_areas(void) 171void __init setup_per_cpu_areas(void)
443{ 172{
444 size_t static_size = __per_cpu_end - __per_cpu_start;
445 unsigned int cpu; 173 unsigned int cpu;
446 unsigned long delta; 174 unsigned long delta;
447 size_t pcpu_unit_size; 175 int rc;
448 ssize_t ret;
449 176
450 pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n", 177 pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%d nr_node_ids:%d\n",
451 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids); 178 NR_CPUS, nr_cpumask_bits, nr_cpu_ids, nr_node_ids);
452 179
453 /* 180 /*
454 * Allocate percpu area. If PSE is supported, try to make use 181 * Allocate percpu area. Embedding allocator is our favorite;
455 * of large page mappings. Please read comments on top of 182 * however, on NUMA configurations, it can result in very
456 * each allocator for details. 183 * sparse unit mapping and vmalloc area isn't spacious enough
184 * on 32bit. Use page in that case.
457 */ 185 */
458 ret = -EINVAL; 186#ifdef CONFIG_X86_32
459 if (strlen(pcpu_chosen_alloc)) { 187 if (pcpu_chosen_fc == PCPU_FC_AUTO && pcpu_need_numa())
460 if (strcmp(pcpu_chosen_alloc, "4k")) { 188 pcpu_chosen_fc = PCPU_FC_PAGE;
461 if (!strcmp(pcpu_chosen_alloc, "lpage")) 189#endif
462 ret = setup_pcpu_lpage(static_size, true); 190 rc = -EINVAL;
463 else if (!strcmp(pcpu_chosen_alloc, "embed")) 191 if (pcpu_chosen_fc != PCPU_FC_PAGE) {
464 ret = setup_pcpu_embed(static_size, true); 192 const size_t atom_size = cpu_has_pse ? PMD_SIZE : PAGE_SIZE;
465 else 193 const size_t dyn_size = PERCPU_MODULE_RESERVE +
466 pr_warning("PERCPU: unknown allocator %s " 194 PERCPU_DYNAMIC_RESERVE - PERCPU_FIRST_CHUNK_RESERVE;
467 "specified\n", pcpu_chosen_alloc); 195
468 if (ret < 0) 196 rc = pcpu_embed_first_chunk(PERCPU_FIRST_CHUNK_RESERVE,
469 pr_warning("PERCPU: %s allocator failed (%zd), " 197 dyn_size, atom_size,
470 "falling back to 4k\n", 198 pcpu_cpu_distance,
471 pcpu_chosen_alloc, ret); 199 pcpu_fc_alloc, pcpu_fc_free);
472 } 200 if (rc < 0)
473 } else { 201 pr_warning("PERCPU: %s allocator failed (%d), "
474 ret = setup_pcpu_lpage(static_size, false); 202 "falling back to page size\n",
475 if (ret < 0) 203 pcpu_fc_names[pcpu_chosen_fc], rc);
476 ret = setup_pcpu_embed(static_size, false);
477 } 204 }
478 if (ret < 0) 205 if (rc < 0)
479 ret = setup_pcpu_4k(static_size); 206 rc = pcpu_page_first_chunk(PERCPU_FIRST_CHUNK_RESERVE,
480 if (ret < 0) 207 pcpu_fc_alloc, pcpu_fc_free,
481 panic("cannot allocate static percpu area (%zu bytes, err=%zd)", 208 pcpup_populate_pte);
482 static_size, ret); 209 if (rc < 0)
483 210 panic("cannot initialize percpu area (err=%d)", rc);
484 pcpu_unit_size = ret;
485 211
486 /* alrighty, percpu areas up and running */ 212 /* alrighty, percpu areas up and running */
487 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start; 213 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
488 for_each_possible_cpu(cpu) { 214 for_each_possible_cpu(cpu) {
489 per_cpu_offset(cpu) = delta + cpu * pcpu_unit_size; 215 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
490 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu); 216 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
491 per_cpu(cpu_number, cpu) = cpu; 217 per_cpu(cpu_number, cpu) = cpu;
492 setup_percpu_segment(cpu); 218 setup_percpu_segment(cpu);
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index c36cc1452cdc..a25eeec00080 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -47,6 +47,7 @@
47#include <linux/bootmem.h> 47#include <linux/bootmem.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/nmi.h> 49#include <linux/nmi.h>
50#include <linux/tboot.h>
50 51
51#include <asm/acpi.h> 52#include <asm/acpi.h>
52#include <asm/desc.h> 53#include <asm/desc.h>
@@ -1117,9 +1118,22 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1117 1118
1118 if (is_uv_system()) 1119 if (is_uv_system())
1119 uv_system_init(); 1120 uv_system_init();
1121
1122 set_mtrr_aps_delayed_init();
1120out: 1123out:
1121 preempt_enable(); 1124 preempt_enable();
1122} 1125}
1126
1127void arch_enable_nonboot_cpus_begin(void)
1128{
1129 set_mtrr_aps_delayed_init();
1130}
1131
1132void arch_enable_nonboot_cpus_end(void)
1133{
1134 mtrr_aps_init();
1135}
1136
1123/* 1137/*
1124 * Early setup to make printk work. 1138 * Early setup to make printk work.
1125 */ 1139 */
@@ -1141,6 +1155,7 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
1141 setup_ioapic_dest(); 1155 setup_ioapic_dest();
1142#endif 1156#endif
1143 check_nmi_watchdog(); 1157 check_nmi_watchdog();
1158 mtrr_aps_init();
1144} 1159}
1145 1160
1146static int __initdata setup_possible_cpus = -1; 1161static int __initdata setup_possible_cpus = -1;
@@ -1318,6 +1333,7 @@ void play_dead_common(void)
1318void native_play_dead(void) 1333void native_play_dead(void)
1319{ 1334{
1320 play_dead_common(); 1335 play_dead_common();
1336 tboot_shutdown(TB_SHUTDOWN_WFS);
1321 wbinvd_halt(); 1337 wbinvd_halt();
1322} 1338}
1323 1339
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
new file mode 100644
index 000000000000..86c9f91b48ae
--- /dev/null
+++ b/arch/x86/kernel/tboot.c
@@ -0,0 +1,447 @@
1/*
2 * tboot.c: main implementation of helper functions used by kernel for
3 * runtime support of Intel(R) Trusted Execution Technology
4 *
5 * Copyright (c) 2006-2009, Intel Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22#include <linux/dma_remapping.h>
23#include <linux/init_task.h>
24#include <linux/spinlock.h>
25#include <linux/delay.h>
26#include <linux/sched.h>
27#include <linux/init.h>
28#include <linux/dmar.h>
29#include <linux/cpu.h>
30#include <linux/pfn.h>
31#include <linux/mm.h>
32#include <linux/tboot.h>
33
34#include <asm/trampoline.h>
35#include <asm/processor.h>
36#include <asm/bootparam.h>
37#include <asm/pgtable.h>
38#include <asm/pgalloc.h>
39#include <asm/fixmap.h>
40#include <asm/proto.h>
41#include <asm/setup.h>
42#include <asm/e820.h>
43#include <asm/io.h>
44
45#include "acpi/realmode/wakeup.h"
46
47/* Global pointer to shared data; NULL means no measured launch. */
48struct tboot *tboot __read_mostly;
49
50/* timeout for APs (in secs) to enter wait-for-SIPI state during shutdown */
51#define AP_WAIT_TIMEOUT 1
52
53#undef pr_fmt
54#define pr_fmt(fmt) "tboot: " fmt
55
56static u8 tboot_uuid[16] __initdata = TBOOT_UUID;
57
58void __init tboot_probe(void)
59{
60 /* Look for valid page-aligned address for shared page. */
61 if (!boot_params.tboot_addr)
62 return;
63 /*
64 * also verify that it is mapped as we expect it before calling
65 * set_fixmap(), to reduce chance of garbage value causing crash
66 */
67 if (!e820_any_mapped(boot_params.tboot_addr,
68 boot_params.tboot_addr, E820_RESERVED)) {
69 pr_warning("non-0 tboot_addr but it is not of type E820_RESERVED\n");
70 return;
71 }
72
73 /* only a natively booted kernel should be using TXT */
74 if (paravirt_enabled()) {
75 pr_warning("non-0 tboot_addr but pv_ops is enabled\n");
76 return;
77 }
78
79 /* Map and check for tboot UUID. */
80 set_fixmap(FIX_TBOOT_BASE, boot_params.tboot_addr);
81 tboot = (struct tboot *)fix_to_virt(FIX_TBOOT_BASE);
82 if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) {
83 pr_warning("tboot at 0x%llx is invalid\n",
84 boot_params.tboot_addr);
85 tboot = NULL;
86 return;
87 }
88 if (tboot->version < 5) {
89 pr_warning("tboot version is invalid: %u\n", tboot->version);
90 tboot = NULL;
91 return;
92 }
93
94 pr_info("found shared page at phys addr 0x%llx:\n",
95 boot_params.tboot_addr);
96 pr_debug("version: %d\n", tboot->version);
97 pr_debug("log_addr: 0x%08x\n", tboot->log_addr);
98 pr_debug("shutdown_entry: 0x%x\n", tboot->shutdown_entry);
99 pr_debug("tboot_base: 0x%08x\n", tboot->tboot_base);
100 pr_debug("tboot_size: 0x%x\n", tboot->tboot_size);
101}
102
103static pgd_t *tboot_pg_dir;
104static struct mm_struct tboot_mm = {
105 .mm_rb = RB_ROOT,
106 .pgd = swapper_pg_dir,
107 .mm_users = ATOMIC_INIT(2),
108 .mm_count = ATOMIC_INIT(1),
109 .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem),
110 .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
111 .mmlist = LIST_HEAD_INIT(init_mm.mmlist),
112 .cpu_vm_mask = CPU_MASK_ALL,
113};
114
115static inline void switch_to_tboot_pt(void)
116{
117 write_cr3(virt_to_phys(tboot_pg_dir));
118}
119
120static int map_tboot_page(unsigned long vaddr, unsigned long pfn,
121 pgprot_t prot)
122{
123 pgd_t *pgd;
124 pud_t *pud;
125 pmd_t *pmd;
126 pte_t *pte;
127
128 pgd = pgd_offset(&tboot_mm, vaddr);
129 pud = pud_alloc(&tboot_mm, pgd, vaddr);
130 if (!pud)
131 return -1;
132 pmd = pmd_alloc(&tboot_mm, pud, vaddr);
133 if (!pmd)
134 return -1;
135 pte = pte_alloc_map(&tboot_mm, pmd, vaddr);
136 if (!pte)
137 return -1;
138 set_pte_at(&tboot_mm, vaddr, pte, pfn_pte(pfn, prot));
139 pte_unmap(pte);
140 return 0;
141}
142
143static int map_tboot_pages(unsigned long vaddr, unsigned long start_pfn,
144 unsigned long nr)
145{
146 /* Reuse the original kernel mapping */
147 tboot_pg_dir = pgd_alloc(&tboot_mm);
148 if (!tboot_pg_dir)
149 return -1;
150
151 for (; nr > 0; nr--, vaddr += PAGE_SIZE, start_pfn++) {
152 if (map_tboot_page(vaddr, start_pfn, PAGE_KERNEL_EXEC))
153 return -1;
154 }
155
156 return 0;
157}
158
159static void tboot_create_trampoline(void)
160{
161 u32 map_base, map_size;
162
163 /* Create identity map for tboot shutdown code. */
164 map_base = PFN_DOWN(tboot->tboot_base);
165 map_size = PFN_UP(tboot->tboot_size);
166 if (map_tboot_pages(map_base << PAGE_SHIFT, map_base, map_size))
167 panic("tboot: Error mapping tboot pages (mfns) @ 0x%x, 0x%x\n",
168 map_base, map_size);
169}
170
171#ifdef CONFIG_ACPI_SLEEP
172
173static void add_mac_region(phys_addr_t start, unsigned long size)
174{
175 struct tboot_mac_region *mr;
176 phys_addr_t end = start + size;
177
178 if (start && size) {
179 mr = &tboot->mac_regions[tboot->num_mac_regions++];
180 mr->start = round_down(start, PAGE_SIZE);
181 mr->size = round_up(end, PAGE_SIZE) - mr->start;
182 }
183}
184
185static int tboot_setup_sleep(void)
186{
187 tboot->num_mac_regions = 0;
188
189 /* S3 resume code */
190 add_mac_region(acpi_wakeup_address, WAKEUP_SIZE);
191
192#ifdef CONFIG_X86_TRAMPOLINE
193 /* AP trampoline code */
194 add_mac_region(virt_to_phys(trampoline_base), TRAMPOLINE_SIZE);
195#endif
196
197 /* kernel code + data + bss */
198 add_mac_region(virt_to_phys(_text), _end - _text);
199
200 tboot->acpi_sinfo.kernel_s3_resume_vector = acpi_wakeup_address;
201
202 return 0;
203}
204
205#else /* no CONFIG_ACPI_SLEEP */
206
207static int tboot_setup_sleep(void)
208{
209 /* S3 shutdown requested, but S3 not supported by the kernel... */
210 BUG();
211 return -1;
212}
213
214#endif
215
216void tboot_shutdown(u32 shutdown_type)
217{
218 void (*shutdown)(void);
219
220 if (!tboot_enabled())
221 return;
222
223 /*
224 * if we're being called before the 1:1 mapping is set up then just
225 * return and let the normal shutdown happen; this should only be
226 * due to very early panic()
227 */
228 if (!tboot_pg_dir)
229 return;
230
231 /* if this is S3 then set regions to MAC */
232 if (shutdown_type == TB_SHUTDOWN_S3)
233 if (tboot_setup_sleep())
234 return;
235
236 tboot->shutdown_type = shutdown_type;
237
238 switch_to_tboot_pt();
239
240 shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
241 shutdown();
242
243 /* should not reach here */
244 while (1)
245 halt();
246}
247
248static void tboot_copy_fadt(const struct acpi_table_fadt *fadt)
249{
250#define TB_COPY_GAS(tbg, g) \
251 tbg.space_id = g.space_id; \
252 tbg.bit_width = g.bit_width; \
253 tbg.bit_offset = g.bit_offset; \
254 tbg.access_width = g.access_width; \
255 tbg.address = g.address;
256
257 TB_COPY_GAS(tboot->acpi_sinfo.pm1a_cnt_blk, fadt->xpm1a_control_block);
258 TB_COPY_GAS(tboot->acpi_sinfo.pm1b_cnt_blk, fadt->xpm1b_control_block);
259 TB_COPY_GAS(tboot->acpi_sinfo.pm1a_evt_blk, fadt->xpm1a_event_block);
260 TB_COPY_GAS(tboot->acpi_sinfo.pm1b_evt_blk, fadt->xpm1b_event_block);
261
262 /*
263 * We need phys addr of waking vector, but can't use virt_to_phys() on
264 * &acpi_gbl_FACS because it is ioremap'ed, so calc from FACS phys
265 * addr.
266 */
267 tboot->acpi_sinfo.wakeup_vector = fadt->facs +
268 offsetof(struct acpi_table_facs, firmware_waking_vector);
269}
270
271void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
272{
273 static u32 acpi_shutdown_map[ACPI_S_STATE_COUNT] = {
274 /* S0,1,2: */ -1, -1, -1,
275 /* S3: */ TB_SHUTDOWN_S3,
276 /* S4: */ TB_SHUTDOWN_S4,
277 /* S5: */ TB_SHUTDOWN_S5 };
278
279 if (!tboot_enabled())
280 return;
281
282 tboot_copy_fadt(&acpi_gbl_FADT);
283 tboot->acpi_sinfo.pm1a_cnt_val = pm1a_control;
284 tboot->acpi_sinfo.pm1b_cnt_val = pm1b_control;
285 /* we always use the 32b wakeup vector */
286 tboot->acpi_sinfo.vector_width = 32;
287
288 if (sleep_state >= ACPI_S_STATE_COUNT ||
289 acpi_shutdown_map[sleep_state] == -1) {
290 pr_warning("unsupported sleep state 0x%x\n", sleep_state);
291 return;
292 }
293
294 tboot_shutdown(acpi_shutdown_map[sleep_state]);
295}
296
297static atomic_t ap_wfs_count;
298
299static int tboot_wait_for_aps(int num_aps)
300{
301 unsigned long timeout;
302
303 timeout = AP_WAIT_TIMEOUT*HZ;
304 while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps &&
305 timeout) {
306 mdelay(1);
307 timeout--;
308 }
309
310 if (timeout)
311 pr_warning("tboot wait for APs timeout\n");
312
313 return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
314}
315
316static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
317 unsigned long action, void *hcpu)
318{
319 switch (action) {
320 case CPU_DYING:
321 atomic_inc(&ap_wfs_count);
322 if (num_online_cpus() == 1)
323 if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
324 return NOTIFY_BAD;
325 break;
326 }
327 return NOTIFY_OK;
328}
329
330static struct notifier_block tboot_cpu_notifier __cpuinitdata =
331{
332 .notifier_call = tboot_cpu_callback,
333};
334
335static __init int tboot_late_init(void)
336{
337 if (!tboot_enabled())
338 return 0;
339
340 tboot_create_trampoline();
341
342 atomic_set(&ap_wfs_count, 0);
343 register_hotcpu_notifier(&tboot_cpu_notifier);
344 return 0;
345}
346
347late_initcall(tboot_late_init);
348
349/*
350 * TXT configuration registers (offsets from TXT_{PUB, PRIV}_CONFIG_REGS_BASE)
351 */
352
353#define TXT_PUB_CONFIG_REGS_BASE 0xfed30000
354#define TXT_PRIV_CONFIG_REGS_BASE 0xfed20000
355
356/* # pages for each config regs space - used by fixmap */
357#define NR_TXT_CONFIG_PAGES ((TXT_PUB_CONFIG_REGS_BASE - \
358 TXT_PRIV_CONFIG_REGS_BASE) >> PAGE_SHIFT)
359
360/* offsets from pub/priv config space */
361#define TXTCR_HEAP_BASE 0x0300
362#define TXTCR_HEAP_SIZE 0x0308
363
364#define SHA1_SIZE 20
365
366struct sha1_hash {
367 u8 hash[SHA1_SIZE];
368};
369
370struct sinit_mle_data {
371 u32 version; /* currently 6 */
372 struct sha1_hash bios_acm_id;
373 u32 edx_senter_flags;
374 u64 mseg_valid;
375 struct sha1_hash sinit_hash;
376 struct sha1_hash mle_hash;
377 struct sha1_hash stm_hash;
378 struct sha1_hash lcp_policy_hash;
379 u32 lcp_policy_control;
380 u32 rlp_wakeup_addr;
381 u32 reserved;
382 u32 num_mdrs;
383 u32 mdrs_off;
384 u32 num_vtd_dmars;
385 u32 vtd_dmars_off;
386} __packed;
387
388struct acpi_table_header *tboot_get_dmar_table(struct acpi_table_header *dmar_tbl)
389{
390 void *heap_base, *heap_ptr, *config;
391
392 if (!tboot_enabled())
393 return dmar_tbl;
394
395 /*
396 * ACPI tables may not be DMA protected by tboot, so use DMAR copy
397 * SINIT saved in SinitMleData in TXT heap (which is DMA protected)
398 */
399
400 /* map config space in order to get heap addr */
401 config = ioremap(TXT_PUB_CONFIG_REGS_BASE, NR_TXT_CONFIG_PAGES *
402 PAGE_SIZE);
403 if (!config)
404 return NULL;
405
406 /* now map TXT heap */
407 heap_base = ioremap(*(u64 *)(config + TXTCR_HEAP_BASE),
408 *(u64 *)(config + TXTCR_HEAP_SIZE));
409 iounmap(config);
410 if (!heap_base)
411 return NULL;
412
413 /* walk heap to SinitMleData */
414 /* skip BiosData */
415 heap_ptr = heap_base + *(u64 *)heap_base;
416 /* skip OsMleData */
417 heap_ptr += *(u64 *)heap_ptr;
418 /* skip OsSinitData */
419 heap_ptr += *(u64 *)heap_ptr;
420 /* now points to SinitMleDataSize; set to SinitMleData */
421 heap_ptr += sizeof(u64);
422 /* get addr of DMAR table */
423 dmar_tbl = (struct acpi_table_header *)(heap_ptr +
424 ((struct sinit_mle_data *)heap_ptr)->vtd_dmars_off -
425 sizeof(u64));
426
427 /* don't unmap heap because dmar.c needs access to this */
428
429 return dmar_tbl;
430}
431
432int tboot_force_iommu(void)
433{
434 if (!tboot_enabled())
435 return 0;
436
437 if (no_iommu || swiotlb || dmar_disabled)
438 pr_warning("Forcing Intel-IOMMU to enabled\n");
439
440 dmar_disabled = 0;
441#ifdef CONFIG_SWIOTLB
442 swiotlb = 0;
443#endif
444 no_iommu = 0;
445
446 return 1;
447}
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 9fc178255c04..0ccb57d5ee35 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -348,15 +348,12 @@ SECTIONS
348 _end = .; 348 _end = .;
349 } 349 }
350 350
351 /* Sections to be discarded */
352 /DISCARD/ : {
353 *(.exitcall.exit)
354 *(.eh_frame)
355 *(.discard)
356 }
357
358 STABS_DEBUG 351 STABS_DEBUG
359 DWARF_DEBUG 352 DWARF_DEBUG
353
354 /* Sections to be discarded */
355 DISCARDS
356 /DISCARD/ : { *(.eh_frame) }
360} 357}
361 358
362 359
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
index fe6f84ca121e..84e236ce76ba 100644
--- a/arch/x86/mm/iomap_32.c
+++ b/arch/x86/mm/iomap_32.c
@@ -21,7 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23 23
24int is_io_mapping_possible(resource_size_t base, unsigned long size) 24static int is_io_mapping_possible(resource_size_t base, unsigned long size)
25{ 25{
26#if !defined(CONFIG_X86_PAE) && defined(CONFIG_PHYS_ADDR_T_64BIT) 26#if !defined(CONFIG_X86_PAE) && defined(CONFIG_PHYS_ADDR_T_64BIT)
27 /* There is no way to map greater than 1 << 32 address without PAE */ 27 /* There is no way to map greater than 1 << 32 address without PAE */
@@ -30,7 +30,30 @@ int is_io_mapping_possible(resource_size_t base, unsigned long size)
30#endif 30#endif
31 return 1; 31 return 1;
32} 32}
33EXPORT_SYMBOL_GPL(is_io_mapping_possible); 33
34int iomap_create_wc(resource_size_t base, unsigned long size, pgprot_t *prot)
35{
36 unsigned long flag = _PAGE_CACHE_WC;
37 int ret;
38
39 if (!is_io_mapping_possible(base, size))
40 return -EINVAL;
41
42 ret = io_reserve_memtype(base, base + size, &flag);
43 if (ret)
44 return ret;
45
46 *prot = __pgprot(__PAGE_KERNEL | flag);
47 return 0;
48}
49EXPORT_SYMBOL_GPL(iomap_create_wc);
50
51void
52iomap_free(resource_size_t base, unsigned long size)
53{
54 io_free_memtype(base, base + size);
55}
56EXPORT_SYMBOL_GPL(iomap_free);
34 57
35void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot) 58void *kmap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot)
36{ 59{
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 04e1ad60c63a..334e63ca7b2b 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -158,24 +158,14 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
158 retval = reserve_memtype(phys_addr, (u64)phys_addr + size, 158 retval = reserve_memtype(phys_addr, (u64)phys_addr + size,
159 prot_val, &new_prot_val); 159 prot_val, &new_prot_val);
160 if (retval) { 160 if (retval) {
161 pr_debug("Warning: reserve_memtype returned %d\n", retval); 161 printk(KERN_ERR "ioremap reserve_memtype failed %d\n", retval);
162 return NULL; 162 return NULL;
163 } 163 }
164 164
165 if (prot_val != new_prot_val) { 165 if (prot_val != new_prot_val) {
166 /* 166 if (!is_new_memtype_allowed(phys_addr, size,
167 * Do not fallback to certain memory types with certain 167 prot_val, new_prot_val)) {
168 * requested type: 168 printk(KERN_ERR
169 * - request is uc-, return cannot be write-back
170 * - request is uc-, return cannot be write-combine
171 * - request is write-combine, return cannot be write-back
172 */
173 if ((prot_val == _PAGE_CACHE_UC_MINUS &&
174 (new_prot_val == _PAGE_CACHE_WB ||
175 new_prot_val == _PAGE_CACHE_WC)) ||
176 (prot_val == _PAGE_CACHE_WC &&
177 new_prot_val == _PAGE_CACHE_WB)) {
178 pr_debug(
179 "ioremap error for 0x%llx-0x%llx, requested 0x%lx, got 0x%lx\n", 169 "ioremap error for 0x%llx-0x%llx, requested 0x%lx, got 0x%lx\n",
180 (unsigned long long)phys_addr, 170 (unsigned long long)phys_addr,
181 (unsigned long long)(phys_addr + size), 171 (unsigned long long)(phys_addr + size),
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 7e600c1962db..24952fdc7e40 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -12,6 +12,7 @@
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/debugfs.h> 13#include <linux/debugfs.h>
14#include <linux/pfn.h> 14#include <linux/pfn.h>
15#include <linux/percpu.h>
15 16
16#include <asm/e820.h> 17#include <asm/e820.h>
17#include <asm/processor.h> 18#include <asm/processor.h>
@@ -686,7 +687,7 @@ static int cpa_process_alias(struct cpa_data *cpa)
686{ 687{
687 struct cpa_data alias_cpa; 688 struct cpa_data alias_cpa;
688 unsigned long laddr = (unsigned long)__va(cpa->pfn << PAGE_SHIFT); 689 unsigned long laddr = (unsigned long)__va(cpa->pfn << PAGE_SHIFT);
689 unsigned long vaddr, remapped; 690 unsigned long vaddr;
690 int ret; 691 int ret;
691 692
692 if (cpa->pfn >= max_pfn_mapped) 693 if (cpa->pfn >= max_pfn_mapped)
@@ -744,24 +745,6 @@ static int cpa_process_alias(struct cpa_data *cpa)
744 } 745 }
745#endif 746#endif
746 747
747 /*
748 * If the PMD page was partially used for per-cpu remapping,
749 * the recycled area needs to be split and modified. Because
750 * the area is always proper subset of a PMD page
751 * cpa->numpages is guaranteed to be 1 for these areas, so
752 * there's no need to loop over and check for further remaps.
753 */
754 remapped = (unsigned long)pcpu_lpage_remapped((void *)laddr);
755 if (remapped) {
756 WARN_ON(cpa->numpages > 1);
757 alias_cpa = *cpa;
758 alias_cpa.vaddr = &remapped;
759 alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY);
760 ret = __change_page_attr_set_clr(&alias_cpa, 0);
761 if (ret)
762 return ret;
763 }
764
765 return 0; 748 return 0;
766} 749}
767 750
@@ -822,6 +805,7 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
822{ 805{
823 struct cpa_data cpa; 806 struct cpa_data cpa;
824 int ret, cache, checkalias; 807 int ret, cache, checkalias;
808 unsigned long baddr = 0;
825 809
826 /* 810 /*
827 * Check, if we are requested to change a not supported 811 * Check, if we are requested to change a not supported
@@ -853,6 +837,11 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
853 */ 837 */
854 WARN_ON_ONCE(1); 838 WARN_ON_ONCE(1);
855 } 839 }
840 /*
841 * Save address for cache flush. *addr is modified in the call
842 * to __change_page_attr_set_clr() below.
843 */
844 baddr = *addr;
856 } 845 }
857 846
858 /* Must avoid aliasing mappings in the highmem code */ 847 /* Must avoid aliasing mappings in the highmem code */
@@ -900,7 +889,7 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages,
900 cpa_flush_array(addr, numpages, cache, 889 cpa_flush_array(addr, numpages, cache,
901 cpa.flags, pages); 890 cpa.flags, pages);
902 } else 891 } else
903 cpa_flush_range(*addr, numpages, cache); 892 cpa_flush_range(baddr, numpages, cache);
904 } else 893 } else
905 cpa_flush_all(cache); 894 cpa_flush_all(cache);
906 895
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index b2f7d3e59b86..d7ebc3a10f2f 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -15,6 +15,7 @@
15#include <linux/gfp.h> 15#include <linux/gfp.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/rbtree.h>
18 19
19#include <asm/cacheflush.h> 20#include <asm/cacheflush.h>
20#include <asm/processor.h> 21#include <asm/processor.h>
@@ -148,11 +149,10 @@ static char *cattr_name(unsigned long flags)
148 * areas). All the aliases have the same cache attributes of course. 149 * areas). All the aliases have the same cache attributes of course.
149 * Zero attributes are represented as holes. 150 * Zero attributes are represented as holes.
150 * 151 *
151 * Currently the data structure is a list because the number of mappings 152 * The data structure is a list that is also organized as an rbtree
152 * are expected to be relatively small. If this should be a problem 153 * sorted on the start address of memtype range.
153 * it could be changed to a rbtree or similar.
154 * 154 *
155 * memtype_lock protects the whole list. 155 * memtype_lock protects both the linear list and rbtree.
156 */ 156 */
157 157
158struct memtype { 158struct memtype {
@@ -160,11 +160,53 @@ struct memtype {
160 u64 end; 160 u64 end;
161 unsigned long type; 161 unsigned long type;
162 struct list_head nd; 162 struct list_head nd;
163 struct rb_node rb;
163}; 164};
164 165
166static struct rb_root memtype_rbroot = RB_ROOT;
165static LIST_HEAD(memtype_list); 167static LIST_HEAD(memtype_list);
166static DEFINE_SPINLOCK(memtype_lock); /* protects memtype list */ 168static DEFINE_SPINLOCK(memtype_lock); /* protects memtype list */
167 169
170static struct memtype *memtype_rb_search(struct rb_root *root, u64 start)
171{
172 struct rb_node *node = root->rb_node;
173 struct memtype *last_lower = NULL;
174
175 while (node) {
176 struct memtype *data = container_of(node, struct memtype, rb);
177
178 if (data->start < start) {
179 last_lower = data;
180 node = node->rb_right;
181 } else if (data->start > start) {
182 node = node->rb_left;
183 } else
184 return data;
185 }
186
187 /* Will return NULL if there is no entry with its start <= start */
188 return last_lower;
189}
190
191static void memtype_rb_insert(struct rb_root *root, struct memtype *data)
192{
193 struct rb_node **new = &(root->rb_node);
194 struct rb_node *parent = NULL;
195
196 while (*new) {
197 struct memtype *this = container_of(*new, struct memtype, rb);
198
199 parent = *new;
200 if (data->start <= this->start)
201 new = &((*new)->rb_left);
202 else if (data->start > this->start)
203 new = &((*new)->rb_right);
204 }
205
206 rb_link_node(&data->rb, parent, new);
207 rb_insert_color(&data->rb, root);
208}
209
168/* 210/*
169 * Does intersection of PAT memory type and MTRR memory type and returns 211 * Does intersection of PAT memory type and MTRR memory type and returns
170 * the resulting memory type as PAT understands it. 212 * the resulting memory type as PAT understands it.
@@ -218,9 +260,6 @@ chk_conflict(struct memtype *new, struct memtype *entry, unsigned long *type)
218 return -EBUSY; 260 return -EBUSY;
219} 261}
220 262
221static struct memtype *cached_entry;
222static u64 cached_start;
223
224static int pat_pagerange_is_ram(unsigned long start, unsigned long end) 263static int pat_pagerange_is_ram(unsigned long start, unsigned long end)
225{ 264{
226 int ram_page = 0, not_rampage = 0; 265 int ram_page = 0, not_rampage = 0;
@@ -249,63 +288,61 @@ static int pat_pagerange_is_ram(unsigned long start, unsigned long end)
249} 288}
250 289
251/* 290/*
252 * For RAM pages, mark the pages as non WB memory type using 291 * For RAM pages, we use page flags to mark the pages with appropriate type.
253 * PageNonWB (PG_arch_1). We allow only one set_memory_uc() or 292 * Here we do two pass:
254 * set_memory_wc() on a RAM page at a time before marking it as WB again. 293 * - Find the memtype of all the pages in the range, look for any conflicts
255 * This is ok, because only one driver will be owning the page and 294 * - In case of no conflicts, set the new memtype for pages in the range
256 * doing set_memory_*() calls.
257 * 295 *
258 * For now, we use PageNonWB to track that the RAM page is being mapped 296 * Caller must hold memtype_lock for atomicity.
259 * as non WB. In future, we will have to use one more flag
260 * (or some other mechanism in page_struct) to distinguish between
261 * UC and WC mapping.
262 */ 297 */
263static int reserve_ram_pages_type(u64 start, u64 end, unsigned long req_type, 298static int reserve_ram_pages_type(u64 start, u64 end, unsigned long req_type,
264 unsigned long *new_type) 299 unsigned long *new_type)
265{ 300{
266 struct page *page; 301 struct page *page;
267 u64 pfn, end_pfn; 302 u64 pfn;
303
304 if (req_type == _PAGE_CACHE_UC) {
305 /* We do not support strong UC */
306 WARN_ON_ONCE(1);
307 req_type = _PAGE_CACHE_UC_MINUS;
308 }
268 309
269 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) { 310 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) {
270 page = pfn_to_page(pfn); 311 unsigned long type;
271 if (page_mapped(page) || PageNonWB(page))
272 goto out;
273 312
274 SetPageNonWB(page); 313 page = pfn_to_page(pfn);
314 type = get_page_memtype(page);
315 if (type != -1) {
316 printk(KERN_INFO "reserve_ram_pages_type failed "
317 "0x%Lx-0x%Lx, track 0x%lx, req 0x%lx\n",
318 start, end, type, req_type);
319 if (new_type)
320 *new_type = type;
321
322 return -EBUSY;
323 }
275 } 324 }
276 return 0;
277 325
278out: 326 if (new_type)
279 end_pfn = pfn; 327 *new_type = req_type;
280 for (pfn = (start >> PAGE_SHIFT); pfn < end_pfn; ++pfn) { 328
329 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) {
281 page = pfn_to_page(pfn); 330 page = pfn_to_page(pfn);
282 ClearPageNonWB(page); 331 set_page_memtype(page, req_type);
283 } 332 }
284 333 return 0;
285 return -EINVAL;
286} 334}
287 335
288static int free_ram_pages_type(u64 start, u64 end) 336static int free_ram_pages_type(u64 start, u64 end)
289{ 337{
290 struct page *page; 338 struct page *page;
291 u64 pfn, end_pfn; 339 u64 pfn;
292 340
293 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) { 341 for (pfn = (start >> PAGE_SHIFT); pfn < (end >> PAGE_SHIFT); ++pfn) {
294 page = pfn_to_page(pfn); 342 page = pfn_to_page(pfn);
295 if (page_mapped(page) || !PageNonWB(page)) 343 set_page_memtype(page, -1);
296 goto out;
297
298 ClearPageNonWB(page);
299 } 344 }
300 return 0; 345 return 0;
301
302out:
303 end_pfn = pfn;
304 for (pfn = (start >> PAGE_SHIFT); pfn < end_pfn; ++pfn) {
305 page = pfn_to_page(pfn);
306 SetPageNonWB(page);
307 }
308 return -EINVAL;
309} 346}
310 347
311/* 348/*
@@ -339,6 +376,8 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
339 if (new_type) { 376 if (new_type) {
340 if (req_type == -1) 377 if (req_type == -1)
341 *new_type = _PAGE_CACHE_WB; 378 *new_type = _PAGE_CACHE_WB;
379 else if (req_type == _PAGE_CACHE_WC)
380 *new_type = _PAGE_CACHE_UC_MINUS;
342 else 381 else
343 *new_type = req_type & _PAGE_CACHE_MASK; 382 *new_type = req_type & _PAGE_CACHE_MASK;
344 } 383 }
@@ -364,11 +403,16 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
364 *new_type = actual_type; 403 *new_type = actual_type;
365 404
366 is_range_ram = pat_pagerange_is_ram(start, end); 405 is_range_ram = pat_pagerange_is_ram(start, end);
367 if (is_range_ram == 1) 406 if (is_range_ram == 1) {
368 return reserve_ram_pages_type(start, end, req_type, 407
369 new_type); 408 spin_lock(&memtype_lock);
370 else if (is_range_ram < 0) 409 err = reserve_ram_pages_type(start, end, req_type, new_type);
410 spin_unlock(&memtype_lock);
411
412 return err;
413 } else if (is_range_ram < 0) {
371 return -EINVAL; 414 return -EINVAL;
415 }
372 416
373 new = kmalloc(sizeof(struct memtype), GFP_KERNEL); 417 new = kmalloc(sizeof(struct memtype), GFP_KERNEL);
374 if (!new) 418 if (!new)
@@ -380,17 +424,19 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
380 424
381 spin_lock(&memtype_lock); 425 spin_lock(&memtype_lock);
382 426
383 if (cached_entry && start >= cached_start) 427 entry = memtype_rb_search(&memtype_rbroot, new->start);
384 entry = cached_entry; 428 if (likely(entry != NULL)) {
385 else 429 /* To work correctly with list_for_each_entry_continue */
430 entry = list_entry(entry->nd.prev, struct memtype, nd);
431 } else {
386 entry = list_entry(&memtype_list, struct memtype, nd); 432 entry = list_entry(&memtype_list, struct memtype, nd);
433 }
387 434
388 /* Search for existing mapping that overlaps the current range */ 435 /* Search for existing mapping that overlaps the current range */
389 where = NULL; 436 where = NULL;
390 list_for_each_entry_continue(entry, &memtype_list, nd) { 437 list_for_each_entry_continue(entry, &memtype_list, nd) {
391 if (end <= entry->start) { 438 if (end <= entry->start) {
392 where = entry->nd.prev; 439 where = entry->nd.prev;
393 cached_entry = list_entry(where, struct memtype, nd);
394 break; 440 break;
395 } else if (start <= entry->start) { /* end > entry->start */ 441 } else if (start <= entry->start) { /* end > entry->start */
396 err = chk_conflict(new, entry, new_type); 442 err = chk_conflict(new, entry, new_type);
@@ -398,8 +444,6 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
398 dprintk("Overlap at 0x%Lx-0x%Lx\n", 444 dprintk("Overlap at 0x%Lx-0x%Lx\n",
399 entry->start, entry->end); 445 entry->start, entry->end);
400 where = entry->nd.prev; 446 where = entry->nd.prev;
401 cached_entry = list_entry(where,
402 struct memtype, nd);
403 } 447 }
404 break; 448 break;
405 } else if (start < entry->end) { /* start > entry->start */ 449 } else if (start < entry->end) { /* start > entry->start */
@@ -407,8 +451,6 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
407 if (!err) { 451 if (!err) {
408 dprintk("Overlap at 0x%Lx-0x%Lx\n", 452 dprintk("Overlap at 0x%Lx-0x%Lx\n",
409 entry->start, entry->end); 453 entry->start, entry->end);
410 cached_entry = list_entry(entry->nd.prev,
411 struct memtype, nd);
412 454
413 /* 455 /*
414 * Move to right position in the linked 456 * Move to right position in the linked
@@ -436,13 +478,13 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
436 return err; 478 return err;
437 } 479 }
438 480
439 cached_start = start;
440
441 if (where) 481 if (where)
442 list_add(&new->nd, where); 482 list_add(&new->nd, where);
443 else 483 else
444 list_add_tail(&new->nd, &memtype_list); 484 list_add_tail(&new->nd, &memtype_list);
445 485
486 memtype_rb_insert(&memtype_rbroot, new);
487
446 spin_unlock(&memtype_lock); 488 spin_unlock(&memtype_lock);
447 489
448 dprintk("reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s, ret %s\n", 490 dprintk("reserve_memtype added 0x%Lx-0x%Lx, track %s, req %s, ret %s\n",
@@ -454,7 +496,7 @@ int reserve_memtype(u64 start, u64 end, unsigned long req_type,
454 496
455int free_memtype(u64 start, u64 end) 497int free_memtype(u64 start, u64 end)
456{ 498{
457 struct memtype *entry; 499 struct memtype *entry, *saved_entry;
458 int err = -EINVAL; 500 int err = -EINVAL;
459 int is_range_ram; 501 int is_range_ram;
460 502
@@ -466,23 +508,58 @@ int free_memtype(u64 start, u64 end)
466 return 0; 508 return 0;
467 509
468 is_range_ram = pat_pagerange_is_ram(start, end); 510 is_range_ram = pat_pagerange_is_ram(start, end);
469 if (is_range_ram == 1) 511 if (is_range_ram == 1) {
470 return free_ram_pages_type(start, end); 512
471 else if (is_range_ram < 0) 513 spin_lock(&memtype_lock);
514 err = free_ram_pages_type(start, end);
515 spin_unlock(&memtype_lock);
516
517 return err;
518 } else if (is_range_ram < 0) {
472 return -EINVAL; 519 return -EINVAL;
520 }
473 521
474 spin_lock(&memtype_lock); 522 spin_lock(&memtype_lock);
523
524 entry = memtype_rb_search(&memtype_rbroot, start);
525 if (unlikely(entry == NULL))
526 goto unlock_ret;
527
528 /*
529 * Saved entry points to an entry with start same or less than what
530 * we searched for. Now go through the list in both directions to look
531 * for the entry that matches with both start and end, with list stored
532 * in sorted start address
533 */
534 saved_entry = entry;
475 list_for_each_entry(entry, &memtype_list, nd) { 535 list_for_each_entry(entry, &memtype_list, nd) {
476 if (entry->start == start && entry->end == end) { 536 if (entry->start == start && entry->end == end) {
477 if (cached_entry == entry || cached_start == start) 537 rb_erase(&entry->rb, &memtype_rbroot);
478 cached_entry = NULL; 538 list_del(&entry->nd);
539 kfree(entry);
540 err = 0;
541 break;
542 } else if (entry->start > start) {
543 break;
544 }
545 }
546
547 if (!err)
548 goto unlock_ret;
479 549
550 entry = saved_entry;
551 list_for_each_entry_reverse(entry, &memtype_list, nd) {
552 if (entry->start == start && entry->end == end) {
553 rb_erase(&entry->rb, &memtype_rbroot);
480 list_del(&entry->nd); 554 list_del(&entry->nd);
481 kfree(entry); 555 kfree(entry);
482 err = 0; 556 err = 0;
483 break; 557 break;
558 } else if (entry->start < start) {
559 break;
484 } 560 }
485 } 561 }
562unlock_ret:
486 spin_unlock(&memtype_lock); 563 spin_unlock(&memtype_lock);
487 564
488 if (err) { 565 if (err) {
@@ -496,6 +573,101 @@ int free_memtype(u64 start, u64 end)
496} 573}
497 574
498 575
576/**
577 * lookup_memtype - Looksup the memory type for a physical address
578 * @paddr: physical address of which memory type needs to be looked up
579 *
580 * Only to be called when PAT is enabled
581 *
582 * Returns _PAGE_CACHE_WB, _PAGE_CACHE_WC, _PAGE_CACHE_UC_MINUS or
583 * _PAGE_CACHE_UC
584 */
585static unsigned long lookup_memtype(u64 paddr)
586{
587 int rettype = _PAGE_CACHE_WB;
588 struct memtype *entry;
589
590 if (is_ISA_range(paddr, paddr + PAGE_SIZE - 1))
591 return rettype;
592
593 if (pat_pagerange_is_ram(paddr, paddr + PAGE_SIZE)) {
594 struct page *page;
595 spin_lock(&memtype_lock);
596 page = pfn_to_page(paddr >> PAGE_SHIFT);
597 rettype = get_page_memtype(page);
598 spin_unlock(&memtype_lock);
599 /*
600 * -1 from get_page_memtype() implies RAM page is in its
601 * default state and not reserved, and hence of type WB
602 */
603 if (rettype == -1)
604 rettype = _PAGE_CACHE_WB;
605
606 return rettype;
607 }
608
609 spin_lock(&memtype_lock);
610
611 entry = memtype_rb_search(&memtype_rbroot, paddr);
612 if (entry != NULL)
613 rettype = entry->type;
614 else
615 rettype = _PAGE_CACHE_UC_MINUS;
616
617 spin_unlock(&memtype_lock);
618 return rettype;
619}
620
621/**
622 * io_reserve_memtype - Request a memory type mapping for a region of memory
623 * @start: start (physical address) of the region
624 * @end: end (physical address) of the region
625 * @type: A pointer to memtype, with requested type. On success, requested
626 * or any other compatible type that was available for the region is returned
627 *
628 * On success, returns 0
629 * On failure, returns non-zero
630 */
631int io_reserve_memtype(resource_size_t start, resource_size_t end,
632 unsigned long *type)
633{
634 resource_size_t size = end - start;
635 unsigned long req_type = *type;
636 unsigned long new_type;
637 int ret;
638
639 WARN_ON_ONCE(iomem_map_sanity_check(start, size));
640
641 ret = reserve_memtype(start, end, req_type, &new_type);
642 if (ret)
643 goto out_err;
644
645 if (!is_new_memtype_allowed(start, size, req_type, new_type))
646 goto out_free;
647
648 if (kernel_map_sync_memtype(start, size, new_type) < 0)
649 goto out_free;
650
651 *type = new_type;
652 return 0;
653
654out_free:
655 free_memtype(start, end);
656 ret = -EBUSY;
657out_err:
658 return ret;
659}
660
661/**
662 * io_free_memtype - Release a memory type mapping for a region of memory
663 * @start: start (physical address) of the region
664 * @end: end (physical address) of the region
665 */
666void io_free_memtype(resource_size_t start, resource_size_t end)
667{
668 free_memtype(start, end);
669}
670
499pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 671pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
500 unsigned long size, pgprot_t vma_prot) 672 unsigned long size, pgprot_t vma_prot)
501{ 673{
@@ -577,7 +749,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
577{ 749{
578 unsigned long id_sz; 750 unsigned long id_sz;
579 751
580 if (!pat_enabled || base >= __pa(high_memory)) 752 if (base >= __pa(high_memory))
581 return 0; 753 return 0;
582 754
583 id_sz = (__pa(high_memory) < base + size) ? 755 id_sz = (__pa(high_memory) < base + size) ?
@@ -612,11 +784,29 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
612 is_ram = pat_pagerange_is_ram(paddr, paddr + size); 784 is_ram = pat_pagerange_is_ram(paddr, paddr + size);
613 785
614 /* 786 /*
615 * reserve_pfn_range() doesn't support RAM pages. Maintain the current 787 * reserve_pfn_range() for RAM pages. We do not refcount to keep
616 * behavior with RAM pages by returning success. 788 * track of number of mappings of RAM pages. We can assert that
789 * the type requested matches the type of first page in the range.
617 */ 790 */
618 if (is_ram != 0) 791 if (is_ram) {
792 if (!pat_enabled)
793 return 0;
794
795 flags = lookup_memtype(paddr);
796 if (want_flags != flags) {
797 printk(KERN_WARNING
798 "%s:%d map pfn RAM range req %s for %Lx-%Lx, got %s\n",
799 current->comm, current->pid,
800 cattr_name(want_flags),
801 (unsigned long long)paddr,
802 (unsigned long long)(paddr + size),
803 cattr_name(flags));
804 *vma_prot = __pgprot((pgprot_val(*vma_prot) &
805 (~_PAGE_CACHE_MASK)) |
806 flags);
807 }
619 return 0; 808 return 0;
809 }
620 810
621 ret = reserve_memtype(paddr, paddr + size, want_flags, &flags); 811 ret = reserve_memtype(paddr, paddr + size, want_flags, &flags);
622 if (ret) 812 if (ret)
@@ -678,14 +868,6 @@ int track_pfn_vma_copy(struct vm_area_struct *vma)
678 unsigned long vma_size = vma->vm_end - vma->vm_start; 868 unsigned long vma_size = vma->vm_end - vma->vm_start;
679 pgprot_t pgprot; 869 pgprot_t pgprot;
680 870
681 if (!pat_enabled)
682 return 0;
683
684 /*
685 * For now, only handle remap_pfn_range() vmas where
686 * is_linear_pfn_mapping() == TRUE. Handling of
687 * vm_insert_pfn() is TBD.
688 */
689 if (is_linear_pfn_mapping(vma)) { 871 if (is_linear_pfn_mapping(vma)) {
690 /* 872 /*
691 * reserve the whole chunk covered by vma. We need the 873 * reserve the whole chunk covered by vma. We need the
@@ -713,23 +895,24 @@ int track_pfn_vma_copy(struct vm_area_struct *vma)
713int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t *prot, 895int track_pfn_vma_new(struct vm_area_struct *vma, pgprot_t *prot,
714 unsigned long pfn, unsigned long size) 896 unsigned long pfn, unsigned long size)
715{ 897{
898 unsigned long flags;
716 resource_size_t paddr; 899 resource_size_t paddr;
717 unsigned long vma_size = vma->vm_end - vma->vm_start; 900 unsigned long vma_size = vma->vm_end - vma->vm_start;
718 901
719 if (!pat_enabled)
720 return 0;
721
722 /*
723 * For now, only handle remap_pfn_range() vmas where
724 * is_linear_pfn_mapping() == TRUE. Handling of
725 * vm_insert_pfn() is TBD.
726 */
727 if (is_linear_pfn_mapping(vma)) { 902 if (is_linear_pfn_mapping(vma)) {
728 /* reserve the whole chunk starting from vm_pgoff */ 903 /* reserve the whole chunk starting from vm_pgoff */
729 paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT; 904 paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT;
730 return reserve_pfn_range(paddr, vma_size, prot, 0); 905 return reserve_pfn_range(paddr, vma_size, prot, 0);
731 } 906 }
732 907
908 if (!pat_enabled)
909 return 0;
910
911 /* for vm_insert_pfn and friends, we set prot based on lookup */
912 flags = lookup_memtype(pfn << PAGE_SHIFT);
913 *prot = __pgprot((pgprot_val(vma->vm_page_prot) & (~_PAGE_CACHE_MASK)) |
914 flags);
915
733 return 0; 916 return 0;
734} 917}
735 918
@@ -744,14 +927,6 @@ void untrack_pfn_vma(struct vm_area_struct *vma, unsigned long pfn,
744 resource_size_t paddr; 927 resource_size_t paddr;
745 unsigned long vma_size = vma->vm_end - vma->vm_start; 928 unsigned long vma_size = vma->vm_end - vma->vm_start;
746 929
747 if (!pat_enabled)
748 return;
749
750 /*
751 * For now, only handle remap_pfn_range() vmas where
752 * is_linear_pfn_mapping() == TRUE. Handling of
753 * vm_insert_pfn() is TBD.
754 */
755 if (is_linear_pfn_mapping(vma)) { 930 if (is_linear_pfn_mapping(vma)) {
756 /* free the whole chunk starting from vm_pgoff */ 931 /* free the whole chunk starting from vm_pgoff */
757 paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT; 932 paddr = (resource_size_t)vma->vm_pgoff << PAGE_SHIFT;
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index 3ffa10df20b9..572ee9782f2a 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -15,63 +15,6 @@
15 * also get peer root bus resource for io,mmio 15 * also get peer root bus resource for io,mmio
16 */ 16 */
17 17
18#ifdef CONFIG_NUMA
19
20#define BUS_NR 256
21
22#ifdef CONFIG_X86_64
23
24static int mp_bus_to_node[BUS_NR];
25
26void set_mp_bus_to_node(int busnum, int node)
27{
28 if (busnum >= 0 && busnum < BUS_NR)
29 mp_bus_to_node[busnum] = node;
30}
31
32int get_mp_bus_to_node(int busnum)
33{
34 int node = -1;
35
36 if (busnum < 0 || busnum > (BUS_NR - 1))
37 return node;
38
39 node = mp_bus_to_node[busnum];
40
41 /*
42 * let numa_node_id to decide it later in dma_alloc_pages
43 * if there is no ram on that node
44 */
45 if (node != -1 && !node_online(node))
46 node = -1;
47
48 return node;
49}
50
51#else /* CONFIG_X86_32 */
52
53static unsigned char mp_bus_to_node[BUS_NR];
54
55void set_mp_bus_to_node(int busnum, int node)
56{
57 if (busnum >= 0 && busnum < BUS_NR)
58 mp_bus_to_node[busnum] = (unsigned char) node;
59}
60
61int get_mp_bus_to_node(int busnum)
62{
63 int node;
64
65 if (busnum < 0 || busnum > (BUS_NR - 1))
66 return 0;
67 node = mp_bus_to_node[busnum];
68 return node;
69}
70
71#endif /* CONFIG_X86_32 */
72
73#endif /* CONFIG_NUMA */
74
75#ifdef CONFIG_X86_64 18#ifdef CONFIG_X86_64
76 19
77/* 20/*
@@ -301,11 +244,6 @@ static int __init early_fill_mp_bus_info(void)
301 u64 val; 244 u64 val;
302 u32 address; 245 u32 address;
303 246
304#ifdef CONFIG_NUMA
305 for (i = 0; i < BUS_NR; i++)
306 mp_bus_to_node[i] = -1;
307#endif
308
309 if (!early_pci_allowed()) 247 if (!early_pci_allowed())
310 return -1; 248 return -1;
311 249
@@ -346,7 +284,7 @@ static int __init early_fill_mp_bus_info(void)
346 node = (reg >> 4) & 0x07; 284 node = (reg >> 4) & 0x07;
347#ifdef CONFIG_NUMA 285#ifdef CONFIG_NUMA
348 for (j = min_bus; j <= max_bus; j++) 286 for (j = min_bus; j <= max_bus; j++)
349 mp_bus_to_node[j] = (unsigned char) node; 287 set_mp_bus_to_node(j, node);
350#endif 288#endif
351 link = (reg >> 8) & 0x03; 289 link = (reg >> 8) & 0x03;
352 290
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 2202b6257b82..5db96d4304de 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -600,3 +600,72 @@ struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
600{ 600{
601 return pci_scan_bus_on_node(busno, &pci_root_ops, -1); 601 return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
602} 602}
603
604/*
605 * NUMA info for PCI busses
606 *
607 * Early arch code is responsible for filling in reasonable values here.
608 * A node id of "-1" means "use current node". In other words, if a bus
609 * has a -1 node id, it's not tightly coupled to any particular chunk
610 * of memory (as is the case on some Nehalem systems).
611 */
612#ifdef CONFIG_NUMA
613
614#define BUS_NR 256
615
616#ifdef CONFIG_X86_64
617
618static int mp_bus_to_node[BUS_NR] = {
619 [0 ... BUS_NR - 1] = -1
620};
621
622void set_mp_bus_to_node(int busnum, int node)
623{
624 if (busnum >= 0 && busnum < BUS_NR)
625 mp_bus_to_node[busnum] = node;
626}
627
628int get_mp_bus_to_node(int busnum)
629{
630 int node = -1;
631
632 if (busnum < 0 || busnum > (BUS_NR - 1))
633 return node;
634
635 node = mp_bus_to_node[busnum];
636
637 /*
638 * let numa_node_id to decide it later in dma_alloc_pages
639 * if there is no ram on that node
640 */
641 if (node != -1 && !node_online(node))
642 node = -1;
643
644 return node;
645}
646
647#else /* CONFIG_X86_32 */
648
649static unsigned char mp_bus_to_node[BUS_NR] = {
650 [0 ... BUS_NR - 1] = -1
651};
652
653void set_mp_bus_to_node(int busnum, int node)
654{
655 if (busnum >= 0 && busnum < BUS_NR)
656 mp_bus_to_node[busnum] = (unsigned char) node;
657}
658
659int get_mp_bus_to_node(int busnum)
660{
661 int node;
662
663 if (busnum < 0 || busnum > (BUS_NR - 1))
664 return 0;
665 node = mp_bus_to_node[busnum];
666 return node;
667}
668
669#endif /* CONFIG_X86_32 */
670
671#endif /* CONFIG_NUMA */
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index b3d20b9cac63..417c9f5b4afa 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -242,7 +242,7 @@ static void __restore_processor_state(struct saved_context *ctxt)
242 fix_processor_context(); 242 fix_processor_context();
243 243
244 do_fpu_end(); 244 do_fpu_end();
245 mtrr_ap_init(); 245 mtrr_bp_restore();
246 246
247#ifdef CONFIG_X86_OLD_MCE 247#ifdef CONFIG_X86_OLD_MCE
248 mcheck_init(&boot_cpu_data); 248 mcheck_init(&boot_cpu_data);
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index 41c159cd872f..921b6ff3b645 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -280,15 +280,6 @@ SECTIONS
280 *(.ResetVector.text) 280 *(.ResetVector.text)
281 } 281 }
282 282
283 /* Sections to be discarded */
284 /DISCARD/ :
285 {
286 *(.exit.literal)
287 EXIT_TEXT
288 EXIT_DATA
289 *(.exitcall.exit)
290 }
291
292 .xt.lit : { *(.xt.lit) } 283 .xt.lit : { *(.xt.lit) }
293 .xt.prop : { *(.xt.prop) } 284 .xt.prop : { *(.xt.prop) }
294 285
@@ -321,4 +312,8 @@ SECTIONS
321 *(.xt.lit) 312 *(.xt.lit)
322 *(.gnu.linkonce.p*) 313 *(.gnu.linkonce.p*)
323 } 314 }
315
316 /* Sections to be discarded */
317 DISCARDS
318 /DISCARD/ : { *(.exit.literal) }
324} 319}
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 7a12cf6ee1d3..ce8ba57c6557 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -146,7 +146,7 @@ enum arq_state {
146#define RQ_STATE(rq) ((enum arq_state)(rq)->elevator_private2) 146#define RQ_STATE(rq) ((enum arq_state)(rq)->elevator_private2)
147#define RQ_SET_STATE(rq, state) ((rq)->elevator_private2 = (void *) state) 147#define RQ_SET_STATE(rq, state) ((rq)->elevator_private2 = (void *) state)
148 148
149static DEFINE_PER_CPU(unsigned long, ioc_count); 149static DEFINE_PER_CPU(unsigned long, as_ioc_count);
150static struct completion *ioc_gone; 150static struct completion *ioc_gone;
151static DEFINE_SPINLOCK(ioc_gone_lock); 151static DEFINE_SPINLOCK(ioc_gone_lock);
152 152
@@ -161,7 +161,7 @@ static void as_antic_stop(struct as_data *ad);
161static void free_as_io_context(struct as_io_context *aic) 161static void free_as_io_context(struct as_io_context *aic)
162{ 162{
163 kfree(aic); 163 kfree(aic);
164 elv_ioc_count_dec(ioc_count); 164 elv_ioc_count_dec(as_ioc_count);
165 if (ioc_gone) { 165 if (ioc_gone) {
166 /* 166 /*
167 * AS scheduler is exiting, grab exit lock and check 167 * AS scheduler is exiting, grab exit lock and check
@@ -169,7 +169,7 @@ static void free_as_io_context(struct as_io_context *aic)
169 * complete ioc_gone and set it back to NULL. 169 * complete ioc_gone and set it back to NULL.
170 */ 170 */
171 spin_lock(&ioc_gone_lock); 171 spin_lock(&ioc_gone_lock);
172 if (ioc_gone && !elv_ioc_count_read(ioc_count)) { 172 if (ioc_gone && !elv_ioc_count_read(as_ioc_count)) {
173 complete(ioc_gone); 173 complete(ioc_gone);
174 ioc_gone = NULL; 174 ioc_gone = NULL;
175 } 175 }
@@ -211,7 +211,7 @@ static struct as_io_context *alloc_as_io_context(void)
211 ret->seek_total = 0; 211 ret->seek_total = 0;
212 ret->seek_samples = 0; 212 ret->seek_samples = 0;
213 ret->seek_mean = 0; 213 ret->seek_mean = 0;
214 elv_ioc_count_inc(ioc_count); 214 elv_ioc_count_inc(as_ioc_count);
215 } 215 }
216 216
217 return ret; 217 return ret;
@@ -1507,7 +1507,7 @@ static void __exit as_exit(void)
1507 ioc_gone = &all_gone; 1507 ioc_gone = &all_gone;
1508 /* ioc_gone's update must be visible before reading ioc_count */ 1508 /* ioc_gone's update must be visible before reading ioc_count */
1509 smp_wmb(); 1509 smp_wmb();
1510 if (elv_ioc_count_read(ioc_count)) 1510 if (elv_ioc_count_read(as_ioc_count))
1511 wait_for_completion(&all_gone); 1511 wait_for_completion(&all_gone);
1512 synchronize_rcu(); 1512 synchronize_rcu();
1513} 1513}
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 0e3814b662af..1ca813b16e78 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -48,7 +48,7 @@ static int cfq_slice_idle = HZ / 125;
48static struct kmem_cache *cfq_pool; 48static struct kmem_cache *cfq_pool;
49static struct kmem_cache *cfq_ioc_pool; 49static struct kmem_cache *cfq_ioc_pool;
50 50
51static DEFINE_PER_CPU(unsigned long, ioc_count); 51static DEFINE_PER_CPU(unsigned long, cfq_ioc_count);
52static struct completion *ioc_gone; 52static struct completion *ioc_gone;
53static DEFINE_SPINLOCK(ioc_gone_lock); 53static DEFINE_SPINLOCK(ioc_gone_lock);
54 54
@@ -1415,7 +1415,7 @@ static void cfq_cic_free_rcu(struct rcu_head *head)
1415 cic = container_of(head, struct cfq_io_context, rcu_head); 1415 cic = container_of(head, struct cfq_io_context, rcu_head);
1416 1416
1417 kmem_cache_free(cfq_ioc_pool, cic); 1417 kmem_cache_free(cfq_ioc_pool, cic);
1418 elv_ioc_count_dec(ioc_count); 1418 elv_ioc_count_dec(cfq_ioc_count);
1419 1419
1420 if (ioc_gone) { 1420 if (ioc_gone) {
1421 /* 1421 /*
@@ -1424,7 +1424,7 @@ static void cfq_cic_free_rcu(struct rcu_head *head)
1424 * complete ioc_gone and set it back to NULL 1424 * complete ioc_gone and set it back to NULL
1425 */ 1425 */
1426 spin_lock(&ioc_gone_lock); 1426 spin_lock(&ioc_gone_lock);
1427 if (ioc_gone && !elv_ioc_count_read(ioc_count)) { 1427 if (ioc_gone && !elv_ioc_count_read(cfq_ioc_count)) {
1428 complete(ioc_gone); 1428 complete(ioc_gone);
1429 ioc_gone = NULL; 1429 ioc_gone = NULL;
1430 } 1430 }
@@ -1550,7 +1550,7 @@ cfq_alloc_io_context(struct cfq_data *cfqd, gfp_t gfp_mask)
1550 INIT_HLIST_NODE(&cic->cic_list); 1550 INIT_HLIST_NODE(&cic->cic_list);
1551 cic->dtor = cfq_free_io_context; 1551 cic->dtor = cfq_free_io_context;
1552 cic->exit = cfq_exit_io_context; 1552 cic->exit = cfq_exit_io_context;
1553 elv_ioc_count_inc(ioc_count); 1553 elv_ioc_count_inc(cfq_ioc_count);
1554 } 1554 }
1555 1555
1556 return cic; 1556 return cic;
@@ -2654,7 +2654,7 @@ static void __exit cfq_exit(void)
2654 * this also protects us from entering cfq_slab_kill() with 2654 * this also protects us from entering cfq_slab_kill() with
2655 * pending RCU callbacks 2655 * pending RCU callbacks
2656 */ 2656 */
2657 if (elv_ioc_count_read(ioc_count)) 2657 if (elv_ioc_count_read(cfq_ioc_count))
2658 wait_for_completion(&all_gone); 2658 wait_for_completion(&all_gone);
2659 cfq_slab_kill(); 2659 cfq_slab_kill();
2660} 2660}
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index db307a356f08..cc22f9a585b0 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -45,6 +45,7 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "actables.h" 47#include "actables.h"
48#include <linux/tboot.h>
48 49
49#define _COMPONENT ACPI_HARDWARE 50#define _COMPONENT ACPI_HARDWARE
50ACPI_MODULE_NAME("hwsleep") 51ACPI_MODULE_NAME("hwsleep")
@@ -342,6 +343,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
342 343
343 ACPI_FLUSH_CPU_CACHE(); 344 ACPI_FLUSH_CPU_CACHE();
344 345
346 tboot_sleep(sleep_state, pm1a_control, pm1b_control);
347
345 /* Write #2: Write both SLP_TYP + SLP_EN */ 348 /* Write #2: Write both SLP_TYP + SLP_EN */
346 349
347 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control); 350 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 55b5b90c2a44..31b961c2f22f 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -61,20 +61,6 @@ static struct acpi_driver acpi_pci_root_driver = {
61 }, 61 },
62}; 62};
63 63
64struct acpi_pci_root {
65 struct list_head node;
66 struct acpi_device *device;
67 struct pci_bus *bus;
68 u16 segment;
69 u8 bus_nr;
70
71 u32 osc_support_set; /* _OSC state of support bits */
72 u32 osc_control_set; /* _OSC state of control bits */
73 u32 osc_control_qry; /* the latest _OSC query result */
74
75 u32 osc_queried:1; /* has _OSC control been queried? */
76};
77
78static LIST_HEAD(acpi_pci_roots); 64static LIST_HEAD(acpi_pci_roots);
79 65
80static struct acpi_pci_driver *sub_driver; 66static struct acpi_pci_driver *sub_driver;
@@ -317,7 +303,7 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *root, u32 flags)
317 return status; 303 return status;
318} 304}
319 305
320static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle) 306struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
321{ 307{
322 struct acpi_pci_root *root; 308 struct acpi_pci_root *root;
323 309
@@ -327,6 +313,7 @@ static struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle)
327 } 313 }
328 return NULL; 314 return NULL;
329} 315}
316EXPORT_SYMBOL_GPL(acpi_pci_find_root);
330 317
331struct acpi_handle_node { 318struct acpi_handle_node {
332 struct list_head node; 319 struct list_head node;
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index d74365d4a6e7..5a09bf392ec1 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -44,6 +44,8 @@
44#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
46 46
47#include "sleep.h"
48
47#define _COMPONENT ACPI_POWER_COMPONENT 49#define _COMPONENT ACPI_POWER_COMPONENT
48ACPI_MODULE_NAME("power"); 50ACPI_MODULE_NAME("power");
49#define ACPI_POWER_CLASS "power_resource" 51#define ACPI_POWER_CLASS "power_resource"
@@ -361,17 +363,15 @@ int acpi_device_sleep_wake(struct acpi_device *dev,
361 */ 363 */
362int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) 364int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
363{ 365{
364 int i, err; 366 int i, err = 0;
365 367
366 if (!dev || !dev->wakeup.flags.valid) 368 if (!dev || !dev->wakeup.flags.valid)
367 return -EINVAL; 369 return -EINVAL;
368 370
369 /* 371 mutex_lock(&acpi_device_lock);
370 * Do not execute the code below twice in a row without calling 372
371 * acpi_disable_wakeup_device_power() in between for the same device 373 if (dev->wakeup.prepare_count++)
372 */ 374 goto out;
373 if (dev->wakeup.flags.prepared)
374 return 0;
375 375
376 /* Open power resource */ 376 /* Open power resource */
377 for (i = 0; i < dev->wakeup.resources.count; i++) { 377 for (i = 0; i < dev->wakeup.resources.count; i++) {
@@ -379,7 +379,8 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
379 if (ret) { 379 if (ret) {
380 printk(KERN_ERR PREFIX "Transition power state\n"); 380 printk(KERN_ERR PREFIX "Transition power state\n");
381 dev->wakeup.flags.valid = 0; 381 dev->wakeup.flags.valid = 0;
382 return -ENODEV; 382 err = -ENODEV;
383 goto err_out;
383 } 384 }
384 } 385 }
385 386
@@ -388,9 +389,13 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
388 * in arbitrary power state afterwards. 389 * in arbitrary power state afterwards.
389 */ 390 */
390 err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); 391 err = acpi_device_sleep_wake(dev, 1, sleep_state, 3);
391 if (!err)
392 dev->wakeup.flags.prepared = 1;
393 392
393 err_out:
394 if (err)
395 dev->wakeup.prepare_count = 0;
396
397 out:
398 mutex_unlock(&acpi_device_lock);
394 return err; 399 return err;
395} 400}
396 401
@@ -402,35 +407,42 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state)
402 */ 407 */
403int acpi_disable_wakeup_device_power(struct acpi_device *dev) 408int acpi_disable_wakeup_device_power(struct acpi_device *dev)
404{ 409{
405 int i, ret; 410 int i, err = 0;
406 411
407 if (!dev || !dev->wakeup.flags.valid) 412 if (!dev || !dev->wakeup.flags.valid)
408 return -EINVAL; 413 return -EINVAL;
409 414
415 mutex_lock(&acpi_device_lock);
416
417 if (--dev->wakeup.prepare_count > 0)
418 goto out;
419
410 /* 420 /*
411 * Do not execute the code below twice in a row without calling 421 * Executing the code below even if prepare_count is already zero when
412 * acpi_enable_wakeup_device_power() in between for the same device 422 * the function is called may be useful, for example for initialisation.
413 */ 423 */
414 if (!dev->wakeup.flags.prepared) 424 if (dev->wakeup.prepare_count < 0)
415 return 0; 425 dev->wakeup.prepare_count = 0;
416 426
417 dev->wakeup.flags.prepared = 0; 427 err = acpi_device_sleep_wake(dev, 0, 0, 0);
418 428 if (err)
419 ret = acpi_device_sleep_wake(dev, 0, 0, 0); 429 goto out;
420 if (ret)
421 return ret;
422 430
423 /* Close power resource */ 431 /* Close power resource */
424 for (i = 0; i < dev->wakeup.resources.count; i++) { 432 for (i = 0; i < dev->wakeup.resources.count; i++) {
425 ret = acpi_power_off_device(dev->wakeup.resources.handles[i], dev); 433 int ret = acpi_power_off_device(
434 dev->wakeup.resources.handles[i], dev);
426 if (ret) { 435 if (ret) {
427 printk(KERN_ERR PREFIX "Transition power state\n"); 436 printk(KERN_ERR PREFIX "Transition power state\n");
428 dev->wakeup.flags.valid = 0; 437 dev->wakeup.flags.valid = 0;
429 return -ENODEV; 438 err = -ENODEV;
439 goto out;
430 } 440 }
431 } 441 }
432 442
433 return ret; 443 out:
444 mutex_unlock(&acpi_device_lock);
445 return err;
434} 446}
435 447
436/* -------------------------------------------------------------------------- 448/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 781435d7e369..318b1ea7a5bf 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -781,6 +781,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
781 kfree(buffer.pointer); 781 kfree(buffer.pointer);
782 782
783 device->wakeup.flags.valid = 1; 783 device->wakeup.flags.valid = 1;
784 device->wakeup.prepare_count = 0;
784 /* Call _PSW/_DSW object to disable its ability to wake the sleeping 785 /* Call _PSW/_DSW object to disable its ability to wake the sleeping
785 * system for the ACPI device with the _PRW object. 786 * system for the ACPI device with the _PRW object.
786 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW. 787 * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 42159a28f433..feece693d773 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -689,19 +689,25 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
689{ 689{
690 acpi_handle handle; 690 acpi_handle handle;
691 struct acpi_device *adev; 691 struct acpi_device *adev;
692 int error;
692 693
693 if (!device_may_wakeup(dev)) 694 if (!device_can_wakeup(dev))
694 return -EINVAL; 695 return -EINVAL;
695 696
696 handle = DEVICE_ACPI_HANDLE(dev); 697 handle = DEVICE_ACPI_HANDLE(dev);
697 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { 698 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
698 printk(KERN_DEBUG "ACPI handle has no context!\n"); 699 dev_dbg(dev, "ACPI handle has no context in %s!\n", __func__);
699 return -ENODEV; 700 return -ENODEV;
700 } 701 }
701 702
702 return enable ? 703 error = enable ?
703 acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) : 704 acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) :
704 acpi_disable_wakeup_device_power(adev); 705 acpi_disable_wakeup_device_power(adev);
706 if (!error)
707 dev_info(dev, "wake-up capability %s by ACPI\n",
708 enable ? "enabled" : "disabled");
709
710 return error;
705} 711}
706#endif 712#endif
707 713
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 88725dcdf8bc..e0ee0c036f5a 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -68,7 +68,7 @@ void acpi_enable_wakeup_device(u8 sleep_state)
68 /* If users want to disable run-wake GPE, 68 /* If users want to disable run-wake GPE,
69 * we only disable it for wake and leave it for runtime 69 * we only disable it for wake and leave it for runtime
70 */ 70 */
71 if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) 71 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
72 || sleep_state > (u32) dev->wakeup.sleep_state) { 72 || sleep_state > (u32) dev->wakeup.sleep_state) {
73 if (dev->wakeup.flags.run_wake) { 73 if (dev->wakeup.flags.run_wake) {
74 /* set_gpe_type will disable GPE, leave it like that */ 74 /* set_gpe_type will disable GPE, leave it like that */
@@ -100,7 +100,7 @@ void acpi_disable_wakeup_device(u8 sleep_state)
100 if (!dev->wakeup.flags.valid) 100 if (!dev->wakeup.flags.valid)
101 continue; 101 continue;
102 102
103 if ((!dev->wakeup.state.enabled && !dev->wakeup.flags.prepared) 103 if ((!dev->wakeup.state.enabled && !dev->wakeup.prepare_count)
104 || sleep_state > (u32) dev->wakeup.sleep_state) { 104 || sleep_state > (u32) dev->wakeup.sleep_state) {
105 if (dev->wakeup.flags.run_wake) { 105 if (dev->wakeup.flags.run_wake) {
106 acpi_set_gpe_type(dev->wakeup.gpe_device, 106 acpi_set_gpe_type(dev->wakeup.gpe_device,
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index 095f97e60665..c8753a9ed290 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -13,8 +13,8 @@
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/seq_file.h> 14#include <linux/seq_file.h>
15 15
16#include <asm/cell-regs.h>
16#include <asm/firmware.h> 17#include <asm/firmware.h>
17#include <asm/iommu.h>
18#include <asm/lv1call.h> 18#include <asm/lv1call.h>
19#include <asm/ps3.h> 19#include <asm/ps3.h>
20#include <asm/ps3gpu.h> 20#include <asm/ps3gpu.h>
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index 178e2e9e9f09..d6f36c004d9b 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -107,7 +107,7 @@ struct agp_bridge_driver {
107 void (*agp_enable)(struct agp_bridge_data *, u32); 107 void (*agp_enable)(struct agp_bridge_data *, u32);
108 void (*cleanup)(void); 108 void (*cleanup)(void);
109 void (*tlb_flush)(struct agp_memory *); 109 void (*tlb_flush)(struct agp_memory *);
110 unsigned long (*mask_memory)(struct agp_bridge_data *, struct page *, int); 110 unsigned long (*mask_memory)(struct agp_bridge_data *, dma_addr_t, int);
111 void (*cache_flush)(void); 111 void (*cache_flush)(void);
112 int (*create_gatt_table)(struct agp_bridge_data *); 112 int (*create_gatt_table)(struct agp_bridge_data *);
113 int (*free_gatt_table)(struct agp_bridge_data *); 113 int (*free_gatt_table)(struct agp_bridge_data *);
@@ -121,6 +121,11 @@ struct agp_bridge_driver {
121 void (*agp_destroy_pages)(struct agp_memory *); 121 void (*agp_destroy_pages)(struct agp_memory *);
122 int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); 122 int (*agp_type_to_mask_type) (struct agp_bridge_data *, int);
123 void (*chipset_flush)(struct agp_bridge_data *); 123 void (*chipset_flush)(struct agp_bridge_data *);
124
125 int (*agp_map_page)(struct page *page, dma_addr_t *ret);
126 void (*agp_unmap_page)(struct page *page, dma_addr_t dma);
127 int (*agp_map_memory)(struct agp_memory *mem);
128 void (*agp_unmap_memory)(struct agp_memory *mem);
124}; 129};
125 130
126struct agp_bridge_data { 131struct agp_bridge_data {
@@ -134,7 +139,8 @@ struct agp_bridge_data {
134 u32 __iomem *gatt_table; 139 u32 __iomem *gatt_table;
135 u32 *gatt_table_real; 140 u32 *gatt_table_real;
136 unsigned long scratch_page; 141 unsigned long scratch_page;
137 unsigned long scratch_page_real; 142 struct page *scratch_page_page;
143 dma_addr_t scratch_page_dma;
138 unsigned long gart_bus_addr; 144 unsigned long gart_bus_addr;
139 unsigned long gatt_bus_addr; 145 unsigned long gatt_bus_addr;
140 u32 mode; 146 u32 mode;
@@ -291,7 +297,7 @@ int agp_3_5_enable(struct agp_bridge_data *bridge);
291void global_cache_flush(void); 297void global_cache_flush(void);
292void get_agp_version(struct agp_bridge_data *bridge); 298void get_agp_version(struct agp_bridge_data *bridge);
293unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, 299unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge,
294 struct page *page, int type); 300 dma_addr_t phys, int type);
295int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, 301int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge,
296 int type); 302 int type);
297struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); 303struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev);
@@ -312,9 +318,6 @@ void agp3_generic_cleanup(void);
312#define AGP_GENERIC_SIZES_ENTRIES 11 318#define AGP_GENERIC_SIZES_ENTRIES 11
313extern const struct aper_size_info_16 agp3_generic_sizes[]; 319extern const struct aper_size_info_16 agp3_generic_sizes[];
314 320
315#define virt_to_gart(x) (phys_to_gart(virt_to_phys(x)))
316#define gart_to_virt(x) (phys_to_virt(gart_to_phys(x)))
317
318extern int agp_off; 321extern int agp_off;
319extern int agp_try_unsupported_boot; 322extern int agp_try_unsupported_boot;
320 323
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 201ef3ffd484..d2ce68f27e4b 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -152,7 +152,7 @@ static struct page *m1541_alloc_page(struct agp_bridge_data *bridge)
152 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 152 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
153 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 153 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
154 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 154 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
155 phys_to_gart(page_to_phys(page))) | ALI_CACHE_FLUSH_EN )); 155 page_to_phys(page)) | ALI_CACHE_FLUSH_EN ));
156 return page; 156 return page;
157} 157}
158 158
@@ -180,7 +180,7 @@ static void m1541_destroy_page(struct page *page, int flags)
180 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); 180 pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
181 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, 181 pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
182 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) | 182 (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
183 phys_to_gart(page_to_phys(page))) | ALI_CACHE_FLUSH_EN)); 183 page_to_phys(page)) | ALI_CACHE_FLUSH_EN));
184 } 184 }
185 agp_generic_destroy_page(page, flags); 185 agp_generic_destroy_page(page, flags);
186} 186}
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index ba9bde71eaaf..73dbf40c874d 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -44,7 +44,7 @@ static int amd_create_page_map(struct amd_page_map *page_map)
44#ifndef CONFIG_X86 44#ifndef CONFIG_X86
45 SetPageReserved(virt_to_page(page_map->real)); 45 SetPageReserved(virt_to_page(page_map->real));
46 global_cache_flush(); 46 global_cache_flush();
47 page_map->remapped = ioremap_nocache(virt_to_gart(page_map->real), 47 page_map->remapped = ioremap_nocache(virt_to_phys(page_map->real),
48 PAGE_SIZE); 48 PAGE_SIZE);
49 if (page_map->remapped == NULL) { 49 if (page_map->remapped == NULL) {
50 ClearPageReserved(virt_to_page(page_map->real)); 50 ClearPageReserved(virt_to_page(page_map->real));
@@ -160,7 +160,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
160 160
161 agp_bridge->gatt_table_real = (u32 *)page_dir.real; 161 agp_bridge->gatt_table_real = (u32 *)page_dir.real;
162 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; 162 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
163 agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real); 163 agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
164 164
165 /* Get the address for the gart region. 165 /* Get the address for the gart region.
166 * This is a bus address even on the alpha, b/c its 166 * This is a bus address even on the alpha, b/c its
@@ -173,7 +173,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
173 173
174 /* Calculate the agp offset */ 174 /* Calculate the agp offset */
175 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { 175 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
176 writel(virt_to_gart(amd_irongate_private.gatt_pages[i]->real) | 1, 176 writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) | 1,
177 page_dir.remapped+GET_PAGE_DIR_OFF(addr)); 177 page_dir.remapped+GET_PAGE_DIR_OFF(addr));
178 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ 178 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
179 } 179 }
@@ -325,7 +325,9 @@ static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
325 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; 325 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
326 cur_gatt = GET_GATT(addr); 326 cur_gatt = GET_GATT(addr);
327 writel(agp_generic_mask_memory(agp_bridge, 327 writel(agp_generic_mask_memory(agp_bridge,
328 mem->pages[i], mem->type), cur_gatt+GET_GATT_OFF(addr)); 328 page_to_phys(mem->pages[i]),
329 mem->type),
330 cur_gatt+GET_GATT_OFF(addr));
329 readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */ 331 readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
330 } 332 }
331 amd_irongate_tlbflush(mem); 333 amd_irongate_tlbflush(mem);
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 3bf5dda90f4a..2fb2e6cc322a 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -79,7 +79,8 @@ static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
79 79
80 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 80 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
81 tmp = agp_bridge->driver->mask_memory(agp_bridge, 81 tmp = agp_bridge->driver->mask_memory(agp_bridge,
82 mem->pages[i], mask_type); 82 page_to_phys(mem->pages[i]),
83 mask_type);
83 84
84 BUG_ON(tmp & 0xffffff0000000ffcULL); 85 BUG_ON(tmp & 0xffffff0000000ffcULL);
85 pte = (tmp & 0x000000ff00000000ULL) >> 28; 86 pte = (tmp & 0x000000ff00000000ULL) >> 28;
@@ -177,7 +178,7 @@ static const struct aper_size_info_32 amd_8151_sizes[7] =
177 178
178static int amd_8151_configure(void) 179static int amd_8151_configure(void)
179{ 180{
180 unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real); 181 unsigned long gatt_bus = virt_to_phys(agp_bridge->gatt_table_real);
181 int i; 182 int i;
182 183
183 /* Configure AGP regs in each x86-64 host bridge. */ 184 /* Configure AGP regs in each x86-64 host bridge. */
@@ -557,7 +558,7 @@ static void __devexit agp_amd64_remove(struct pci_dev *pdev)
557{ 558{
558 struct agp_bridge_data *bridge = pci_get_drvdata(pdev); 559 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
559 560
560 release_mem_region(virt_to_gart(bridge->gatt_table_real), 561 release_mem_region(virt_to_phys(bridge->gatt_table_real),
561 amd64_aperture_sizes[bridge->aperture_size_idx].size); 562 amd64_aperture_sizes[bridge->aperture_size_idx].size);
562 agp_remove_bridge(bridge); 563 agp_remove_bridge(bridge);
563 agp_put_bridge(bridge); 564 agp_put_bridge(bridge);
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 33656e144cc5..3b2ecbe86ebe 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -302,7 +302,8 @@ static int ati_insert_memory(struct agp_memory * mem,
302 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; 302 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
303 cur_gatt = GET_GATT(addr); 303 cur_gatt = GET_GATT(addr);
304 writel(agp_bridge->driver->mask_memory(agp_bridge, 304 writel(agp_bridge->driver->mask_memory(agp_bridge,
305 mem->pages[i], mem->type), 305 page_to_phys(mem->pages[i]),
306 mem->type),
306 cur_gatt+GET_GATT_OFF(addr)); 307 cur_gatt+GET_GATT_OFF(addr));
307 } 308 }
308 readl(GET_GATT(agp_bridge->gart_bus_addr)); /* PCI posting */ 309 readl(GET_GATT(agp_bridge->gart_bus_addr)); /* PCI posting */
@@ -359,7 +360,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
359 360
360 agp_bridge->gatt_table_real = (u32 *)page_dir.real; 361 agp_bridge->gatt_table_real = (u32 *)page_dir.real;
361 agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped; 362 agp_bridge->gatt_table = (u32 __iomem *) page_dir.remapped;
362 agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real); 363 agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
363 364
364 /* Write out the size register */ 365 /* Write out the size register */
365 current_size = A_SIZE_LVL2(agp_bridge->current_size); 366 current_size = A_SIZE_LVL2(agp_bridge->current_size);
@@ -389,7 +390,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
389 390
390 /* Calculate the agp offset */ 391 /* Calculate the agp offset */
391 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { 392 for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
392 writel(virt_to_gart(ati_generic_private.gatt_pages[i]->real) | 1, 393 writel(virt_to_phys(ati_generic_private.gatt_pages[i]->real) | 1,
393 page_dir.remapped+GET_PAGE_DIR_OFF(addr)); 394 page_dir.remapped+GET_PAGE_DIR_OFF(addr));
394 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */ 395 readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
395 } 396 }
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index cfa5a649dfe7..ad87753f6de4 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -149,9 +149,21 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
149 return -ENOMEM; 149 return -ENOMEM;
150 } 150 }
151 151
152 bridge->scratch_page_real = phys_to_gart(page_to_phys(page)); 152 bridge->scratch_page_page = page;
153 bridge->scratch_page = 153 if (bridge->driver->agp_map_page) {
154 bridge->driver->mask_memory(bridge, page, 0); 154 if (bridge->driver->agp_map_page(page,
155 &bridge->scratch_page_dma)) {
156 dev_err(&bridge->dev->dev,
157 "unable to dma-map scratch page\n");
158 rc = -ENOMEM;
159 goto err_out_nounmap;
160 }
161 } else {
162 bridge->scratch_page_dma = page_to_phys(page);
163 }
164
165 bridge->scratch_page = bridge->driver->mask_memory(bridge,
166 bridge->scratch_page_dma, 0);
155 } 167 }
156 168
157 size_value = bridge->driver->fetch_size(); 169 size_value = bridge->driver->fetch_size();
@@ -191,8 +203,14 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
191 return 0; 203 return 0;
192 204
193err_out: 205err_out:
206 if (bridge->driver->needs_scratch_page &&
207 bridge->driver->agp_unmap_page) {
208 bridge->driver->agp_unmap_page(bridge->scratch_page_page,
209 bridge->scratch_page_dma);
210 }
211err_out_nounmap:
194 if (bridge->driver->needs_scratch_page) { 212 if (bridge->driver->needs_scratch_page) {
195 void *va = gart_to_virt(bridge->scratch_page_real); 213 void *va = page_address(bridge->scratch_page_page);
196 214
197 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP); 215 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP);
198 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE); 216 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE);
@@ -219,7 +237,11 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge)
219 237
220 if (bridge->driver->agp_destroy_page && 238 if (bridge->driver->agp_destroy_page &&
221 bridge->driver->needs_scratch_page) { 239 bridge->driver->needs_scratch_page) {
222 void *va = gart_to_virt(bridge->scratch_page_real); 240 void *va = page_address(bridge->scratch_page_page);
241
242 if (bridge->driver->agp_unmap_page)
243 bridge->driver->agp_unmap_page(bridge->scratch_page_page,
244 bridge->scratch_page_dma);
223 245
224 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP); 246 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_UNMAP);
225 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE); 247 bridge->driver->agp_destroy_page(va, AGP_PAGE_DESTROY_FREE);
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 35d50f2861b6..793f39ea9618 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -67,7 +67,7 @@ static const struct gatt_mask efficeon_generic_masks[] =
67/* This function does the same thing as mask_memory() for this chipset... */ 67/* This function does the same thing as mask_memory() for this chipset... */
68static inline unsigned long efficeon_mask_memory(struct page *page) 68static inline unsigned long efficeon_mask_memory(struct page *page)
69{ 69{
70 unsigned long addr = phys_to_gart(page_to_phys(page)); 70 unsigned long addr = page_to_phys(page);
71 return addr | 0x00000001; 71 return addr | 0x00000001;
72} 72}
73 73
@@ -226,7 +226,7 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge)
226 226
227 efficeon_private.l1_table[index] = page; 227 efficeon_private.l1_table[index] = page;
228 228
229 value = virt_to_gart((unsigned long *)page) | pati | present | index; 229 value = virt_to_phys((unsigned long *)page) | pati | present | index;
230 230
231 pci_write_config_dword(agp_bridge->dev, 231 pci_write_config_dword(agp_bridge->dev,
232 EFFICEON_ATTPAGE, value); 232 EFFICEON_ATTPAGE, value);
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 1e8b461b91f1..c50543966eb2 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -437,6 +437,12 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start)
437 curr->bridge->driver->cache_flush(); 437 curr->bridge->driver->cache_flush();
438 curr->is_flushed = true; 438 curr->is_flushed = true;
439 } 439 }
440
441 if (curr->bridge->driver->agp_map_memory) {
442 ret_val = curr->bridge->driver->agp_map_memory(curr);
443 if (ret_val)
444 return ret_val;
445 }
440 ret_val = curr->bridge->driver->insert_memory(curr, pg_start, curr->type); 446 ret_val = curr->bridge->driver->insert_memory(curr, pg_start, curr->type);
441 447
442 if (ret_val != 0) 448 if (ret_val != 0)
@@ -478,6 +484,9 @@ int agp_unbind_memory(struct agp_memory *curr)
478 if (ret_val != 0) 484 if (ret_val != 0)
479 return ret_val; 485 return ret_val;
480 486
487 if (curr->bridge->driver->agp_unmap_memory)
488 curr->bridge->driver->agp_unmap_memory(curr);
489
481 curr->is_bound = false; 490 curr->is_bound = false;
482 curr->pg_start = 0; 491 curr->pg_start = 0;
483 spin_lock(&curr->bridge->mapped_lock); 492 spin_lock(&curr->bridge->mapped_lock);
@@ -979,7 +988,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
979 set_memory_uc((unsigned long)table, 1 << page_order); 988 set_memory_uc((unsigned long)table, 1 << page_order);
980 bridge->gatt_table = (void *)table; 989 bridge->gatt_table = (void *)table;
981#else 990#else
982 bridge->gatt_table = ioremap_nocache(virt_to_gart(table), 991 bridge->gatt_table = ioremap_nocache(virt_to_phys(table),
983 (PAGE_SIZE * (1 << page_order))); 992 (PAGE_SIZE * (1 << page_order)));
984 bridge->driver->cache_flush(); 993 bridge->driver->cache_flush();
985#endif 994#endif
@@ -992,7 +1001,7 @@ int agp_generic_create_gatt_table(struct agp_bridge_data *bridge)
992 1001
993 return -ENOMEM; 1002 return -ENOMEM;
994 } 1003 }
995 bridge->gatt_bus_addr = virt_to_gart(bridge->gatt_table_real); 1004 bridge->gatt_bus_addr = virt_to_phys(bridge->gatt_table_real);
996 1005
997 /* AK: bogus, should encode addresses > 4GB */ 1006 /* AK: bogus, should encode addresses > 4GB */
998 for (i = 0; i < num_entries; i++) { 1007 for (i = 0; i < num_entries; i++) {
@@ -1132,7 +1141,9 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
1132 } 1141 }
1133 1142
1134 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 1143 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
1135 writel(bridge->driver->mask_memory(bridge, mem->pages[i], mask_type), 1144 writel(bridge->driver->mask_memory(bridge,
1145 page_to_phys(mem->pages[i]),
1146 mask_type),
1136 bridge->gatt_table+j); 1147 bridge->gatt_table+j);
1137 } 1148 }
1138 readl(bridge->gatt_table+j-1); /* PCI Posting. */ 1149 readl(bridge->gatt_table+j-1); /* PCI Posting. */
@@ -1347,9 +1358,8 @@ void global_cache_flush(void)
1347EXPORT_SYMBOL(global_cache_flush); 1358EXPORT_SYMBOL(global_cache_flush);
1348 1359
1349unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, 1360unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge,
1350 struct page *page, int type) 1361 dma_addr_t addr, int type)
1351{ 1362{
1352 unsigned long addr = phys_to_gart(page_to_phys(page));
1353 /* memory type is ignored in the generic routine */ 1363 /* memory type is ignored in the generic routine */
1354 if (bridge->driver->masks) 1364 if (bridge->driver->masks)
1355 return addr | bridge->driver->masks[0].mask; 1365 return addr | bridge->driver->masks[0].mask;
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 8f3d4c184914..501e293e5ad0 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -107,7 +107,7 @@ static int __init hp_zx1_ioc_shared(void)
107 hp->gart_size = HP_ZX1_GART_SIZE; 107 hp->gart_size = HP_ZX1_GART_SIZE;
108 hp->gatt_entries = hp->gart_size / hp->io_page_size; 108 hp->gatt_entries = hp->gart_size / hp->io_page_size;
109 109
110 hp->io_pdir = gart_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE)); 110 hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
111 hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; 111 hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)];
112 112
113 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { 113 if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
@@ -246,7 +246,7 @@ hp_zx1_configure (void)
246 agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS); 246 agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS);
247 247
248 if (hp->io_pdir_owner) { 248 if (hp->io_pdir_owner) {
249 writel(virt_to_gart(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE); 249 writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
250 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); 250 readl(hp->ioc_regs+HP_ZX1_PDIR_BASE);
251 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); 251 writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG);
252 readl(hp->ioc_regs+HP_ZX1_TCNFG); 252 readl(hp->ioc_regs+HP_ZX1_TCNFG);
@@ -394,10 +394,8 @@ hp_zx1_remove_memory (struct agp_memory *mem, off_t pg_start, int type)
394} 394}
395 395
396static unsigned long 396static unsigned long
397hp_zx1_mask_memory (struct agp_bridge_data *bridge, 397hp_zx1_mask_memory (struct agp_bridge_data *bridge, dma_addr_t addr, int type)
398 struct page *page, int type)
399{ 398{
400 unsigned long addr = phys_to_gart(page_to_phys(page));
401 return HP_ZX1_PDIR_VALID_BIT | addr; 399 return HP_ZX1_PDIR_VALID_BIT | addr;
402} 400}
403 401
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 60cc35bb5db7..e763d3312ce7 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -61,7 +61,7 @@
61#define WR_FLUSH_GATT(index) RD_GATT(index) 61#define WR_FLUSH_GATT(index) RD_GATT(index)
62 62
63static unsigned long i460_mask_memory (struct agp_bridge_data *bridge, 63static unsigned long i460_mask_memory (struct agp_bridge_data *bridge,
64 unsigned long addr, int type); 64 dma_addr_t addr, int type);
65 65
66static struct { 66static struct {
67 void *gatt; /* ioremap'd GATT area */ 67 void *gatt; /* ioremap'd GATT area */
@@ -325,7 +325,7 @@ static int i460_insert_memory_small_io_page (struct agp_memory *mem,
325 325
326 io_page_size = 1UL << I460_IO_PAGE_SHIFT; 326 io_page_size = 1UL << I460_IO_PAGE_SHIFT;
327 for (i = 0, j = io_pg_start; i < mem->page_count; i++) { 327 for (i = 0, j = io_pg_start; i < mem->page_count; i++) {
328 paddr = phys_to_gart(page_to_phys(mem->pages[i])); 328 paddr = page_to_phys(mem->pages[i]);
329 for (k = 0; k < I460_IOPAGES_PER_KPAGE; k++, j++, paddr += io_page_size) 329 for (k = 0; k < I460_IOPAGES_PER_KPAGE; k++, j++, paddr += io_page_size)
330 WR_GATT(j, i460_mask_memory(agp_bridge, paddr, mem->type)); 330 WR_GATT(j, i460_mask_memory(agp_bridge, paddr, mem->type));
331 } 331 }
@@ -382,7 +382,7 @@ static int i460_alloc_large_page (struct lp_desc *lp)
382 return -ENOMEM; 382 return -ENOMEM;
383 } 383 }
384 384
385 lp->paddr = phys_to_gart(page_to_phys(lp->page)); 385 lp->paddr = page_to_phys(lp->page);
386 lp->refcount = 0; 386 lp->refcount = 0;
387 atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp); 387 atomic_add(I460_KPAGES_PER_IOPAGE, &agp_bridge->current_memory_agp);
388 return 0; 388 return 0;
@@ -546,20 +546,13 @@ static void i460_destroy_page (struct page *page, int flags)
546#endif /* I460_LARGE_IO_PAGES */ 546#endif /* I460_LARGE_IO_PAGES */
547 547
548static unsigned long i460_mask_memory (struct agp_bridge_data *bridge, 548static unsigned long i460_mask_memory (struct agp_bridge_data *bridge,
549 unsigned long addr, int type) 549 dma_addr_t addr, int type)
550{ 550{
551 /* Make sure the returned address is a valid GATT entry */ 551 /* Make sure the returned address is a valid GATT entry */
552 return bridge->driver->masks[0].mask 552 return bridge->driver->masks[0].mask
553 | (((addr & ~((1 << I460_IO_PAGE_SHIFT) - 1)) & 0xfffff000) >> 12); 553 | (((addr & ~((1 << I460_IO_PAGE_SHIFT) - 1)) & 0xfffff000) >> 12);
554} 554}
555 555
556static unsigned long i460_page_mask_memory(struct agp_bridge_data *bridge,
557 struct page *page, int type)
558{
559 unsigned long addr = phys_to_gart(page_to_phys(page));
560 return i460_mask_memory(bridge, addr, type);
561}
562
563const struct agp_bridge_driver intel_i460_driver = { 556const struct agp_bridge_driver intel_i460_driver = {
564 .owner = THIS_MODULE, 557 .owner = THIS_MODULE,
565 .aperture_sizes = i460_sizes, 558 .aperture_sizes = i460_sizes,
@@ -569,7 +562,7 @@ const struct agp_bridge_driver intel_i460_driver = {
569 .fetch_size = i460_fetch_size, 562 .fetch_size = i460_fetch_size,
570 .cleanup = i460_cleanup, 563 .cleanup = i460_cleanup,
571 .tlb_flush = i460_tlb_flush, 564 .tlb_flush = i460_tlb_flush,
572 .mask_memory = i460_page_mask_memory, 565 .mask_memory = i460_mask_memory,
573 .masks = i460_masks, 566 .masks = i460_masks,
574 .agp_enable = agp_generic_enable, 567 .agp_enable = agp_generic_enable,
575 .cache_flush = global_cache_flush, 568 .cache_flush = global_cache_flush,
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index c58557790585..1540e693d91e 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -10,6 +10,16 @@
10#include <linux/agp_backend.h> 10#include <linux/agp_backend.h>
11#include "agp.h" 11#include "agp.h"
12 12
13/*
14 * If we have Intel graphics, we're not going to have anything other than
15 * an Intel IOMMU. So make the correct use of the PCI DMA API contingent
16 * on the Intel IOMMU support (CONFIG_DMAR).
17 * Only newer chipsets need to bother with this, of course.
18 */
19#ifdef CONFIG_DMAR
20#define USE_PCI_DMA_API 1
21#endif
22
13#define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588 23#define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588
14#define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a 24#define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a
15#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970 25#define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
@@ -172,6 +182,123 @@ static struct _intel_private {
172 int resource_valid; 182 int resource_valid;
173} intel_private; 183} intel_private;
174 184
185#ifdef USE_PCI_DMA_API
186static int intel_agp_map_page(struct page *page, dma_addr_t *ret)
187{
188 *ret = pci_map_page(intel_private.pcidev, page, 0,
189 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
190 if (pci_dma_mapping_error(intel_private.pcidev, *ret))
191 return -EINVAL;
192 return 0;
193}
194
195static void intel_agp_unmap_page(struct page *page, dma_addr_t dma)
196{
197 pci_unmap_page(intel_private.pcidev, dma,
198 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
199}
200
201static void intel_agp_free_sglist(struct agp_memory *mem)
202{
203 struct sg_table st;
204
205 st.sgl = mem->sg_list;
206 st.orig_nents = st.nents = mem->page_count;
207
208 sg_free_table(&st);
209
210 mem->sg_list = NULL;
211 mem->num_sg = 0;
212}
213
214static int intel_agp_map_memory(struct agp_memory *mem)
215{
216 struct sg_table st;
217 struct scatterlist *sg;
218 int i;
219
220 DBG("try mapping %lu pages\n", (unsigned long)mem->page_count);
221
222 if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL))
223 return -ENOMEM;
224
225 mem->sg_list = sg = st.sgl;
226
227 for (i = 0 ; i < mem->page_count; i++, sg = sg_next(sg))
228 sg_set_page(sg, mem->pages[i], PAGE_SIZE, 0);
229
230 mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list,
231 mem->page_count, PCI_DMA_BIDIRECTIONAL);
232 if (unlikely(!mem->num_sg)) {
233 intel_agp_free_sglist(mem);
234 return -ENOMEM;
235 }
236 return 0;
237}
238
239static void intel_agp_unmap_memory(struct agp_memory *mem)
240{
241 DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count);
242
243 pci_unmap_sg(intel_private.pcidev, mem->sg_list,
244 mem->page_count, PCI_DMA_BIDIRECTIONAL);
245 intel_agp_free_sglist(mem);
246}
247
248static void intel_agp_insert_sg_entries(struct agp_memory *mem,
249 off_t pg_start, int mask_type)
250{
251 struct scatterlist *sg;
252 int i, j;
253
254 j = pg_start;
255
256 WARN_ON(!mem->num_sg);
257
258 if (mem->num_sg == mem->page_count) {
259 for_each_sg(mem->sg_list, sg, mem->page_count, i) {
260 writel(agp_bridge->driver->mask_memory(agp_bridge,
261 sg_dma_address(sg), mask_type),
262 intel_private.gtt+j);
263 j++;
264 }
265 } else {
266 /* sg may merge pages, but we have to seperate
267 * per-page addr for GTT */
268 unsigned int len, m;
269
270 for_each_sg(mem->sg_list, sg, mem->num_sg, i) {
271 len = sg_dma_len(sg) / PAGE_SIZE;
272 for (m = 0; m < len; m++) {
273 writel(agp_bridge->driver->mask_memory(agp_bridge,
274 sg_dma_address(sg) + m * PAGE_SIZE,
275 mask_type),
276 intel_private.gtt+j);
277 j++;
278 }
279 }
280 }
281 readl(intel_private.gtt+j-1);
282}
283
284#else
285
286static void intel_agp_insert_sg_entries(struct agp_memory *mem,
287 off_t pg_start, int mask_type)
288{
289 int i, j;
290
291 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
292 writel(agp_bridge->driver->mask_memory(agp_bridge,
293 page_to_phys(mem->pages[i]), mask_type),
294 intel_private.gtt+j);
295 }
296
297 readl(intel_private.gtt+j-1);
298}
299
300#endif
301
175static int intel_i810_fetch_size(void) 302static int intel_i810_fetch_size(void)
176{ 303{
177 u32 smram_miscc; 304 u32 smram_miscc;
@@ -345,8 +472,7 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
345 global_cache_flush(); 472 global_cache_flush();
346 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 473 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
347 writel(agp_bridge->driver->mask_memory(agp_bridge, 474 writel(agp_bridge->driver->mask_memory(agp_bridge,
348 mem->pages[i], 475 page_to_phys(mem->pages[i]), mask_type),
349 mask_type),
350 intel_private.registers+I810_PTE_BASE+(j*4)); 476 intel_private.registers+I810_PTE_BASE+(j*4));
351 } 477 }
352 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); 478 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
@@ -463,9 +589,8 @@ static void intel_i810_free_by_type(struct agp_memory *curr)
463} 589}
464 590
465static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge, 591static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
466 struct page *page, int type) 592 dma_addr_t addr, int type)
467{ 593{
468 unsigned long addr = phys_to_gart(page_to_phys(page));
469 /* Type checking must be done elsewhere */ 594 /* Type checking must be done elsewhere */
470 return addr | bridge->driver->masks[type].mask; 595 return addr | bridge->driver->masks[type].mask;
471} 596}
@@ -853,7 +978,7 @@ static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start,
853 978
854 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 979 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
855 writel(agp_bridge->driver->mask_memory(agp_bridge, 980 writel(agp_bridge->driver->mask_memory(agp_bridge,
856 mem->pages[i], mask_type), 981 page_to_phys(mem->pages[i]), mask_type),
857 intel_private.registers+I810_PTE_BASE+(j*4)); 982 intel_private.registers+I810_PTE_BASE+(j*4));
858 } 983 }
859 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); 984 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
@@ -1017,6 +1142,12 @@ static int intel_i915_configure(void)
1017 1142
1018 intel_i9xx_setup_flush(); 1143 intel_i9xx_setup_flush();
1019 1144
1145#ifdef USE_PCI_DMA_API
1146 if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(36)))
1147 dev_err(&intel_private.pcidev->dev,
1148 "set gfx device dma mask 36bit failed!\n");
1149#endif
1150
1020 return 0; 1151 return 0;
1021} 1152}
1022 1153
@@ -1041,7 +1172,7 @@ static void intel_i915_chipset_flush(struct agp_bridge_data *bridge)
1041static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start, 1172static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1042 int type) 1173 int type)
1043{ 1174{
1044 int i, j, num_entries; 1175 int num_entries;
1045 void *temp; 1176 void *temp;
1046 int ret = -EINVAL; 1177 int ret = -EINVAL;
1047 int mask_type; 1178 int mask_type;
@@ -1065,7 +1196,7 @@ static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1065 if ((pg_start + mem->page_count) > num_entries) 1196 if ((pg_start + mem->page_count) > num_entries)
1066 goto out_err; 1197 goto out_err;
1067 1198
1068 /* The i915 can't check the GTT for entries since its read only, 1199 /* The i915 can't check the GTT for entries since it's read only;
1069 * depend on the caller to make the correct offset decisions. 1200 * depend on the caller to make the correct offset decisions.
1070 */ 1201 */
1071 1202
@@ -1081,12 +1212,7 @@ static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1081 if (!mem->is_flushed) 1212 if (!mem->is_flushed)
1082 global_cache_flush(); 1213 global_cache_flush();
1083 1214
1084 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 1215 intel_agp_insert_sg_entries(mem, pg_start, mask_type);
1085 writel(agp_bridge->driver->mask_memory(agp_bridge,
1086 mem->pages[i], mask_type), intel_private.gtt+j);
1087 }
1088
1089 readl(intel_private.gtt+j-1);
1090 agp_bridge->driver->tlb_flush(mem); 1216 agp_bridge->driver->tlb_flush(mem);
1091 1217
1092 out: 1218 out:
@@ -1198,9 +1324,8 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
1198 * this conditional. 1324 * this conditional.
1199 */ 1325 */
1200static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, 1326static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
1201 struct page *page, int type) 1327 dma_addr_t addr, int type)
1202{ 1328{
1203 dma_addr_t addr = phys_to_gart(page_to_phys(page));
1204 /* Shift high bits down */ 1329 /* Shift high bits down */
1205 addr |= (addr >> 28) & 0xf0; 1330 addr |= (addr >> 28) & 0xf0;
1206 1331
@@ -2006,6 +2131,12 @@ static const struct agp_bridge_driver intel_915_driver = {
2006 .agp_destroy_pages = agp_generic_destroy_pages, 2131 .agp_destroy_pages = agp_generic_destroy_pages,
2007 .agp_type_to_mask_type = intel_i830_type_to_mask_type, 2132 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
2008 .chipset_flush = intel_i915_chipset_flush, 2133 .chipset_flush = intel_i915_chipset_flush,
2134#ifdef USE_PCI_DMA_API
2135 .agp_map_page = intel_agp_map_page,
2136 .agp_unmap_page = intel_agp_unmap_page,
2137 .agp_map_memory = intel_agp_map_memory,
2138 .agp_unmap_memory = intel_agp_unmap_memory,
2139#endif
2009}; 2140};
2010 2141
2011static const struct agp_bridge_driver intel_i965_driver = { 2142static const struct agp_bridge_driver intel_i965_driver = {
@@ -2034,6 +2165,12 @@ static const struct agp_bridge_driver intel_i965_driver = {
2034 .agp_destroy_pages = agp_generic_destroy_pages, 2165 .agp_destroy_pages = agp_generic_destroy_pages,
2035 .agp_type_to_mask_type = intel_i830_type_to_mask_type, 2166 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
2036 .chipset_flush = intel_i915_chipset_flush, 2167 .chipset_flush = intel_i915_chipset_flush,
2168#ifdef USE_PCI_DMA_API
2169 .agp_map_page = intel_agp_map_page,
2170 .agp_unmap_page = intel_agp_unmap_page,
2171 .agp_map_memory = intel_agp_map_memory,
2172 .agp_unmap_memory = intel_agp_unmap_memory,
2173#endif
2037}; 2174};
2038 2175
2039static const struct agp_bridge_driver intel_7505_driver = { 2176static const struct agp_bridge_driver intel_7505_driver = {
@@ -2088,6 +2225,12 @@ static const struct agp_bridge_driver intel_g33_driver = {
2088 .agp_destroy_pages = agp_generic_destroy_pages, 2225 .agp_destroy_pages = agp_generic_destroy_pages,
2089 .agp_type_to_mask_type = intel_i830_type_to_mask_type, 2226 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
2090 .chipset_flush = intel_i915_chipset_flush, 2227 .chipset_flush = intel_i915_chipset_flush,
2228#ifdef USE_PCI_DMA_API
2229 .agp_map_page = intel_agp_map_page,
2230 .agp_unmap_page = intel_agp_unmap_page,
2231 .agp_map_memory = intel_agp_map_memory,
2232 .agp_unmap_memory = intel_agp_unmap_memory,
2233#endif
2091}; 2234};
2092 2235
2093static int find_gmch(u16 device) 2236static int find_gmch(u16 device)
@@ -2313,15 +2456,6 @@ static int agp_intel_resume(struct pci_dev *pdev)
2313 struct agp_bridge_data *bridge = pci_get_drvdata(pdev); 2456 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2314 int ret_val; 2457 int ret_val;
2315 2458
2316 pci_restore_state(pdev);
2317
2318 /* We should restore our graphics device's config space,
2319 * as host bridge (00:00) resumes before graphics device (02:00),
2320 * then our access to its pci space can work right.
2321 */
2322 if (intel_private.pcidev)
2323 pci_restore_state(intel_private.pcidev);
2324
2325 if (bridge->driver == &intel_generic_driver) 2459 if (bridge->driver == &intel_generic_driver)
2326 intel_configure(); 2460 intel_configure();
2327 else if (bridge->driver == &intel_850_driver) 2461 else if (bridge->driver == &intel_850_driver)
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 263d71dd441c..7e36d2b4f9d4 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -225,7 +225,7 @@ static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type
225 } 225 }
226 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++) {
227 writel(agp_bridge->driver->mask_memory(agp_bridge, 227 writel(agp_bridge->driver->mask_memory(agp_bridge,
228 mem->pages[i], mask_type), 228 page_to_phys(mem->pages[i]), mask_type),
229 agp_bridge->gatt_table+nvidia_private.pg_offset+j); 229 agp_bridge->gatt_table+nvidia_private.pg_offset+j);
230 } 230 }
231 231
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index e077701ae3d9..60ab75104da9 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -32,7 +32,7 @@
32#define AGP8X_MODE (1 << AGP8X_MODE_BIT) 32#define AGP8X_MODE (1 << AGP8X_MODE_BIT)
33 33
34static unsigned long 34static unsigned long
35parisc_agp_mask_memory(struct agp_bridge_data *bridge, unsigned long addr, 35parisc_agp_mask_memory(struct agp_bridge_data *bridge, dma_addr_t addr,
36 int type); 36 int type);
37 37
38static struct _parisc_agp_info { 38static struct _parisc_agp_info {
@@ -189,20 +189,12 @@ parisc_agp_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
189} 189}
190 190
191static unsigned long 191static unsigned long
192parisc_agp_mask_memory(struct agp_bridge_data *bridge, unsigned long addr, 192parisc_agp_mask_memory(struct agp_bridge_data *bridge, dma_addr_t addr,
193 int type) 193 int type)
194{ 194{
195 return SBA_PDIR_VALID_BIT | addr; 195 return SBA_PDIR_VALID_BIT | addr;
196} 196}
197 197
198static unsigned long
199parisc_agp_page_mask_memory(struct agp_bridge_data *bridge, struct page *page,
200 int type)
201{
202 unsigned long addr = phys_to_gart(page_to_phys(page));
203 return SBA_PDIR_VALID_BIT | addr;
204}
205
206static void 198static void
207parisc_agp_enable(struct agp_bridge_data *bridge, u32 mode) 199parisc_agp_enable(struct agp_bridge_data *bridge, u32 mode)
208{ 200{
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index d3ea2e4226b5..0d426ae39c85 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -70,10 +70,9 @@ static void sgi_tioca_tlbflush(struct agp_memory *mem)
70 * entry. 70 * entry.
71 */ 71 */
72static unsigned long 72static unsigned long
73sgi_tioca_mask_memory(struct agp_bridge_data *bridge, 73sgi_tioca_mask_memory(struct agp_bridge_data *bridge, dma_addr_t addr,
74 struct page *page, int type) 74 int type)
75{ 75{
76 unsigned long addr = phys_to_gart(page_to_phys(page));
77 return tioca_physpage_to_gart(addr); 76 return tioca_physpage_to_gart(addr);
78} 77}
79 78
@@ -190,7 +189,8 @@ static int sgi_tioca_insert_memory(struct agp_memory *mem, off_t pg_start,
190 189
191 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 190 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
192 table[j] = 191 table[j] =
193 bridge->driver->mask_memory(bridge, mem->pages[i], 192 bridge->driver->mask_memory(bridge,
193 page_to_phys(mem->pages[i]),
194 mem->type); 194 mem->type);
195 } 195 }
196 196
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index b964a2199329..13acaaf64edb 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -155,7 +155,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
155 /* Create a fake scratch directory */ 155 /* Create a fake scratch directory */
156 for (i = 0; i < 1024; i++) { 156 for (i = 0; i < 1024; i++) {
157 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i); 157 writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i);
158 writel(virt_to_gart(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i); 158 writel(virt_to_phys(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
159 } 159 }
160 160
161 retval = serverworks_create_gatt_pages(value->num_entries / 1024); 161 retval = serverworks_create_gatt_pages(value->num_entries / 1024);
@@ -167,7 +167,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
167 167
168 agp_bridge->gatt_table_real = (u32 *)page_dir.real; 168 agp_bridge->gatt_table_real = (u32 *)page_dir.real;
169 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped; 169 agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
170 agp_bridge->gatt_bus_addr = virt_to_gart(page_dir.real); 170 agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
171 171
172 /* Get the address for the gart region. 172 /* Get the address for the gart region.
173 * This is a bus address even on the alpha, b/c its 173 * This is a bus address even on the alpha, b/c its
@@ -179,7 +179,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
179 179
180 /* Calculate the agp offset */ 180 /* Calculate the agp offset */
181 for (i = 0; i < value->num_entries / 1024; i++) 181 for (i = 0; i < value->num_entries / 1024; i++)
182 writel(virt_to_gart(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i); 182 writel(virt_to_phys(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
183 183
184 return 0; 184 return 0;
185} 185}
@@ -349,7 +349,9 @@ static int serverworks_insert_memory(struct agp_memory *mem,
349 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 349 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
350 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; 350 addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
351 cur_gatt = SVRWRKS_GET_GATT(addr); 351 cur_gatt = SVRWRKS_GET_GATT(addr);
352 writel(agp_bridge->driver->mask_memory(agp_bridge, mem->pages[i], mem->type), cur_gatt+GET_GATT_OFF(addr)); 352 writel(agp_bridge->driver->mask_memory(agp_bridge,
353 page_to_phys(mem->pages[i]), mem->type),
354 cur_gatt+GET_GATT_OFF(addr));
353 } 355 }
354 serverworks_tlbflush(mem); 356 serverworks_tlbflush(mem);
355 return 0; 357 return 0;
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index f192c3b9ad41..20ef1bf5e726 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -7,6 +7,7 @@
7#include <linux/pagemap.h> 7#include <linux/pagemap.h>
8#include <linux/agp_backend.h> 8#include <linux/agp_backend.h>
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/vmalloc.h>
10#include <asm/uninorth.h> 11#include <asm/uninorth.h>
11#include <asm/pci-bridge.h> 12#include <asm/pci-bridge.h>
12#include <asm/prom.h> 13#include <asm/prom.h>
@@ -27,6 +28,8 @@
27static int uninorth_rev; 28static int uninorth_rev;
28static int is_u3; 29static int is_u3;
29 30
31#define DEFAULT_APERTURE_SIZE 256
32#define DEFAULT_APERTURE_STRING "256"
30static char *aperture = NULL; 33static char *aperture = NULL;
31 34
32static int uninorth_fetch_size(void) 35static int uninorth_fetch_size(void)
@@ -55,7 +58,7 @@ static int uninorth_fetch_size(void)
55 58
56 if (!size) { 59 if (!size) {
57 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) 60 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++)
58 if (values[i].size == 32) 61 if (values[i].size == DEFAULT_APERTURE_SIZE)
59 break; 62 break;
60 } 63 }
61 64
@@ -135,7 +138,7 @@ static int uninorth_configure(void)
135 if (is_u3) { 138 if (is_u3) {
136 pci_write_config_dword(agp_bridge->dev, 139 pci_write_config_dword(agp_bridge->dev,
137 UNI_N_CFG_GART_DUMMY_PAGE, 140 UNI_N_CFG_GART_DUMMY_PAGE,
138 agp_bridge->scratch_page_real >> 12); 141 page_to_phys(agp_bridge->scratch_page_page) >> 12);
139 } 142 }
140 143
141 return 0; 144 return 0;
@@ -179,8 +182,6 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start,
179 } 182 }
180 (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]); 183 (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]);
181 mb(); 184 mb();
182 flush_dcache_range((unsigned long)&agp_bridge->gatt_table[pg_start],
183 (unsigned long)&agp_bridge->gatt_table[pg_start + mem->page_count]);
184 185
185 uninorth_tlbflush(mem); 186 uninorth_tlbflush(mem);
186 return 0; 187 return 0;
@@ -224,7 +225,6 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
224 (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); 225 (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000);
225 } 226 }
226 mb(); 227 mb();
227 flush_dcache_range((unsigned long)gp, (unsigned long) &gp[i]);
228 uninorth_tlbflush(mem); 228 uninorth_tlbflush(mem);
229 229
230 return 0; 230 return 0;
@@ -243,7 +243,6 @@ int u3_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
243 for (i = 0; i < mem->page_count; ++i) 243 for (i = 0; i < mem->page_count; ++i)
244 gp[i] = 0; 244 gp[i] = 0;
245 mb(); 245 mb();
246 flush_dcache_range((unsigned long)gp, (unsigned long) &gp[i]);
247 uninorth_tlbflush(mem); 246 uninorth_tlbflush(mem);
248 247
249 return 0; 248 return 0;
@@ -396,6 +395,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
396 int i; 395 int i;
397 void *temp; 396 void *temp;
398 struct page *page; 397 struct page *page;
398 struct page **pages;
399 399
400 /* We can't handle 2 level gatt's */ 400 /* We can't handle 2 level gatt's */
401 if (bridge->driver->size_type == LVL2_APER_SIZE) 401 if (bridge->driver->size_type == LVL2_APER_SIZE)
@@ -424,21 +424,39 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
424 if (table == NULL) 424 if (table == NULL)
425 return -ENOMEM; 425 return -ENOMEM;
426 426
427 pages = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL);
428 if (pages == NULL)
429 goto enomem;
430
427 table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1); 431 table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
428 432
429 for (page = virt_to_page(table); page <= virt_to_page(table_end); page++) 433 for (page = virt_to_page(table), i = 0; page <= virt_to_page(table_end);
434 page++, i++) {
430 SetPageReserved(page); 435 SetPageReserved(page);
436 pages[i] = page;
437 }
431 438
432 bridge->gatt_table_real = (u32 *) table; 439 bridge->gatt_table_real = (u32 *) table;
433 bridge->gatt_table = (u32 *)table; 440 /* Need to clear out any dirty data still sitting in caches */
434 bridge->gatt_bus_addr = virt_to_gart(table); 441 flush_dcache_range((unsigned long)table,
442 (unsigned long)(table_end + PAGE_SIZE));
443 bridge->gatt_table = vmap(pages, (1 << page_order), 0, PAGE_KERNEL_NCG);
444
445 if (bridge->gatt_table == NULL)
446 goto enomem;
447
448 bridge->gatt_bus_addr = virt_to_phys(table);
435 449
436 for (i = 0; i < num_entries; i++) 450 for (i = 0; i < num_entries; i++)
437 bridge->gatt_table[i] = 0; 451 bridge->gatt_table[i] = 0;
438 452
439 flush_dcache_range((unsigned long)table, (unsigned long)table_end);
440
441 return 0; 453 return 0;
454
455enomem:
456 kfree(pages);
457 if (table)
458 free_pages((unsigned long)table, page_order);
459 return -ENOMEM;
442} 460}
443 461
444static int uninorth_free_gatt_table(struct agp_bridge_data *bridge) 462static int uninorth_free_gatt_table(struct agp_bridge_data *bridge)
@@ -456,6 +474,7 @@ static int uninorth_free_gatt_table(struct agp_bridge_data *bridge)
456 * from the table. 474 * from the table.
457 */ 475 */
458 476
477 vunmap(bridge->gatt_table);
459 table = (char *) bridge->gatt_table_real; 478 table = (char *) bridge->gatt_table_real;
460 table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1); 479 table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
461 480
@@ -474,13 +493,11 @@ void null_cache_flush(void)
474 493
475/* Setup function */ 494/* Setup function */
476 495
477static const struct aper_size_info_32 uninorth_sizes[7] = 496static const struct aper_size_info_32 uninorth_sizes[] =
478{ 497{
479#if 0 /* Not sure uninorth supports that high aperture sizes */
480 {256, 65536, 6, 64}, 498 {256, 65536, 6, 64},
481 {128, 32768, 5, 32}, 499 {128, 32768, 5, 32},
482 {64, 16384, 4, 16}, 500 {64, 16384, 4, 16},
483#endif
484 {32, 8192, 3, 8}, 501 {32, 8192, 3, 8},
485 {16, 4096, 2, 4}, 502 {16, 4096, 2, 4},
486 {8, 2048, 1, 2}, 503 {8, 2048, 1, 2},
@@ -491,7 +508,7 @@ static const struct aper_size_info_32 uninorth_sizes[7] =
491 * Not sure that u3 supports that high aperture sizes but it 508 * Not sure that u3 supports that high aperture sizes but it
492 * would strange if it did not :) 509 * would strange if it did not :)
493 */ 510 */
494static const struct aper_size_info_32 u3_sizes[8] = 511static const struct aper_size_info_32 u3_sizes[] =
495{ 512{
496 {512, 131072, 7, 128}, 513 {512, 131072, 7, 128},
497 {256, 65536, 6, 64}, 514 {256, 65536, 6, 64},
@@ -507,7 +524,7 @@ const struct agp_bridge_driver uninorth_agp_driver = {
507 .owner = THIS_MODULE, 524 .owner = THIS_MODULE,
508 .aperture_sizes = (void *)uninorth_sizes, 525 .aperture_sizes = (void *)uninorth_sizes,
509 .size_type = U32_APER_SIZE, 526 .size_type = U32_APER_SIZE,
510 .num_aperture_sizes = 4, 527 .num_aperture_sizes = ARRAY_SIZE(uninorth_sizes),
511 .configure = uninorth_configure, 528 .configure = uninorth_configure,
512 .fetch_size = uninorth_fetch_size, 529 .fetch_size = uninorth_fetch_size,
513 .cleanup = uninorth_cleanup, 530 .cleanup = uninorth_cleanup,
@@ -534,7 +551,7 @@ const struct agp_bridge_driver u3_agp_driver = {
534 .owner = THIS_MODULE, 551 .owner = THIS_MODULE,
535 .aperture_sizes = (void *)u3_sizes, 552 .aperture_sizes = (void *)u3_sizes,
536 .size_type = U32_APER_SIZE, 553 .size_type = U32_APER_SIZE,
537 .num_aperture_sizes = 8, 554 .num_aperture_sizes = ARRAY_SIZE(u3_sizes),
538 .configure = uninorth_configure, 555 .configure = uninorth_configure,
539 .fetch_size = uninorth_fetch_size, 556 .fetch_size = uninorth_fetch_size,
540 .cleanup = uninorth_cleanup, 557 .cleanup = uninorth_cleanup,
@@ -717,7 +734,7 @@ module_param(aperture, charp, 0);
717MODULE_PARM_DESC(aperture, 734MODULE_PARM_DESC(aperture,
718 "Aperture size, must be power of two between 4MB and an\n" 735 "Aperture size, must be power of two between 4MB and an\n"
719 "\t\tupper limit specific to the UniNorth revision.\n" 736 "\t\tupper limit specific to the UniNorth revision.\n"
720 "\t\tDefault: 32M"); 737 "\t\tDefault: " DEFAULT_APERTURE_STRING "M");
721 738
722MODULE_AUTHOR("Ben Herrenschmidt & Paul Mackerras"); 739MODULE_AUTHOR("Ben Herrenschmidt & Paul Mackerras");
723MODULE_LICENSE("GPL"); 740MODULE_LICENSE("GPL");
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index a00869c650d5..ef31738c2cbe 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -2,7 +2,7 @@
2 * Generic /dev/nvram driver for architectures providing some 2 * Generic /dev/nvram driver for architectures providing some
3 * "generic" hooks, that is : 3 * "generic" hooks, that is :
4 * 4 *
5 * nvram_read_byte, nvram_write_byte, nvram_sync 5 * nvram_read_byte, nvram_write_byte, nvram_sync, nvram_get_size
6 * 6 *
7 * Note that an additional hook is supported for PowerMac only 7 * Note that an additional hook is supported for PowerMac only
8 * for getting the nvram "partition" informations 8 * for getting the nvram "partition" informations
@@ -28,6 +28,8 @@
28 28
29#define NVRAM_SIZE 8192 29#define NVRAM_SIZE 8192
30 30
31static ssize_t nvram_len;
32
31static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 33static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
32{ 34{
33 lock_kernel(); 35 lock_kernel();
@@ -36,7 +38,7 @@ static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
36 offset += file->f_pos; 38 offset += file->f_pos;
37 break; 39 break;
38 case 2: 40 case 2:
39 offset += NVRAM_SIZE; 41 offset += nvram_len;
40 break; 42 break;
41 } 43 }
42 if (offset < 0) { 44 if (offset < 0) {
@@ -56,9 +58,9 @@ static ssize_t read_nvram(struct file *file, char __user *buf,
56 58
57 if (!access_ok(VERIFY_WRITE, buf, count)) 59 if (!access_ok(VERIFY_WRITE, buf, count))
58 return -EFAULT; 60 return -EFAULT;
59 if (*ppos >= NVRAM_SIZE) 61 if (*ppos >= nvram_len)
60 return 0; 62 return 0;
61 for (i = *ppos; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count) 63 for (i = *ppos; count > 0 && i < nvram_len; ++i, ++p, --count)
62 if (__put_user(nvram_read_byte(i), p)) 64 if (__put_user(nvram_read_byte(i), p))
63 return -EFAULT; 65 return -EFAULT;
64 *ppos = i; 66 *ppos = i;
@@ -74,9 +76,9 @@ static ssize_t write_nvram(struct file *file, const char __user *buf,
74 76
75 if (!access_ok(VERIFY_READ, buf, count)) 77 if (!access_ok(VERIFY_READ, buf, count))
76 return -EFAULT; 78 return -EFAULT;
77 if (*ppos >= NVRAM_SIZE) 79 if (*ppos >= nvram_len)
78 return 0; 80 return 0;
79 for (i = *ppos; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count) { 81 for (i = *ppos; count > 0 && i < nvram_len; ++i, ++p, --count) {
80 if (__get_user(c, p)) 82 if (__get_user(c, p))
81 return -EFAULT; 83 return -EFAULT;
82 nvram_write_byte(c, i); 84 nvram_write_byte(c, i);
@@ -133,9 +135,20 @@ static struct miscdevice nvram_dev = {
133 135
134int __init nvram_init(void) 136int __init nvram_init(void)
135{ 137{
138 int ret = 0;
139
136 printk(KERN_INFO "Generic non-volatile memory driver v%s\n", 140 printk(KERN_INFO "Generic non-volatile memory driver v%s\n",
137 NVRAM_VERSION); 141 NVRAM_VERSION);
138 return misc_register(&nvram_dev); 142 ret = misc_register(&nvram_dev);
143 if (ret != 0)
144 goto out;
145
146 nvram_len = nvram_get_size();
147 if (nvram_len < 0)
148 nvram_len = NVRAM_SIZE;
149
150out:
151 return ret;
139} 152}
140 153
141void __exit nvram_cleanup(void) 154void __exit nvram_cleanup(void)
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index d97779ef72cb..25ce15bb1c08 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -516,8 +516,6 @@ static void hvc_set_winsz(struct work_struct *work)
516 struct winsize ws; 516 struct winsize ws;
517 517
518 hp = container_of(work, struct hvc_struct, tty_resize); 518 hp = container_of(work, struct hvc_struct, tty_resize);
519 if (!hp)
520 return;
521 519
522 spin_lock_irqsave(&hp->lock, hvc_flags); 520 spin_lock_irqsave(&hp->lock, hvc_flags);
523 if (!hp->tty) { 521 if (!hp->tty) {
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
index c72b994652ac..10be343d6ae7 100644
--- a/drivers/char/hvc_vio.c
+++ b/drivers/char/hvc_vio.c
@@ -120,7 +120,7 @@ static struct vio_driver hvc_vio_driver = {
120 } 120 }
121}; 121};
122 122
123static int hvc_vio_init(void) 123static int __init hvc_vio_init(void)
124{ 124{
125 int rc; 125 int rc;
126 126
@@ -134,7 +134,7 @@ static int hvc_vio_init(void)
134} 134}
135module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */ 135module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
136 136
137static void hvc_vio_exit(void) 137static void __exit hvc_vio_exit(void)
138{ 138{
139 vio_unregister_driver(&hvc_vio_driver); 139 vio_unregister_driver(&hvc_vio_driver);
140} 140}
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 2989056a9e39..793b236c9266 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -1230,11 +1230,12 @@ static struct tty_driver *hvsi_console_device(struct console *console,
1230 1230
1231static int __init hvsi_console_setup(struct console *console, char *options) 1231static int __init hvsi_console_setup(struct console *console, char *options)
1232{ 1232{
1233 struct hvsi_struct *hp = &hvsi_ports[console->index]; 1233 struct hvsi_struct *hp;
1234 int ret; 1234 int ret;
1235 1235
1236 if (console->index < 0 || console->index >= hvsi_count) 1236 if (console->index < 0 || console->index >= hvsi_count)
1237 return -1; 1237 return -1;
1238 hp = &hvsi_ports[console->index];
1238 1239
1239 /* give the FSP a chance to change the baud rate when we re-open */ 1240 /* give the FSP a chance to change the baud rate when we re-open */
1240 hvsi_close_protocol(hp); 1241 hvsi_close_protocol(hp);
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index bdea7e2f94ba..bc33ddc9c97c 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -71,7 +71,7 @@ struct cpu_dbs_info_s {
71 */ 71 */
72 struct mutex timer_mutex; 72 struct mutex timer_mutex;
73}; 73};
74static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 74static DEFINE_PER_CPU(struct cpu_dbs_info_s, cs_cpu_dbs_info);
75 75
76static unsigned int dbs_enable; /* number of CPUs using this policy */ 76static unsigned int dbs_enable; /* number of CPUs using this policy */
77 77
@@ -137,7 +137,7 @@ dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
137 void *data) 137 void *data)
138{ 138{
139 struct cpufreq_freqs *freq = data; 139 struct cpufreq_freqs *freq = data;
140 struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info, 140 struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cs_cpu_dbs_info,
141 freq->cpu); 141 freq->cpu);
142 142
143 struct cpufreq_policy *policy; 143 struct cpufreq_policy *policy;
@@ -297,7 +297,7 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
297 /* we need to re-evaluate prev_cpu_idle */ 297 /* we need to re-evaluate prev_cpu_idle */
298 for_each_online_cpu(j) { 298 for_each_online_cpu(j) {
299 struct cpu_dbs_info_s *dbs_info; 299 struct cpu_dbs_info_s *dbs_info;
300 dbs_info = &per_cpu(cpu_dbs_info, j); 300 dbs_info = &per_cpu(cs_cpu_dbs_info, j);
301 dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 301 dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
302 &dbs_info->prev_cpu_wall); 302 &dbs_info->prev_cpu_wall);
303 if (dbs_tuners_ins.ignore_nice) 303 if (dbs_tuners_ins.ignore_nice)
@@ -387,7 +387,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
387 cputime64_t cur_wall_time, cur_idle_time; 387 cputime64_t cur_wall_time, cur_idle_time;
388 unsigned int idle_time, wall_time; 388 unsigned int idle_time, wall_time;
389 389
390 j_dbs_info = &per_cpu(cpu_dbs_info, j); 390 j_dbs_info = &per_cpu(cs_cpu_dbs_info, j);
391 391
392 cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); 392 cur_idle_time = get_cpu_idle_time(j, &cur_wall_time);
393 393
@@ -521,7 +521,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
521 unsigned int j; 521 unsigned int j;
522 int rc; 522 int rc;
523 523
524 this_dbs_info = &per_cpu(cpu_dbs_info, cpu); 524 this_dbs_info = &per_cpu(cs_cpu_dbs_info, cpu);
525 525
526 switch (event) { 526 switch (event) {
527 case CPUFREQ_GOV_START: 527 case CPUFREQ_GOV_START:
@@ -538,7 +538,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
538 538
539 for_each_cpu(j, policy->cpus) { 539 for_each_cpu(j, policy->cpus) {
540 struct cpu_dbs_info_s *j_dbs_info; 540 struct cpu_dbs_info_s *j_dbs_info;
541 j_dbs_info = &per_cpu(cpu_dbs_info, j); 541 j_dbs_info = &per_cpu(cs_cpu_dbs_info, j);
542 j_dbs_info->cur_policy = policy; 542 j_dbs_info->cur_policy = policy;
543 543
544 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 544 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index d6ba14276bb1..d7a528c80de8 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -78,7 +78,7 @@ struct cpu_dbs_info_s {
78 */ 78 */
79 struct mutex timer_mutex; 79 struct mutex timer_mutex;
80}; 80};
81static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); 81static DEFINE_PER_CPU(struct cpu_dbs_info_s, od_cpu_dbs_info);
82 82
83static unsigned int dbs_enable; /* number of CPUs using this policy */ 83static unsigned int dbs_enable; /* number of CPUs using this policy */
84 84
@@ -149,7 +149,8 @@ static unsigned int powersave_bias_target(struct cpufreq_policy *policy,
149 unsigned int freq_hi, freq_lo; 149 unsigned int freq_hi, freq_lo;
150 unsigned int index = 0; 150 unsigned int index = 0;
151 unsigned int jiffies_total, jiffies_hi, jiffies_lo; 151 unsigned int jiffies_total, jiffies_hi, jiffies_lo;
152 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, policy->cpu); 152 struct cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info,
153 policy->cpu);
153 154
154 if (!dbs_info->freq_table) { 155 if (!dbs_info->freq_table) {
155 dbs_info->freq_lo = 0; 156 dbs_info->freq_lo = 0;
@@ -192,7 +193,7 @@ static unsigned int powersave_bias_target(struct cpufreq_policy *policy,
192 193
193static void ondemand_powersave_bias_init_cpu(int cpu) 194static void ondemand_powersave_bias_init_cpu(int cpu)
194{ 195{
195 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); 196 struct cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
196 dbs_info->freq_table = cpufreq_frequency_get_table(cpu); 197 dbs_info->freq_table = cpufreq_frequency_get_table(cpu);
197 dbs_info->freq_lo = 0; 198 dbs_info->freq_lo = 0;
198} 199}
@@ -297,7 +298,7 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
297 /* we need to re-evaluate prev_cpu_idle */ 298 /* we need to re-evaluate prev_cpu_idle */
298 for_each_online_cpu(j) { 299 for_each_online_cpu(j) {
299 struct cpu_dbs_info_s *dbs_info; 300 struct cpu_dbs_info_s *dbs_info;
300 dbs_info = &per_cpu(cpu_dbs_info, j); 301 dbs_info = &per_cpu(od_cpu_dbs_info, j);
301 dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 302 dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
302 &dbs_info->prev_cpu_wall); 303 &dbs_info->prev_cpu_wall);
303 if (dbs_tuners_ins.ignore_nice) 304 if (dbs_tuners_ins.ignore_nice)
@@ -388,7 +389,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
388 unsigned int load, load_freq; 389 unsigned int load, load_freq;
389 int freq_avg; 390 int freq_avg;
390 391
391 j_dbs_info = &per_cpu(cpu_dbs_info, j); 392 j_dbs_info = &per_cpu(od_cpu_dbs_info, j);
392 393
393 cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); 394 cur_idle_time = get_cpu_idle_time(j, &cur_wall_time);
394 395
@@ -535,7 +536,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
535 unsigned int j; 536 unsigned int j;
536 int rc; 537 int rc;
537 538
538 this_dbs_info = &per_cpu(cpu_dbs_info, cpu); 539 this_dbs_info = &per_cpu(od_cpu_dbs_info, cpu);
539 540
540 switch (event) { 541 switch (event) {
541 case CPUFREQ_GOV_START: 542 case CPUFREQ_GOV_START:
@@ -553,7 +554,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
553 dbs_enable++; 554 dbs_enable++;
554 for_each_cpu(j, policy->cpus) { 555 for_each_cpu(j, policy->cpus) {
555 struct cpu_dbs_info_s *j_dbs_info; 556 struct cpu_dbs_info_s *j_dbs_info;
556 j_dbs_info = &per_cpu(cpu_dbs_info, j); 557 j_dbs_info = &per_cpu(od_cpu_dbs_info, j);
557 j_dbs_info->cur_policy = policy; 558 j_dbs_info->cur_policy = policy;
558 559
559 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 560 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index de566cf0414c..30879df3daea 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -1 +1 @@
obj-y += drm/ obj-y += drm/ vga/
diff --git a/drivers/gpu/vga/Kconfig b/drivers/gpu/vga/Kconfig
new file mode 100644
index 000000000000..790e675b13eb
--- /dev/null
+++ b/drivers/gpu/vga/Kconfig
@@ -0,0 +1,10 @@
1config VGA_ARB
2 bool "VGA Arbitration" if EMBEDDED
3 default y
4 depends on PCI
5 help
6 Some "legacy" VGA devices implemented on PCI typically have the same
7 hard-decoded addresses as they did on ISA. When multiple PCI devices
8 are accessed at same time they need some kind of coordination. Please
9 see Documentation/vgaarbiter.txt for more details. Select this to
10 enable VGA arbiter.
diff --git a/drivers/gpu/vga/Makefile b/drivers/gpu/vga/Makefile
new file mode 100644
index 000000000000..7cc8c1ed645b
--- /dev/null
+++ b/drivers/gpu/vga/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_VGA_ARB) += vgaarb.o
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
new file mode 100644
index 000000000000..1ac0c93603c9
--- /dev/null
+++ b/drivers/gpu/vga/vgaarb.c
@@ -0,0 +1,1205 @@
1/*
2 * vgaarb.c
3 *
4 * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com>
6 * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org>
7 *
8 * Implements the VGA arbitration. For details refer to
9 * Documentation/vgaarbiter.txt
10 */
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/pci.h>
15#include <linux/errno.h>
16#include <linux/init.h>
17#include <linux/list.h>
18#include <linux/sched.h>
19#include <linux/wait.h>
20#include <linux/spinlock.h>
21#include <linux/poll.h>
22#include <linux/miscdevice.h>
23
24#include <linux/uaccess.h>
25
26#include <linux/vgaarb.h>
27
28static void vga_arbiter_notify_clients(void);
29/*
30 * We keep a list of all vga devices in the system to speed
31 * up the various operations of the arbiter
32 */
33struct vga_device {
34 struct list_head list;
35 struct pci_dev *pdev;
36 unsigned int decodes; /* what does it decodes */
37 unsigned int owns; /* what does it owns */
38 unsigned int locks; /* what does it locks */
39 unsigned int io_lock_cnt; /* legacy IO lock count */
40 unsigned int mem_lock_cnt; /* legacy MEM lock count */
41 unsigned int io_norm_cnt; /* normal IO count */
42 unsigned int mem_norm_cnt; /* normal MEM count */
43
44 /* allow IRQ enable/disable hook */
45 void *cookie;
46 void (*irq_set_state)(void *cookie, bool enable);
47 unsigned int (*set_vga_decode)(void *cookie, bool decode);
48};
49
50static LIST_HEAD(vga_list);
51static int vga_count, vga_decode_count;
52static bool vga_arbiter_used;
53static DEFINE_SPINLOCK(vga_lock);
54static DECLARE_WAIT_QUEUE_HEAD(vga_wait_queue);
55
56
57static const char *vga_iostate_to_str(unsigned int iostate)
58{
59 /* Ignore VGA_RSRC_IO and VGA_RSRC_MEM */
60 iostate &= VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM;
61 switch (iostate) {
62 case VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM:
63 return "io+mem";
64 case VGA_RSRC_LEGACY_IO:
65 return "io";
66 case VGA_RSRC_LEGACY_MEM:
67 return "mem";
68 }
69 return "none";
70}
71
72static int vga_str_to_iostate(char *buf, int str_size, int *io_state)
73{
74 /* we could in theory hand out locks on IO and mem
75 * separately to userspace but it can cause deadlocks */
76 if (strncmp(buf, "none", 4) == 0) {
77 *io_state = VGA_RSRC_NONE;
78 return 1;
79 }
80
81 /* XXX We're not chekcing the str_size! */
82 if (strncmp(buf, "io+mem", 6) == 0)
83 goto both;
84 else if (strncmp(buf, "io", 2) == 0)
85 goto both;
86 else if (strncmp(buf, "mem", 3) == 0)
87 goto both;
88 return 0;
89both:
90 *io_state = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM;
91 return 1;
92}
93
94#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
95/* this is only used a cookie - it should not be dereferenced */
96static struct pci_dev *vga_default;
97#endif
98
99static void vga_arb_device_card_gone(struct pci_dev *pdev);
100
101/* Find somebody in our list */
102static struct vga_device *vgadev_find(struct pci_dev *pdev)
103{
104 struct vga_device *vgadev;
105
106 list_for_each_entry(vgadev, &vga_list, list)
107 if (pdev == vgadev->pdev)
108 return vgadev;
109 return NULL;
110}
111
112/* Returns the default VGA device (vgacon's babe) */
113#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
114struct pci_dev *vga_default_device(void)
115{
116 return vga_default;
117}
118#endif
119
120static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
121{
122 if (vgadev->irq_set_state)
123 vgadev->irq_set_state(vgadev->cookie, state);
124}
125
126
127/* If we don't ever use VGA arb we should avoid
128 turning off anything anywhere due to old X servers getting
129 confused about the boot device not being VGA */
130static void vga_check_first_use(void)
131{
132 /* we should inform all GPUs in the system that
133 * VGA arb has occured and to try and disable resources
134 * if they can */
135 if (!vga_arbiter_used) {
136 vga_arbiter_used = true;
137 vga_arbiter_notify_clients();
138 }
139}
140
141static struct vga_device *__vga_tryget(struct vga_device *vgadev,
142 unsigned int rsrc)
143{
144 unsigned int wants, legacy_wants, match;
145 struct vga_device *conflict;
146 unsigned int pci_bits;
147 /* Account for "normal" resources to lock. If we decode the legacy,
148 * counterpart, we need to request it as well
149 */
150 if ((rsrc & VGA_RSRC_NORMAL_IO) &&
151 (vgadev->decodes & VGA_RSRC_LEGACY_IO))
152 rsrc |= VGA_RSRC_LEGACY_IO;
153 if ((rsrc & VGA_RSRC_NORMAL_MEM) &&
154 (vgadev->decodes & VGA_RSRC_LEGACY_MEM))
155 rsrc |= VGA_RSRC_LEGACY_MEM;
156
157 pr_devel("%s: %d\n", __func__, rsrc);
158 pr_devel("%s: owns: %d\n", __func__, vgadev->owns);
159
160 /* Check what resources we need to acquire */
161 wants = rsrc & ~vgadev->owns;
162
163 /* We already own everything, just mark locked & bye bye */
164 if (wants == 0)
165 goto lock_them;
166
167 /* We don't need to request a legacy resource, we just enable
168 * appropriate decoding and go
169 */
170 legacy_wants = wants & VGA_RSRC_LEGACY_MASK;
171 if (legacy_wants == 0)
172 goto enable_them;
173
174 /* Ok, we don't, let's find out how we need to kick off */
175 list_for_each_entry(conflict, &vga_list, list) {
176 unsigned int lwants = legacy_wants;
177 unsigned int change_bridge = 0;
178
179 /* Don't conflict with myself */
180 if (vgadev == conflict)
181 continue;
182
183 /* Check if the architecture allows a conflict between those
184 * 2 devices or if they are on separate domains
185 */
186 if (!vga_conflicts(vgadev->pdev, conflict->pdev))
187 continue;
188
189 /* We have a possible conflict. before we go further, we must
190 * check if we sit on the same bus as the conflicting device.
191 * if we don't, then we must tie both IO and MEM resources
192 * together since there is only a single bit controlling
193 * VGA forwarding on P2P bridges
194 */
195 if (vgadev->pdev->bus != conflict->pdev->bus) {
196 change_bridge = 1;
197 lwants = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM;
198 }
199
200 /* Check if the guy has a lock on the resource. If he does,
201 * return the conflicting entry
202 */
203 if (conflict->locks & lwants)
204 return conflict;
205
206 /* Ok, now check if he owns the resource we want. We don't need
207 * to check "decodes" since it should be impossible to own
208 * own legacy resources you don't decode unless I have a bug
209 * in this code...
210 */
211 WARN_ON(conflict->owns & ~conflict->decodes);
212 match = lwants & conflict->owns;
213 if (!match)
214 continue;
215
216 /* looks like he doesn't have a lock, we can steal
217 * them from him
218 */
219 vga_irq_set_state(conflict, false);
220
221 pci_bits = 0;
222 if (lwants & (VGA_RSRC_LEGACY_MEM|VGA_RSRC_NORMAL_MEM))
223 pci_bits |= PCI_COMMAND_MEMORY;
224 if (lwants & (VGA_RSRC_LEGACY_IO|VGA_RSRC_NORMAL_IO))
225 pci_bits |= PCI_COMMAND_IO;
226
227 pci_set_vga_state(conflict->pdev, false, pci_bits,
228 change_bridge);
229 conflict->owns &= ~lwants;
230 /* If he also owned non-legacy, that is no longer the case */
231 if (lwants & VGA_RSRC_LEGACY_MEM)
232 conflict->owns &= ~VGA_RSRC_NORMAL_MEM;
233 if (lwants & VGA_RSRC_LEGACY_IO)
234 conflict->owns &= ~VGA_RSRC_NORMAL_IO;
235 }
236
237enable_them:
238 /* ok dude, we got it, everybody conflicting has been disabled, let's
239 * enable us. Make sure we don't mark a bit in "owns" that we don't
240 * also have in "decodes". We can lock resources we don't decode but
241 * not own them.
242 */
243 pci_bits = 0;
244 if (wants & (VGA_RSRC_LEGACY_MEM|VGA_RSRC_NORMAL_MEM))
245 pci_bits |= PCI_COMMAND_MEMORY;
246 if (wants & (VGA_RSRC_LEGACY_IO|VGA_RSRC_NORMAL_IO))
247 pci_bits |= PCI_COMMAND_IO;
248 pci_set_vga_state(vgadev->pdev, true, pci_bits, !!(wants & VGA_RSRC_LEGACY_MASK));
249
250 vga_irq_set_state(vgadev, true);
251 vgadev->owns |= (wants & vgadev->decodes);
252lock_them:
253 vgadev->locks |= (rsrc & VGA_RSRC_LEGACY_MASK);
254 if (rsrc & VGA_RSRC_LEGACY_IO)
255 vgadev->io_lock_cnt++;
256 if (rsrc & VGA_RSRC_LEGACY_MEM)
257 vgadev->mem_lock_cnt++;
258 if (rsrc & VGA_RSRC_NORMAL_IO)
259 vgadev->io_norm_cnt++;
260 if (rsrc & VGA_RSRC_NORMAL_MEM)
261 vgadev->mem_norm_cnt++;
262
263 return NULL;
264}
265
266static void __vga_put(struct vga_device *vgadev, unsigned int rsrc)
267{
268 unsigned int old_locks = vgadev->locks;
269
270 pr_devel("%s\n", __func__);
271
272 /* Update our counters, and account for equivalent legacy resources
273 * if we decode them
274 */
275 if ((rsrc & VGA_RSRC_NORMAL_IO) && vgadev->io_norm_cnt > 0) {
276 vgadev->io_norm_cnt--;
277 if (vgadev->decodes & VGA_RSRC_LEGACY_IO)
278 rsrc |= VGA_RSRC_LEGACY_IO;
279 }
280 if ((rsrc & VGA_RSRC_NORMAL_MEM) && vgadev->mem_norm_cnt > 0) {
281 vgadev->mem_norm_cnt--;
282 if (vgadev->decodes & VGA_RSRC_LEGACY_MEM)
283 rsrc |= VGA_RSRC_LEGACY_MEM;
284 }
285 if ((rsrc & VGA_RSRC_LEGACY_IO) && vgadev->io_lock_cnt > 0)
286 vgadev->io_lock_cnt--;
287 if ((rsrc & VGA_RSRC_LEGACY_MEM) && vgadev->mem_lock_cnt > 0)
288 vgadev->mem_lock_cnt--;
289
290 /* Just clear lock bits, we do lazy operations so we don't really
291 * have to bother about anything else at this point
292 */
293 if (vgadev->io_lock_cnt == 0)
294 vgadev->locks &= ~VGA_RSRC_LEGACY_IO;
295 if (vgadev->mem_lock_cnt == 0)
296 vgadev->locks &= ~VGA_RSRC_LEGACY_MEM;
297
298 /* Kick the wait queue in case somebody was waiting if we actually
299 * released something
300 */
301 if (old_locks != vgadev->locks)
302 wake_up_all(&vga_wait_queue);
303}
304
305int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible)
306{
307 struct vga_device *vgadev, *conflict;
308 unsigned long flags;
309 wait_queue_t wait;
310 int rc = 0;
311
312 vga_check_first_use();
313 /* The one who calls us should check for this, but lets be sure... */
314 if (pdev == NULL)
315 pdev = vga_default_device();
316 if (pdev == NULL)
317 return 0;
318
319 for (;;) {
320 spin_lock_irqsave(&vga_lock, flags);
321 vgadev = vgadev_find(pdev);
322 if (vgadev == NULL) {
323 spin_unlock_irqrestore(&vga_lock, flags);
324 rc = -ENODEV;
325 break;
326 }
327 conflict = __vga_tryget(vgadev, rsrc);
328 spin_unlock_irqrestore(&vga_lock, flags);
329 if (conflict == NULL)
330 break;
331
332
333 /* We have a conflict, we wait until somebody kicks the
334 * work queue. Currently we have one work queue that we
335 * kick each time some resources are released, but it would
336 * be fairly easy to have a per device one so that we only
337 * need to attach to the conflicting device
338 */
339 init_waitqueue_entry(&wait, current);
340 add_wait_queue(&vga_wait_queue, &wait);
341 set_current_state(interruptible ?
342 TASK_INTERRUPTIBLE :
343 TASK_UNINTERRUPTIBLE);
344 if (signal_pending(current)) {
345 rc = -EINTR;
346 break;
347 }
348 schedule();
349 remove_wait_queue(&vga_wait_queue, &wait);
350 set_current_state(TASK_RUNNING);
351 }
352 return rc;
353}
354EXPORT_SYMBOL(vga_get);
355
356int vga_tryget(struct pci_dev *pdev, unsigned int rsrc)
357{
358 struct vga_device *vgadev;
359 unsigned long flags;
360 int rc = 0;
361
362 vga_check_first_use();
363
364 /* The one who calls us should check for this, but lets be sure... */
365 if (pdev == NULL)
366 pdev = vga_default_device();
367 if (pdev == NULL)
368 return 0;
369 spin_lock_irqsave(&vga_lock, flags);
370 vgadev = vgadev_find(pdev);
371 if (vgadev == NULL) {
372 rc = -ENODEV;
373 goto bail;
374 }
375 if (__vga_tryget(vgadev, rsrc))
376 rc = -EBUSY;
377bail:
378 spin_unlock_irqrestore(&vga_lock, flags);
379 return rc;
380}
381EXPORT_SYMBOL(vga_tryget);
382
383void vga_put(struct pci_dev *pdev, unsigned int rsrc)
384{
385 struct vga_device *vgadev;
386 unsigned long flags;
387
388 /* The one who calls us should check for this, but lets be sure... */
389 if (pdev == NULL)
390 pdev = vga_default_device();
391 if (pdev == NULL)
392 return;
393 spin_lock_irqsave(&vga_lock, flags);
394 vgadev = vgadev_find(pdev);
395 if (vgadev == NULL)
396 goto bail;
397 __vga_put(vgadev, rsrc);
398bail:
399 spin_unlock_irqrestore(&vga_lock, flags);
400}
401EXPORT_SYMBOL(vga_put);
402
403/*
404 * Currently, we assume that the "initial" setup of the system is
405 * not sane, that is we come up with conflicting devices and let
406 * the arbiter's client decides if devices decodes or not legacy
407 * things.
408 */
409static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
410{
411 struct vga_device *vgadev;
412 unsigned long flags;
413 struct pci_bus *bus;
414 struct pci_dev *bridge;
415 u16 cmd;
416
417 /* Only deal with VGA class devices */
418 if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
419 return false;
420
421 /* Allocate structure */
422 vgadev = kmalloc(sizeof(struct vga_device), GFP_KERNEL);
423 if (vgadev == NULL) {
424 pr_err("vgaarb: failed to allocate pci device\n");
425 /* What to do on allocation failure ? For now, let's
426 * just do nothing, I'm not sure there is anything saner
427 * to be done
428 */
429 return false;
430 }
431
432 memset(vgadev, 0, sizeof(*vgadev));
433
434 /* Take lock & check for duplicates */
435 spin_lock_irqsave(&vga_lock, flags);
436 if (vgadev_find(pdev) != NULL) {
437 BUG_ON(1);
438 goto fail;
439 }
440 vgadev->pdev = pdev;
441
442 /* By default, assume we decode everything */
443 vgadev->decodes = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
444 VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
445
446 /* by default mark it as decoding */
447 vga_decode_count++;
448 /* Mark that we "own" resources based on our enables, we will
449 * clear that below if the bridge isn't forwarding
450 */
451 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
452 if (cmd & PCI_COMMAND_IO)
453 vgadev->owns |= VGA_RSRC_LEGACY_IO;
454 if (cmd & PCI_COMMAND_MEMORY)
455 vgadev->owns |= VGA_RSRC_LEGACY_MEM;
456
457 /* Check if VGA cycles can get down to us */
458 bus = pdev->bus;
459 while (bus) {
460 bridge = bus->self;
461 if (bridge) {
462 u16 l;
463 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
464 &l);
465 if (!(l & PCI_BRIDGE_CTL_VGA)) {
466 vgadev->owns = 0;
467 break;
468 }
469 }
470 bus = bus->parent;
471 }
472
473 /* Deal with VGA default device. Use first enabled one
474 * by default if arch doesn't have it's own hook
475 */
476#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
477 if (vga_default == NULL &&
478 ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK))
479 vga_default = pci_dev_get(pdev);
480#endif
481
482 /* Add to the list */
483 list_add(&vgadev->list, &vga_list);
484 vga_count++;
485 pr_info("vgaarb: device added: PCI:%s,decodes=%s,owns=%s,locks=%s\n",
486 pci_name(pdev),
487 vga_iostate_to_str(vgadev->decodes),
488 vga_iostate_to_str(vgadev->owns),
489 vga_iostate_to_str(vgadev->locks));
490
491 spin_unlock_irqrestore(&vga_lock, flags);
492 return true;
493fail:
494 spin_unlock_irqrestore(&vga_lock, flags);
495 kfree(vgadev);
496 return false;
497}
498
499static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
500{
501 struct vga_device *vgadev;
502 unsigned long flags;
503 bool ret = true;
504
505 spin_lock_irqsave(&vga_lock, flags);
506 vgadev = vgadev_find(pdev);
507 if (vgadev == NULL) {
508 ret = false;
509 goto bail;
510 }
511
512 if (vga_default == pdev) {
513 pci_dev_put(vga_default);
514 vga_default = NULL;
515 }
516
517 if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM))
518 vga_decode_count--;
519
520 /* Remove entry from list */
521 list_del(&vgadev->list);
522 vga_count--;
523 /* Notify userland driver that the device is gone so it discards
524 * it's copies of the pci_dev pointer
525 */
526 vga_arb_device_card_gone(pdev);
527
528 /* Wake up all possible waiters */
529 wake_up_all(&vga_wait_queue);
530bail:
531 spin_unlock_irqrestore(&vga_lock, flags);
532 kfree(vgadev);
533 return ret;
534}
535
536/* this is called with the lock */
537static inline void vga_update_device_decodes(struct vga_device *vgadev,
538 int new_decodes)
539{
540 int old_decodes;
541 struct vga_device *new_vgadev, *conflict;
542
543 old_decodes = vgadev->decodes;
544 vgadev->decodes = new_decodes;
545
546 pr_info("vgaarb: device changed decodes: PCI:%s,olddecodes=%s,decodes=%s:owns=%s\n",
547 pci_name(vgadev->pdev),
548 vga_iostate_to_str(old_decodes),
549 vga_iostate_to_str(vgadev->decodes),
550 vga_iostate_to_str(vgadev->owns));
551
552
553 /* if we own the decodes we should move them along to
554 another card */
555 if ((vgadev->owns & old_decodes) && (vga_count > 1)) {
556 /* set us to own nothing */
557 vgadev->owns &= ~old_decodes;
558 list_for_each_entry(new_vgadev, &vga_list, list) {
559 if ((new_vgadev != vgadev) &&
560 (new_vgadev->decodes & VGA_RSRC_LEGACY_MASK)) {
561 pr_info("vgaarb: transferring owner from PCI:%s to PCI:%s\n", pci_name(vgadev->pdev), pci_name(new_vgadev->pdev));
562 conflict = __vga_tryget(new_vgadev, VGA_RSRC_LEGACY_MASK);
563 if (!conflict)
564 __vga_put(new_vgadev, VGA_RSRC_LEGACY_MASK);
565 break;
566 }
567 }
568 }
569
570 /* change decodes counter */
571 if (old_decodes != new_decodes) {
572 if (new_decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM))
573 vga_decode_count++;
574 else
575 vga_decode_count--;
576 }
577}
578
579void __vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes, bool userspace)
580{
581 struct vga_device *vgadev;
582 unsigned long flags;
583
584 decodes &= VGA_RSRC_LEGACY_MASK;
585
586 spin_lock_irqsave(&vga_lock, flags);
587 vgadev = vgadev_find(pdev);
588 if (vgadev == NULL)
589 goto bail;
590
591 /* don't let userspace futz with kernel driver decodes */
592 if (userspace && vgadev->set_vga_decode)
593 goto bail;
594
595 /* update the device decodes + counter */
596 vga_update_device_decodes(vgadev, decodes);
597
598 /* XXX if somebody is going from "doesn't decode" to "decodes" state
599 * here, additional care must be taken as we may have pending owner
600 * ship of non-legacy region ...
601 */
602bail:
603 spin_unlock_irqrestore(&vga_lock, flags);
604}
605
606void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes)
607{
608 __vga_set_legacy_decoding(pdev, decodes, false);
609}
610EXPORT_SYMBOL(vga_set_legacy_decoding);
611
612/* call with NULL to unregister */
613int vga_client_register(struct pci_dev *pdev, void *cookie,
614 void (*irq_set_state)(void *cookie, bool state),
615 unsigned int (*set_vga_decode)(void *cookie, bool decode))
616{
617 int ret = -1;
618 struct vga_device *vgadev;
619 unsigned long flags;
620
621 spin_lock_irqsave(&vga_lock, flags);
622 vgadev = vgadev_find(pdev);
623 if (!vgadev)
624 goto bail;
625
626 vgadev->irq_set_state = irq_set_state;
627 vgadev->set_vga_decode = set_vga_decode;
628 vgadev->cookie = cookie;
629 ret = 0;
630
631bail:
632 spin_unlock_irqrestore(&vga_lock, flags);
633 return ret;
634
635}
636EXPORT_SYMBOL(vga_client_register);
637
638/*
639 * Char driver implementation
640 *
641 * Semantics is:
642 *
643 * open : open user instance of the arbitrer. by default, it's
644 * attached to the default VGA device of the system.
645 *
646 * close : close user instance, release locks
647 *
648 * read : return a string indicating the status of the target.
649 * an IO state string is of the form {io,mem,io+mem,none},
650 * mc and ic are respectively mem and io lock counts (for
651 * debugging/diagnostic only). "decodes" indicate what the
652 * card currently decodes, "owns" indicates what is currently
653 * enabled on it, and "locks" indicates what is locked by this
654 * card. If the card is unplugged, we get "invalid" then for
655 * card_ID and an -ENODEV error is returned for any command
656 * until a new card is targeted
657 *
658 * "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)"
659 *
660 * write : write a command to the arbiter. List of commands is:
661 *
662 * target <card_ID> : switch target to card <card_ID> (see below)
663 * lock <io_state> : acquires locks on target ("none" is invalid io_state)
664 * trylock <io_state> : non-blocking acquire locks on target
665 * unlock <io_state> : release locks on target
666 * unlock all : release all locks on target held by this user
667 * decodes <io_state> : set the legacy decoding attributes for the card
668 *
669 * poll : event if something change on any card (not just the target)
670 *
671 * card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default"
672 * to go back to the system default card (TODO: not implemented yet).
673 * Currently, only PCI is supported as a prefix, but the userland API may
674 * support other bus types in the future, even if the current kernel
675 * implementation doesn't.
676 *
677 * Note about locks:
678 *
679 * The driver keeps track of which user has what locks on which card. It
680 * supports stacking, like the kernel one. This complexifies the implementation
681 * a bit, but makes the arbiter more tolerant to userspace problems and able
682 * to properly cleanup in all cases when a process dies.
683 * Currently, a max of 16 cards simultaneously can have locks issued from
684 * userspace for a given user (file descriptor instance) of the arbiter.
685 *
686 * If the device is hot-unplugged, there is a hook inside the module to notify
687 * they being added/removed in the system and automatically added/removed in
688 * the arbiter.
689 */
690
691#define MAX_USER_CARDS 16
692#define PCI_INVALID_CARD ((struct pci_dev *)-1UL)
693
694/*
695 * Each user has an array of these, tracking which cards have locks
696 */
697struct vga_arb_user_card {
698 struct pci_dev *pdev;
699 unsigned int mem_cnt;
700 unsigned int io_cnt;
701};
702
703struct vga_arb_private {
704 struct list_head list;
705 struct pci_dev *target;
706 struct vga_arb_user_card cards[MAX_USER_CARDS];
707 spinlock_t lock;
708};
709
710static LIST_HEAD(vga_user_list);
711static DEFINE_SPINLOCK(vga_user_lock);
712
713
714/*
715 * This function gets a string in the format: "PCI:domain:bus:dev.fn" and
716 * returns the respective values. If the string is not in this format,
717 * it returns 0.
718 */
719static int vga_pci_str_to_vars(char *buf, int count, unsigned int *domain,
720 unsigned int *bus, unsigned int *devfn)
721{
722 int n;
723 unsigned int slot, func;
724
725
726 n = sscanf(buf, "PCI:%x:%x:%x.%x", domain, bus, &slot, &func);
727 if (n != 4)
728 return 0;
729
730 *devfn = PCI_DEVFN(slot, func);
731
732 return 1;
733}
734
735static ssize_t vga_arb_read(struct file *file, char __user * buf,
736 size_t count, loff_t *ppos)
737{
738 struct vga_arb_private *priv = file->private_data;
739 struct vga_device *vgadev;
740 struct pci_dev *pdev;
741 unsigned long flags;
742 size_t len;
743 int rc;
744 char *lbuf;
745
746 lbuf = kmalloc(1024, GFP_KERNEL);
747 if (lbuf == NULL)
748 return -ENOMEM;
749
750 /* Shields against vga_arb_device_card_gone (pci_dev going
751 * away), and allows access to vga list
752 */
753 spin_lock_irqsave(&vga_lock, flags);
754
755 /* If we are targetting the default, use it */
756 pdev = priv->target;
757 if (pdev == NULL || pdev == PCI_INVALID_CARD) {
758 spin_unlock_irqrestore(&vga_lock, flags);
759 len = sprintf(lbuf, "invalid");
760 goto done;
761 }
762
763 /* Find card vgadev structure */
764 vgadev = vgadev_find(pdev);
765 if (vgadev == NULL) {
766 /* Wow, it's not in the list, that shouldn't happen,
767 * let's fix us up and return invalid card
768 */
769 if (pdev == priv->target)
770 vga_arb_device_card_gone(pdev);
771 spin_unlock_irqrestore(&vga_lock, flags);
772 len = sprintf(lbuf, "invalid");
773 goto done;
774 }
775
776 /* Fill the buffer with infos */
777 len = snprintf(lbuf, 1024,
778 "count:%d,PCI:%s,decodes=%s,owns=%s,locks=%s(%d:%d)\n",
779 vga_decode_count, pci_name(pdev),
780 vga_iostate_to_str(vgadev->decodes),
781 vga_iostate_to_str(vgadev->owns),
782 vga_iostate_to_str(vgadev->locks),
783 vgadev->io_lock_cnt, vgadev->mem_lock_cnt);
784
785 spin_unlock_irqrestore(&vga_lock, flags);
786done:
787
788 /* Copy that to user */
789 if (len > count)
790 len = count;
791 rc = copy_to_user(buf, lbuf, len);
792 kfree(lbuf);
793 if (rc)
794 return -EFAULT;
795 return len;
796}
797
798/*
799 * TODO: To avoid parsing inside kernel and to improve the speed we may
800 * consider use ioctl here
801 */
802static ssize_t vga_arb_write(struct file *file, const char __user * buf,
803 size_t count, loff_t *ppos)
804{
805 struct vga_arb_private *priv = file->private_data;
806 struct vga_arb_user_card *uc = NULL;
807 struct pci_dev *pdev;
808
809 unsigned int io_state;
810
811 char *kbuf, *curr_pos;
812 size_t remaining = count;
813
814 int ret_val;
815 int i;
816
817
818 kbuf = kmalloc(count + 1, GFP_KERNEL);
819 if (!kbuf)
820 return -ENOMEM;
821
822 if (copy_from_user(kbuf, buf, count)) {
823 kfree(kbuf);
824 return -EFAULT;
825 }
826 curr_pos = kbuf;
827 kbuf[count] = '\0'; /* Just to make sure... */
828
829 if (strncmp(curr_pos, "lock ", 5) == 0) {
830 curr_pos += 5;
831 remaining -= 5;
832
833 pr_devel("client 0x%p called 'lock'\n", priv);
834
835 if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) {
836 ret_val = -EPROTO;
837 goto done;
838 }
839 if (io_state == VGA_RSRC_NONE) {
840 ret_val = -EPROTO;
841 goto done;
842 }
843
844 pdev = priv->target;
845 if (priv->target == NULL) {
846 ret_val = -ENODEV;
847 goto done;
848 }
849
850 vga_get_uninterruptible(pdev, io_state);
851
852 /* Update the client's locks lists... */
853 for (i = 0; i < MAX_USER_CARDS; i++) {
854 if (priv->cards[i].pdev == pdev) {
855 if (io_state & VGA_RSRC_LEGACY_IO)
856 priv->cards[i].io_cnt++;
857 if (io_state & VGA_RSRC_LEGACY_MEM)
858 priv->cards[i].mem_cnt++;
859 break;
860 }
861 }
862
863 ret_val = count;
864 goto done;
865 } else if (strncmp(curr_pos, "unlock ", 7) == 0) {
866 curr_pos += 7;
867 remaining -= 7;
868
869 pr_devel("client 0x%p called 'unlock'\n", priv);
870
871 if (strncmp(curr_pos, "all", 3) == 0)
872 io_state = VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM;
873 else {
874 if (!vga_str_to_iostate
875 (curr_pos, remaining, &io_state)) {
876 ret_val = -EPROTO;
877 goto done;
878 }
879 /* TODO: Add this?
880 if (io_state == VGA_RSRC_NONE) {
881 ret_val = -EPROTO;
882 goto done;
883 }
884 */
885 }
886
887 pdev = priv->target;
888 if (priv->target == NULL) {
889 ret_val = -ENODEV;
890 goto done;
891 }
892 for (i = 0; i < MAX_USER_CARDS; i++) {
893 if (priv->cards[i].pdev == pdev)
894 uc = &priv->cards[i];
895 }
896
897 if (!uc)
898 return -EINVAL;
899
900 if (io_state & VGA_RSRC_LEGACY_IO && uc->io_cnt == 0)
901 return -EINVAL;
902
903 if (io_state & VGA_RSRC_LEGACY_MEM && uc->mem_cnt == 0)
904 return -EINVAL;
905
906 vga_put(pdev, io_state);
907
908 if (io_state & VGA_RSRC_LEGACY_IO)
909 uc->io_cnt--;
910 if (io_state & VGA_RSRC_LEGACY_MEM)
911 uc->mem_cnt--;
912
913 ret_val = count;
914 goto done;
915 } else if (strncmp(curr_pos, "trylock ", 8) == 0) {
916 curr_pos += 8;
917 remaining -= 8;
918
919 pr_devel("client 0x%p called 'trylock'\n", priv);
920
921 if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) {
922 ret_val = -EPROTO;
923 goto done;
924 }
925 /* TODO: Add this?
926 if (io_state == VGA_RSRC_NONE) {
927 ret_val = -EPROTO;
928 goto done;
929 }
930 */
931
932 pdev = priv->target;
933 if (priv->target == NULL) {
934 ret_val = -ENODEV;
935 goto done;
936 }
937
938 if (vga_tryget(pdev, io_state)) {
939 /* Update the client's locks lists... */
940 for (i = 0; i < MAX_USER_CARDS; i++) {
941 if (priv->cards[i].pdev == pdev) {
942 if (io_state & VGA_RSRC_LEGACY_IO)
943 priv->cards[i].io_cnt++;
944 if (io_state & VGA_RSRC_LEGACY_MEM)
945 priv->cards[i].mem_cnt++;
946 break;
947 }
948 }
949 ret_val = count;
950 goto done;
951 } else {
952 ret_val = -EBUSY;
953 goto done;
954 }
955
956 } else if (strncmp(curr_pos, "target ", 7) == 0) {
957 unsigned int domain, bus, devfn;
958 struct vga_device *vgadev;
959
960 curr_pos += 7;
961 remaining -= 7;
962 pr_devel("client 0x%p called 'target'\n", priv);
963 /* if target is default */
964 if (!strncmp(buf, "default", 7))
965 pdev = pci_dev_get(vga_default_device());
966 else {
967 if (!vga_pci_str_to_vars(curr_pos, remaining,
968 &domain, &bus, &devfn)) {
969 ret_val = -EPROTO;
970 goto done;
971 }
972
973 pdev = pci_get_bus_and_slot(bus, devfn);
974 if (!pdev) {
975 pr_info("vgaarb: invalid PCI address!\n");
976 ret_val = -ENODEV;
977 goto done;
978 }
979 }
980
981 vgadev = vgadev_find(pdev);
982 if (vgadev == NULL) {
983 pr_info("vgaarb: this pci device is not a vga device\n");
984 pci_dev_put(pdev);
985 ret_val = -ENODEV;
986 goto done;
987 }
988
989 priv->target = pdev;
990 for (i = 0; i < MAX_USER_CARDS; i++) {
991 if (priv->cards[i].pdev == pdev)
992 break;
993 if (priv->cards[i].pdev == NULL) {
994 priv->cards[i].pdev = pdev;
995 priv->cards[i].io_cnt = 0;
996 priv->cards[i].mem_cnt = 0;
997 break;
998 }
999 }
1000 if (i == MAX_USER_CARDS) {
1001 pr_err("vgaarb: maximum user cards number reached!\n");
1002 pci_dev_put(pdev);
1003 /* XXX: which value to return? */
1004 ret_val = -ENOMEM;
1005 goto done;
1006 }
1007
1008 ret_val = count;
1009 pci_dev_put(pdev);
1010 goto done;
1011
1012
1013 } else if (strncmp(curr_pos, "decodes ", 8) == 0) {
1014 curr_pos += 8;
1015 remaining -= 8;
1016 pr_devel("vgaarb: client 0x%p called 'decodes'\n", priv);
1017
1018 if (!vga_str_to_iostate(curr_pos, remaining, &io_state)) {
1019 ret_val = -EPROTO;
1020 goto done;
1021 }
1022 pdev = priv->target;
1023 if (priv->target == NULL) {
1024 ret_val = -ENODEV;
1025 goto done;
1026 }
1027
1028 __vga_set_legacy_decoding(pdev, io_state, true);
1029 ret_val = count;
1030 goto done;
1031 }
1032 /* If we got here, the message written is not part of the protocol! */
1033 kfree(kbuf);
1034 return -EPROTO;
1035
1036done:
1037 kfree(kbuf);
1038 return ret_val;
1039}
1040
1041static unsigned int vga_arb_fpoll(struct file *file, poll_table * wait)
1042{
1043 struct vga_arb_private *priv = file->private_data;
1044
1045 pr_devel("%s\n", __func__);
1046
1047 if (priv == NULL)
1048 return -ENODEV;
1049 poll_wait(file, &vga_wait_queue, wait);
1050 return POLLIN;
1051}
1052
1053static int vga_arb_open(struct inode *inode, struct file *file)
1054{
1055 struct vga_arb_private *priv;
1056 unsigned long flags;
1057
1058 pr_devel("%s\n", __func__);
1059
1060 priv = kmalloc(sizeof(struct vga_arb_private), GFP_KERNEL);
1061 if (priv == NULL)
1062 return -ENOMEM;
1063 memset(priv, 0, sizeof(*priv));
1064 spin_lock_init(&priv->lock);
1065 file->private_data = priv;
1066
1067 spin_lock_irqsave(&vga_user_lock, flags);
1068 list_add(&priv->list, &vga_user_list);
1069 spin_unlock_irqrestore(&vga_user_lock, flags);
1070
1071 /* Set the client' lists of locks */
1072 priv->target = vga_default_device(); /* Maybe this is still null! */
1073 priv->cards[0].pdev = priv->target;
1074 priv->cards[0].io_cnt = 0;
1075 priv->cards[0].mem_cnt = 0;
1076
1077
1078 return 0;
1079}
1080
1081static int vga_arb_release(struct inode *inode, struct file *file)
1082{
1083 struct vga_arb_private *priv = file->private_data;
1084 struct vga_arb_user_card *uc;
1085 unsigned long flags;
1086 int i;
1087
1088 pr_devel("%s\n", __func__);
1089
1090 if (priv == NULL)
1091 return -ENODEV;
1092
1093 spin_lock_irqsave(&vga_user_lock, flags);
1094 list_del(&priv->list);
1095 for (i = 0; i < MAX_USER_CARDS; i++) {
1096 uc = &priv->cards[i];
1097 if (uc->pdev == NULL)
1098 continue;
1099 pr_devel("uc->io_cnt == %d, uc->mem_cnt == %d\n",
1100 uc->io_cnt, uc->mem_cnt);
1101 while (uc->io_cnt--)
1102 vga_put(uc->pdev, VGA_RSRC_LEGACY_IO);
1103 while (uc->mem_cnt--)
1104 vga_put(uc->pdev, VGA_RSRC_LEGACY_MEM);
1105 }
1106 spin_unlock_irqrestore(&vga_user_lock, flags);
1107
1108 kfree(priv);
1109
1110 return 0;
1111}
1112
1113static void vga_arb_device_card_gone(struct pci_dev *pdev)
1114{
1115}
1116
1117/*
1118 * callback any registered clients to let them know we have a
1119 * change in VGA cards
1120 */
1121static void vga_arbiter_notify_clients(void)
1122{
1123 struct vga_device *vgadev;
1124 unsigned long flags;
1125 uint32_t new_decodes;
1126 bool new_state;
1127
1128 if (!vga_arbiter_used)
1129 return;
1130
1131 spin_lock_irqsave(&vga_lock, flags);
1132 list_for_each_entry(vgadev, &vga_list, list) {
1133 if (vga_count > 1)
1134 new_state = false;
1135 else
1136 new_state = true;
1137 if (vgadev->set_vga_decode) {
1138 new_decodes = vgadev->set_vga_decode(vgadev->cookie, new_state);
1139 vga_update_device_decodes(vgadev, new_decodes);
1140 }
1141 }
1142 spin_unlock_irqrestore(&vga_lock, flags);
1143}
1144
1145static int pci_notify(struct notifier_block *nb, unsigned long action,
1146 void *data)
1147{
1148 struct device *dev = data;
1149 struct pci_dev *pdev = to_pci_dev(dev);
1150 bool notify = false;
1151
1152 pr_devel("%s\n", __func__);
1153
1154 /* For now we're only intereted in devices added and removed. I didn't
1155 * test this thing here, so someone needs to double check for the
1156 * cases of hotplugable vga cards. */
1157 if (action == BUS_NOTIFY_ADD_DEVICE)
1158 notify = vga_arbiter_add_pci_device(pdev);
1159 else if (action == BUS_NOTIFY_DEL_DEVICE)
1160 notify = vga_arbiter_del_pci_device(pdev);
1161
1162 if (notify)
1163 vga_arbiter_notify_clients();
1164 return 0;
1165}
1166
1167static struct notifier_block pci_notifier = {
1168 .notifier_call = pci_notify,
1169};
1170
1171static const struct file_operations vga_arb_device_fops = {
1172 .read = vga_arb_read,
1173 .write = vga_arb_write,
1174 .poll = vga_arb_fpoll,
1175 .open = vga_arb_open,
1176 .release = vga_arb_release,
1177};
1178
1179static struct miscdevice vga_arb_device = {
1180 MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops
1181};
1182
1183static int __init vga_arb_device_init(void)
1184{
1185 int rc;
1186 struct pci_dev *pdev;
1187
1188 rc = misc_register(&vga_arb_device);
1189 if (rc < 0)
1190 pr_err("vgaarb: error %d registering device\n", rc);
1191
1192 bus_register_notifier(&pci_bus_type, &pci_notifier);
1193
1194 /* We add all pci devices satisfying vga class in the arbiter by
1195 * default */
1196 pdev = NULL;
1197 while ((pdev =
1198 pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
1199 PCI_ANY_ID, pdev)) != NULL)
1200 vga_arbiter_add_pci_device(pdev);
1201
1202 pr_info("vgaarb: loaded\n");
1203 return rc;
1204}
1205subsys_initcall(vga_arb_device_init);
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c
index dbfeda42b940..248219a89a68 100644
--- a/drivers/ide/at91_ide.c
+++ b/drivers/ide/at91_ide.c
@@ -29,9 +29,7 @@
29 29
30#include <mach/board.h> 30#include <mach/board.h>
31#include <mach/gpio.h> 31#include <mach/gpio.h>
32#include <mach/at91sam9263.h>
33#include <mach/at91sam9_smc.h> 32#include <mach/at91sam9_smc.h>
34#include <mach/at91sam9263_matrix.h>
35 33
36#define DRV_NAME "at91_ide" 34#define DRV_NAME "at91_ide"
37 35
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6a9a769bffc1..b79ca419d8d9 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/seq_file.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
34#include <linux/interrupt.h> 35#include <linux/interrupt.h>
35#include <linux/errno.h> 36#include <linux/errno.h>
@@ -1146,8 +1147,8 @@ void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf)
1146 ide_debug_log(IDE_DBG_PROBE, "curspeed: %u, maxspeed: %u", 1147 ide_debug_log(IDE_DBG_PROBE, "curspeed: %u, maxspeed: %u",
1147 curspeed, maxspeed); 1148 curspeed, maxspeed);
1148 1149
1149 cd->current_speed = (curspeed + (176/2)) / 176; 1150 cd->current_speed = DIV_ROUND_CLOSEST(curspeed, 176);
1150 cd->max_speed = (maxspeed + (176/2)) / 176; 1151 cd->max_speed = DIV_ROUND_CLOSEST(maxspeed, 176);
1151} 1152}
1152 1153
1153#define IDE_CD_CAPABILITIES \ 1154#define IDE_CD_CAPABILITIES \
@@ -1389,19 +1390,30 @@ static sector_t ide_cdrom_capacity(ide_drive_t *drive)
1389 return capacity * sectors_per_frame; 1390 return capacity * sectors_per_frame;
1390} 1391}
1391 1392
1392static int proc_idecd_read_capacity(char *page, char **start, off_t off, 1393static int idecd_capacity_proc_show(struct seq_file *m, void *v)
1393 int count, int *eof, void *data)
1394{ 1394{
1395 ide_drive_t *drive = data; 1395 ide_drive_t *drive = m->private;
1396 int len;
1397 1396
1398 len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); 1397 seq_printf(m, "%llu\n", (long long)ide_cdrom_capacity(drive));
1399 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1398 return 0;
1399}
1400
1401static int idecd_capacity_proc_open(struct inode *inode, struct file *file)
1402{
1403 return single_open(file, idecd_capacity_proc_show, PDE(inode)->data);
1400} 1404}
1401 1405
1406static const struct file_operations idecd_capacity_proc_fops = {
1407 .owner = THIS_MODULE,
1408 .open = idecd_capacity_proc_open,
1409 .read = seq_read,
1410 .llseek = seq_lseek,
1411 .release = single_release,
1412};
1413
1402static ide_proc_entry_t idecd_proc[] = { 1414static ide_proc_entry_t idecd_proc[] = {
1403 { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, 1415 { "capacity", S_IFREG|S_IRUGO, &idecd_capacity_proc_fops },
1404 { NULL, 0, NULL, NULL } 1416 {}
1405}; 1417};
1406 1418
1407static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive) 1419static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive)
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 19f263bf0a9e..60b0590ccc9c 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -1,5 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/seq_file.h>
3 4
4#include "ide-disk.h" 5#include "ide-disk.h"
5 6
@@ -37,77 +38,117 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
37 return ide_raw_taskfile(drive, &cmd, buf, 1); 38 return ide_raw_taskfile(drive, &cmd, buf, 1);
38} 39}
39 40
40static int proc_idedisk_read_cache 41static int idedisk_cache_proc_show(struct seq_file *m, void *v)
41 (char *page, char **start, off_t off, int count, int *eof, void *data)
42{ 42{
43 ide_drive_t *drive = (ide_drive_t *) data; 43 ide_drive_t *drive = (ide_drive_t *) m->private;
44 char *out = page;
45 int len;
46 44
47 if (drive->dev_flags & IDE_DFLAG_ID_READ) 45 if (drive->dev_flags & IDE_DFLAG_ID_READ)
48 len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); 46 seq_printf(m, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2);
49 else 47 else
50 len = sprintf(out, "(none)\n"); 48 seq_printf(m, "(none)\n");
49 return 0;
50}
51 51
52 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 52static int idedisk_cache_proc_open(struct inode *inode, struct file *file)
53{
54 return single_open(file, idedisk_cache_proc_show, PDE(inode)->data);
53} 55}
54 56
55static int proc_idedisk_read_capacity 57static const struct file_operations idedisk_cache_proc_fops = {
56 (char *page, char **start, off_t off, int count, int *eof, void *data) 58 .owner = THIS_MODULE,
59 .open = idedisk_cache_proc_open,
60 .read = seq_read,
61 .llseek = seq_lseek,
62 .release = single_release,
63};
64
65static int idedisk_capacity_proc_show(struct seq_file *m, void *v)
57{ 66{
58 ide_drive_t*drive = (ide_drive_t *)data; 67 ide_drive_t*drive = (ide_drive_t *)m->private;
59 int len;
60 68
61 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive)); 69 seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive));
70 return 0;
71}
62 72
63 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 73static int idedisk_capacity_proc_open(struct inode *inode, struct file *file)
74{
75 return single_open(file, idedisk_capacity_proc_show, PDE(inode)->data);
64} 76}
65 77
66static int proc_idedisk_read_smart(char *page, char **start, off_t off, 78static const struct file_operations idedisk_capacity_proc_fops = {
67 int count, int *eof, void *data, u8 sub_cmd) 79 .owner = THIS_MODULE,
80 .open = idedisk_capacity_proc_open,
81 .read = seq_read,
82 .llseek = seq_lseek,
83 .release = single_release,
84};
85
86static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 sub_cmd)
68{ 87{
69 ide_drive_t *drive = (ide_drive_t *)data; 88 u8 *buf;
70 int len = 0, i = 0; 89
90 buf = kmalloc(SECTOR_SIZE, GFP_KERNEL);
91 if (!buf)
92 return -ENOMEM;
71 93
72 (void)smart_enable(drive); 94 (void)smart_enable(drive);
73 95
74 if (get_smart_data(drive, page, sub_cmd) == 0) { 96 if (get_smart_data(drive, buf, sub_cmd) == 0) {
75 unsigned short *val = (unsigned short *) page; 97 __le16 *val = (__le16 *)buf;
76 char *out = (char *)val + SECTOR_SIZE; 98 int i;
77 99
78 page = out; 100 for (i = 0; i < SECTOR_SIZE / 2; i++) {
79 do { 101 seq_printf(m, "%04x%c", le16_to_cpu(val[i]),
80 out += sprintf(out, "%04x%c", le16_to_cpu(*val), 102 (i % 8) == 7 ? '\n' : ' ');
81 (++i & 7) ? ' ' : '\n'); 103 }
82 val += 1;
83 } while (i < SECTOR_SIZE / 2);
84 len = out - page;
85 } 104 }
105 kfree(buf);
106 return 0;
107}
86 108
87 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 109static int idedisk_sv_proc_show(struct seq_file *m, void *v)
110{
111 return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES);
88} 112}
89 113
90static int proc_idedisk_read_sv 114static int idedisk_sv_proc_open(struct inode *inode, struct file *file)
91 (char *page, char **start, off_t off, int count, int *eof, void *data)
92{ 115{
93 return proc_idedisk_read_smart(page, start, off, count, eof, data, 116 return single_open(file, idedisk_sv_proc_show, PDE(inode)->data);
94 ATA_SMART_READ_VALUES);
95} 117}
96 118
97static int proc_idedisk_read_st 119static const struct file_operations idedisk_sv_proc_fops = {
98 (char *page, char **start, off_t off, int count, int *eof, void *data) 120 .owner = THIS_MODULE,
121 .open = idedisk_sv_proc_open,
122 .read = seq_read,
123 .llseek = seq_lseek,
124 .release = single_release,
125};
126
127static int idedisk_st_proc_show(struct seq_file *m, void *v)
99{ 128{
100 return proc_idedisk_read_smart(page, start, off, count, eof, data, 129 return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS);
101 ATA_SMART_READ_THRESHOLDS);
102} 130}
103 131
132static int idedisk_st_proc_open(struct inode *inode, struct file *file)
133{
134 return single_open(file, idedisk_st_proc_show, PDE(inode)->data);
135}
136
137static const struct file_operations idedisk_st_proc_fops = {
138 .owner = THIS_MODULE,
139 .open = idedisk_st_proc_open,
140 .read = seq_read,
141 .llseek = seq_lseek,
142 .release = single_release,
143};
144
104ide_proc_entry_t ide_disk_proc[] = { 145ide_proc_entry_t ide_disk_proc[] = {
105 { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, 146 { "cache", S_IFREG|S_IRUGO, &idedisk_cache_proc_fops },
106 { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, 147 { "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops },
107 { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 148 { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops },
108 { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL }, 149 { "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops },
109 { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL }, 150 { "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops },
110 { NULL, 0, NULL, NULL } 151 {}
111}; 152};
112 153
113ide_devset_rw_field(bios_cyl, bios_cyl); 154ide_devset_rw_field(bios_cyl, bios_cyl);
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index fcd4d8153df5..d711d9b883de 100644
--- a/drivers/ide/ide-floppy_proc.c
+++ b/drivers/ide/ide-floppy_proc.c
@@ -1,22 +1,34 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/seq_file.h>
3 4
4#include "ide-floppy.h" 5#include "ide-floppy.h"
5 6
6static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, 7static int idefloppy_capacity_proc_show(struct seq_file *m, void *v)
7 int count, int *eof, void *data)
8{ 8{
9 ide_drive_t*drive = (ide_drive_t *)data; 9 ide_drive_t*drive = (ide_drive_t *)m->private;
10 int len;
11 10
12 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive)); 11 seq_printf(m, "%llu\n", (long long)ide_gd_capacity(drive));
13 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 12 return 0;
14} 13}
15 14
15static int idefloppy_capacity_proc_open(struct inode *inode, struct file *file)
16{
17 return single_open(file, idefloppy_capacity_proc_show, PDE(inode)->data);
18}
19
20static const struct file_operations idefloppy_capacity_proc_fops = {
21 .owner = THIS_MODULE,
22 .open = idefloppy_capacity_proc_open,
23 .read = seq_read,
24 .llseek = seq_lseek,
25 .release = single_release,
26};
27
16ide_proc_entry_t ide_floppy_proc[] = { 28ide_proc_entry_t ide_floppy_proc[] = {
17 { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, 29 { "capacity", S_IFREG|S_IRUGO, &idefloppy_capacity_proc_fops },
18 { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 30 { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops },
19 { NULL, 0, NULL, NULL } 31 {}
20}; 32};
21 33
22ide_devset_rw_field(bios_cyl, bios_cyl); 34ide_devset_rw_field(bios_cyl, bios_cyl);
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index e246d3d3fbcc..d3440b5010a5 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -167,6 +167,8 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
167 err = -EINVAL; 167 err = -EINVAL;
168 goto abort; 168 goto abort;
169 } 169 }
170
171 cmd.tf_flags |= IDE_TFLAG_SET_XFER;
170 } 172 }
171 173
172 err = ide_raw_taskfile(drive, &cmd, buf, args[3]); 174 err = ide_raw_taskfile(drive, &cmd, buf, args[3]);
@@ -174,12 +176,6 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
174 args[0] = tf->status; 176 args[0] = tf->status;
175 args[1] = tf->error; 177 args[1] = tf->error;
176 args[2] = tf->nsect; 178 args[2] = tf->nsect;
177
178 if (!err && xfer_rate) {
179 /* active-retuning-calls future */
180 ide_set_xfer_rate(drive, xfer_rate);
181 ide_driveid_update(drive);
182 }
183abort: 179abort:
184 if (copy_to_user((void __user *)arg, &args, 4)) 180 if (copy_to_user((void __user *)arg, &args, 4))
185 err = -EFAULT; 181 err = -EFAULT;
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 2892b242bbe1..222c1ef65fb9 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -102,8 +102,8 @@ EXPORT_SYMBOL(ide_fixstring);
102 * setting a timer to wake up at half second intervals thereafter, 102 * setting a timer to wake up at half second intervals thereafter,
103 * until timeout is achieved, before timing out. 103 * until timeout is achieved, before timing out.
104 */ 104 */
105static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, 105int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad,
106 unsigned long timeout, u8 *rstat) 106 unsigned long timeout, u8 *rstat)
107{ 107{
108 ide_hwif_t *hwif = drive->hwif; 108 ide_hwif_t *hwif = drive->hwif;
109 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 109 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
@@ -292,6 +292,7 @@ static const char *nien_quirk_list[] = {
292 "QUANTUM FIREBALLP KX27.3", 292 "QUANTUM FIREBALLP KX27.3",
293 "QUANTUM FIREBALLP LM20.4", 293 "QUANTUM FIREBALLP LM20.4",
294 "QUANTUM FIREBALLP LM20.5", 294 "QUANTUM FIREBALLP LM20.5",
295 "FUJITSU MHZ2160BH G2",
295 NULL 296 NULL
296}; 297};
297 298
@@ -316,7 +317,7 @@ int ide_driveid_update(ide_drive_t *drive)
316 return 0; 317 return 0;
317 318
318 SELECT_MASK(drive, 1); 319 SELECT_MASK(drive, 1);
319 rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id); 320 rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id, 1);
320 SELECT_MASK(drive, 0); 321 SELECT_MASK(drive, 0);
321 322
322 if (rc) 323 if (rc)
@@ -363,14 +364,6 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
363 * this point (lost interrupt). 364 * this point (lost interrupt).
364 */ 365 */
365 366
366 /*
367 * FIXME: we race against the running IRQ here if
368 * this is called from non IRQ context. If we use
369 * disable_irq() we hang on the error path. Work
370 * is needed.
371 */
372 disable_irq_nosync(hwif->irq);
373
374 udelay(1); 367 udelay(1);
375 tp_ops->dev_select(drive); 368 tp_ops->dev_select(drive);
376 SELECT_MASK(drive, 1); 369 SELECT_MASK(drive, 1);
@@ -394,8 +387,6 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
394 387
395 SELECT_MASK(drive, 0); 388 SELECT_MASK(drive, 0);
396 389
397 enable_irq(hwif->irq);
398
399 if (error) { 390 if (error) {
400 (void) ide_dump_status(drive, "set_drive_speed_status", stat); 391 (void) ide_dump_status(drive, "set_drive_speed_status", stat);
401 return error; 392 return error;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 1bb106f6221a..8de442cbee94 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -238,6 +238,7 @@ static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
238 * @drive: drive to identify 238 * @drive: drive to identify
239 * @cmd: command to use 239 * @cmd: command to use
240 * @id: buffer for IDENTIFY data 240 * @id: buffer for IDENTIFY data
241 * @irq_ctx: flag set when called from the IRQ context
241 * 242 *
242 * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response. 243 * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response.
243 * 244 *
@@ -246,7 +247,7 @@ static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
246 * 2 device aborted the command (refused to identify itself) 247 * 2 device aborted the command (refused to identify itself)
247 */ 248 */
248 249
249int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) 250int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id, int irq_ctx)
250{ 251{
251 ide_hwif_t *hwif = drive->hwif; 252 ide_hwif_t *hwif = drive->hwif;
252 struct ide_io_ports *io_ports = &hwif->io_ports; 253 struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -263,7 +264,10 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
263 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS); 264 tp_ops->write_devctl(hwif, ATA_NIEN | ATA_DEVCTL_OBS);
264 265
265 /* take a deep breath */ 266 /* take a deep breath */
266 msleep(50); 267 if (irq_ctx)
268 mdelay(50);
269 else
270 msleep(50);
267 271
268 if (io_ports->ctl_addr && 272 if (io_ports->ctl_addr &&
269 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { 273 (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) {
@@ -295,12 +299,19 @@ int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
295 299
296 timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; 300 timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
297 301
298 if (ide_busy_sleep(drive, timeout, use_altstatus))
299 return 1;
300
301 /* wait for IRQ and ATA_DRQ */ 302 /* wait for IRQ and ATA_DRQ */
302 msleep(50); 303 if (irq_ctx) {
303 s = tp_ops->read_status(hwif); 304 rc = __ide_wait_stat(drive, ATA_DRQ, BAD_R_STAT, timeout, &s);
305 if (rc)
306 return 1;
307 } else {
308 rc = ide_busy_sleep(drive, timeout, use_altstatus);
309 if (rc)
310 return 1;
311
312 msleep(50);
313 s = tp_ops->read_status(hwif);
314 }
304 315
305 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { 316 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
306 /* drive returned ID */ 317 /* drive returned ID */
@@ -406,10 +417,10 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
406 417
407 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || 418 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
408 present || cmd == ATA_CMD_ID_ATAPI) { 419 present || cmd == ATA_CMD_ID_ATAPI) {
409 rc = ide_dev_read_id(drive, cmd, id); 420 rc = ide_dev_read_id(drive, cmd, id, 0);
410 if (rc) 421 if (rc)
411 /* failed: try again */ 422 /* failed: try again */
412 rc = ide_dev_read_id(drive, cmd, id); 423 rc = ide_dev_read_id(drive, cmd, id, 0);
413 424
414 stat = tp_ops->read_status(hwif); 425 stat = tp_ops->read_status(hwif);
415 426
@@ -424,7 +435,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
424 msleep(50); 435 msleep(50);
425 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); 436 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
426 (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0); 437 (void)ide_busy_sleep(drive, WAIT_WORSTCASE, 0);
427 rc = ide_dev_read_id(drive, cmd, id); 438 rc = ide_dev_read_id(drive, cmd, id, 0);
428 } 439 }
429 440
430 /* ensure drive IRQ is clear */ 441 /* ensure drive IRQ is clear */
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 3242698832a4..28d09a5d8450 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -30,11 +30,9 @@
30 30
31static struct proc_dir_entry *proc_ide_root; 31static struct proc_dir_entry *proc_ide_root;
32 32
33static int proc_ide_read_imodel 33static int ide_imodel_proc_show(struct seq_file *m, void *v)
34 (char *page, char **start, off_t off, int count, int *eof, void *data)
35{ 34{
36 ide_hwif_t *hwif = (ide_hwif_t *) data; 35 ide_hwif_t *hwif = (ide_hwif_t *) m->private;
37 int len;
38 const char *name; 36 const char *name;
39 37
40 switch (hwif->chipset) { 38 switch (hwif->chipset) {
@@ -53,63 +51,108 @@ static int proc_ide_read_imodel
53 case ide_acorn: name = "acorn"; break; 51 case ide_acorn: name = "acorn"; break;
54 default: name = "(unknown)"; break; 52 default: name = "(unknown)"; break;
55 } 53 }
56 len = sprintf(page, "%s\n", name); 54 seq_printf(m, "%s\n", name);
57 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 55 return 0;
58} 56}
59 57
60static int proc_ide_read_mate 58static int ide_imodel_proc_open(struct inode *inode, struct file *file)
61 (char *page, char **start, off_t off, int count, int *eof, void *data)
62{ 59{
63 ide_hwif_t *hwif = (ide_hwif_t *) data; 60 return single_open(file, ide_imodel_proc_show, PDE(inode)->data);
64 int len; 61}
62
63static const struct file_operations ide_imodel_proc_fops = {
64 .owner = THIS_MODULE,
65 .open = ide_imodel_proc_open,
66 .read = seq_read,
67 .llseek = seq_lseek,
68 .release = single_release,
69};
70
71static int ide_mate_proc_show(struct seq_file *m, void *v)
72{
73 ide_hwif_t *hwif = (ide_hwif_t *) m->private;
65 74
66 if (hwif && hwif->mate) 75 if (hwif && hwif->mate)
67 len = sprintf(page, "%s\n", hwif->mate->name); 76 seq_printf(m, "%s\n", hwif->mate->name);
68 else 77 else
69 len = sprintf(page, "(none)\n"); 78 seq_printf(m, "(none)\n");
70 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 79 return 0;
80}
81
82static int ide_mate_proc_open(struct inode *inode, struct file *file)
83{
84 return single_open(file, ide_mate_proc_show, PDE(inode)->data);
71} 85}
72 86
73static int proc_ide_read_channel 87static const struct file_operations ide_mate_proc_fops = {
74 (char *page, char **start, off_t off, int count, int *eof, void *data) 88 .owner = THIS_MODULE,
89 .open = ide_mate_proc_open,
90 .read = seq_read,
91 .llseek = seq_lseek,
92 .release = single_release,
93};
94
95static int ide_channel_proc_show(struct seq_file *m, void *v)
75{ 96{
76 ide_hwif_t *hwif = (ide_hwif_t *) data; 97 ide_hwif_t *hwif = (ide_hwif_t *) m->private;
77 int len;
78 98
79 page[0] = hwif->channel ? '1' : '0'; 99 seq_printf(m, "%c\n", hwif->channel ? '1' : '0');
80 page[1] = '\n'; 100 return 0;
81 len = 2;
82 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
83} 101}
84 102
85static int proc_ide_read_identify 103static int ide_channel_proc_open(struct inode *inode, struct file *file)
86 (char *page, char **start, off_t off, int count, int *eof, void *data)
87{ 104{
88 ide_drive_t *drive = (ide_drive_t *)data; 105 return single_open(file, ide_channel_proc_show, PDE(inode)->data);
89 int len = 0, i = 0; 106}
90 int err = 0; 107
108static const struct file_operations ide_channel_proc_fops = {
109 .owner = THIS_MODULE,
110 .open = ide_channel_proc_open,
111 .read = seq_read,
112 .llseek = seq_lseek,
113 .release = single_release,
114};
91 115
92 len = sprintf(page, "\n"); 116static int ide_identify_proc_show(struct seq_file *m, void *v)
117{
118 ide_drive_t *drive = (ide_drive_t *)m->private;
119 u8 *buf;
93 120
94 if (drive) { 121 if (!drive) {
95 __le16 *val = (__le16 *)page; 122 seq_putc(m, '\n');
123 return 0;
124 }
96 125
97 err = taskfile_lib_get_identify(drive, page); 126 buf = kmalloc(SECTOR_SIZE, GFP_KERNEL);
98 if (!err) { 127 if (!buf)
99 char *out = (char *)page + SECTOR_SIZE; 128 return -ENOMEM;
129 if (taskfile_lib_get_identify(drive, buf) == 0) {
130 __le16 *val = (__le16 *)buf;
131 int i;
100 132
101 page = out; 133 for (i = 0; i < SECTOR_SIZE / 2; i++) {
102 do { 134 seq_printf(m, "%04x%c", le16_to_cpu(val[i]),
103 out += sprintf(out, "%04x%c", 135 (i % 8) == 7 ? '\n' : ' ');
104 le16_to_cpup(val), (++i & 7) ? ' ' : '\n');
105 val += 1;
106 } while (i < SECTOR_SIZE / 2);
107 len = out - page;
108 } 136 }
109 } 137 } else
110 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 138 seq_putc(m, buf[0]);
139 kfree(buf);
140 return 0;
141}
142
143static int ide_identify_proc_open(struct inode *inode, struct file *file)
144{
145 return single_open(file, ide_identify_proc_show, PDE(inode)->data);
111} 146}
112 147
148static const struct file_operations ide_identify_proc_fops = {
149 .owner = THIS_MODULE,
150 .open = ide_identify_proc_open,
151 .read = seq_read,
152 .llseek = seq_lseek,
153 .release = single_release,
154};
155
113/** 156/**
114 * ide_find_setting - find a specific setting 157 * ide_find_setting - find a specific setting
115 * @st: setting table pointer 158 * @st: setting table pointer
@@ -195,7 +238,6 @@ ide_devset_get(xfer_rate, current_speed);
195static int set_xfer_rate (ide_drive_t *drive, int arg) 238static int set_xfer_rate (ide_drive_t *drive, int arg)
196{ 239{
197 struct ide_cmd cmd; 240 struct ide_cmd cmd;
198 int err;
199 241
200 if (arg < XFER_PIO_0 || arg > XFER_UDMA_6) 242 if (arg < XFER_PIO_0 || arg > XFER_UDMA_6)
201 return -EINVAL; 243 return -EINVAL;
@@ -206,14 +248,9 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
206 cmd.tf.nsect = (u8)arg; 248 cmd.tf.nsect = (u8)arg;
207 cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT; 249 cmd.valid.out.tf = IDE_VALID_FEATURE | IDE_VALID_NSECT;
208 cmd.valid.in.tf = IDE_VALID_NSECT; 250 cmd.valid.in.tf = IDE_VALID_NSECT;
251 cmd.tf_flags = IDE_TFLAG_SET_XFER;
209 252
210 err = ide_no_data_taskfile(drive, &cmd); 253 return ide_no_data_taskfile(drive, &cmd);
211
212 if (!err) {
213 ide_set_xfer_rate(drive, (u8) arg);
214 ide_driveid_update(drive);
215 }
216 return err;
217} 254}
218 255
219ide_devset_rw(current_speed, xfer_rate); 256ide_devset_rw(current_speed, xfer_rate);
@@ -246,22 +283,20 @@ static void proc_ide_settings_warn(void)
246 warned = 1; 283 warned = 1;
247} 284}
248 285
249static int proc_ide_read_settings 286static int ide_settings_proc_show(struct seq_file *m, void *v)
250 (char *page, char **start, off_t off, int count, int *eof, void *data)
251{ 287{
252 const struct ide_proc_devset *setting, *g, *d; 288 const struct ide_proc_devset *setting, *g, *d;
253 const struct ide_devset *ds; 289 const struct ide_devset *ds;
254 ide_drive_t *drive = (ide_drive_t *) data; 290 ide_drive_t *drive = (ide_drive_t *) m->private;
255 char *out = page; 291 int rc, mul_factor, div_factor;
256 int len, rc, mul_factor, div_factor;
257 292
258 proc_ide_settings_warn(); 293 proc_ide_settings_warn();
259 294
260 mutex_lock(&ide_setting_mtx); 295 mutex_lock(&ide_setting_mtx);
261 g = ide_generic_settings; 296 g = ide_generic_settings;
262 d = drive->settings; 297 d = drive->settings;
263 out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); 298 seq_printf(m, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n");
264 out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); 299 seq_printf(m, "----\t\t\t-----\t\t---\t\t---\t\t----\n");
265 while (g->name || (d && d->name)) { 300 while (g->name || (d && d->name)) {
266 /* read settings in the alphabetical order */ 301 /* read settings in the alphabetical order */
267 if (g->name && d && d->name) { 302 if (g->name && d && d->name) {
@@ -275,31 +310,35 @@ static int proc_ide_read_settings
275 setting = g++; 310 setting = g++;
276 mul_factor = setting->mulf ? setting->mulf(drive) : 1; 311 mul_factor = setting->mulf ? setting->mulf(drive) : 1;
277 div_factor = setting->divf ? setting->divf(drive) : 1; 312 div_factor = setting->divf ? setting->divf(drive) : 1;
278 out += sprintf(out, "%-24s", setting->name); 313 seq_printf(m, "%-24s", setting->name);
279 rc = ide_read_setting(drive, setting); 314 rc = ide_read_setting(drive, setting);
280 if (rc >= 0) 315 if (rc >= 0)
281 out += sprintf(out, "%-16d", rc * mul_factor / div_factor); 316 seq_printf(m, "%-16d", rc * mul_factor / div_factor);
282 else 317 else
283 out += sprintf(out, "%-16s", "write-only"); 318 seq_printf(m, "%-16s", "write-only");
284 out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); 319 seq_printf(m, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor);
285 ds = setting->setting; 320 ds = setting->setting;
286 if (ds->get) 321 if (ds->get)
287 out += sprintf(out, "r"); 322 seq_printf(m, "r");
288 if (ds->set) 323 if (ds->set)
289 out += sprintf(out, "w"); 324 seq_printf(m, "w");
290 out += sprintf(out, "\n"); 325 seq_printf(m, "\n");
291 } 326 }
292 len = out - page;
293 mutex_unlock(&ide_setting_mtx); 327 mutex_unlock(&ide_setting_mtx);
294 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 328 return 0;
329}
330
331static int ide_settings_proc_open(struct inode *inode, struct file *file)
332{
333 return single_open(file, ide_settings_proc_show, PDE(inode)->data);
295} 334}
296 335
297#define MAX_LEN 30 336#define MAX_LEN 30
298 337
299static int proc_ide_write_settings(struct file *file, const char __user *buffer, 338static ssize_t ide_settings_proc_write(struct file *file, const char __user *buffer,
300 unsigned long count, void *data) 339 size_t count, loff_t *pos)
301{ 340{
302 ide_drive_t *drive = (ide_drive_t *) data; 341 ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data;
303 char name[MAX_LEN + 1]; 342 char name[MAX_LEN + 1];
304 int for_real = 0, mul_factor, div_factor; 343 int for_real = 0, mul_factor, div_factor;
305 unsigned long n; 344 unsigned long n;
@@ -394,63 +433,104 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer,
394 return count; 433 return count;
395parse_error: 434parse_error:
396 free_page((unsigned long)buf); 435 free_page((unsigned long)buf);
397 printk("proc_ide_write_settings(): parse error\n"); 436 printk("%s(): parse error\n", __func__);
398 return -EINVAL; 437 return -EINVAL;
399} 438}
400 439
401int proc_ide_read_capacity 440static const struct file_operations ide_settings_proc_fops = {
402 (char *page, char **start, off_t off, int count, int *eof, void *data) 441 .owner = THIS_MODULE,
442 .open = ide_settings_proc_open,
443 .read = seq_read,
444 .llseek = seq_lseek,
445 .release = single_release,
446 .write = ide_settings_proc_write,
447};
448
449static int ide_capacity_proc_show(struct seq_file *m, void *v)
450{
451 seq_printf(m, "%llu\n", (long long)0x7fffffff);
452 return 0;
453}
454
455static int ide_capacity_proc_open(struct inode *inode, struct file *file)
403{ 456{
404 int len = sprintf(page, "%llu\n", (long long)0x7fffffff); 457 return single_open(file, ide_capacity_proc_show, NULL);
405 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
406} 458}
407 459
408EXPORT_SYMBOL_GPL(proc_ide_read_capacity); 460const struct file_operations ide_capacity_proc_fops = {
461 .owner = THIS_MODULE,
462 .open = ide_capacity_proc_open,
463 .read = seq_read,
464 .llseek = seq_lseek,
465 .release = single_release,
466};
467EXPORT_SYMBOL_GPL(ide_capacity_proc_fops);
409 468
410int proc_ide_read_geometry 469static int ide_geometry_proc_show(struct seq_file *m, void *v)
411 (char *page, char **start, off_t off, int count, int *eof, void *data)
412{ 470{
413 ide_drive_t *drive = (ide_drive_t *) data; 471 ide_drive_t *drive = (ide_drive_t *) m->private;
414 char *out = page;
415 int len;
416 472
417 out += sprintf(out, "physical %d/%d/%d\n", 473 seq_printf(m, "physical %d/%d/%d\n",
418 drive->cyl, drive->head, drive->sect); 474 drive->cyl, drive->head, drive->sect);
419 out += sprintf(out, "logical %d/%d/%d\n", 475 seq_printf(m, "logical %d/%d/%d\n",
420 drive->bios_cyl, drive->bios_head, drive->bios_sect); 476 drive->bios_cyl, drive->bios_head, drive->bios_sect);
477 return 0;
478}
421 479
422 len = out - page; 480static int ide_geometry_proc_open(struct inode *inode, struct file *file)
423 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 481{
482 return single_open(file, ide_geometry_proc_show, PDE(inode)->data);
424} 483}
425 484
426EXPORT_SYMBOL(proc_ide_read_geometry); 485const struct file_operations ide_geometry_proc_fops = {
486 .owner = THIS_MODULE,
487 .open = ide_geometry_proc_open,
488 .read = seq_read,
489 .llseek = seq_lseek,
490 .release = single_release,
491};
492EXPORT_SYMBOL(ide_geometry_proc_fops);
427 493
428static int proc_ide_read_dmodel 494static int ide_dmodel_proc_show(struct seq_file *seq, void *v)
429 (char *page, char **start, off_t off, int count, int *eof, void *data)
430{ 495{
431 ide_drive_t *drive = (ide_drive_t *) data; 496 ide_drive_t *drive = (ide_drive_t *) seq->private;
432 char *m = (char *)&drive->id[ATA_ID_PROD]; 497 char *m = (char *)&drive->id[ATA_ID_PROD];
433 int len;
434 498
435 len = sprintf(page, "%.40s\n", m[0] ? m : "(none)"); 499 seq_printf(seq, "%.40s\n", m[0] ? m : "(none)");
436 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 500 return 0;
501}
502
503static int ide_dmodel_proc_open(struct inode *inode, struct file *file)
504{
505 return single_open(file, ide_dmodel_proc_show, PDE(inode)->data);
437} 506}
438 507
439static int proc_ide_read_driver 508static const struct file_operations ide_dmodel_proc_fops = {
440 (char *page, char **start, off_t off, int count, int *eof, void *data) 509 .owner = THIS_MODULE,
510 .open = ide_dmodel_proc_open,
511 .read = seq_read,
512 .llseek = seq_lseek,
513 .release = single_release,
514};
515
516static int ide_driver_proc_show(struct seq_file *m, void *v)
441{ 517{
442 ide_drive_t *drive = (ide_drive_t *)data; 518 ide_drive_t *drive = (ide_drive_t *)m->private;
443 struct device *dev = &drive->gendev; 519 struct device *dev = &drive->gendev;
444 struct ide_driver *ide_drv; 520 struct ide_driver *ide_drv;
445 int len;
446 521
447 if (dev->driver) { 522 if (dev->driver) {
448 ide_drv = to_ide_driver(dev->driver); 523 ide_drv = to_ide_driver(dev->driver);
449 len = sprintf(page, "%s version %s\n", 524 seq_printf(m, "%s version %s\n",
450 dev->driver->name, ide_drv->version); 525 dev->driver->name, ide_drv->version);
451 } else 526 } else
452 len = sprintf(page, "ide-default version 0.9.newide\n"); 527 seq_printf(m, "ide-default version 0.9.newide\n");
453 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 528 return 0;
529}
530
531static int ide_driver_proc_open(struct inode *inode, struct file *file)
532{
533 return single_open(file, ide_driver_proc_show, PDE(inode)->data);
454} 534}
455 535
456static int ide_replace_subdriver(ide_drive_t *drive, const char *driver) 536static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
@@ -480,10 +560,10 @@ static int ide_replace_subdriver(ide_drive_t *drive, const char *driver)
480 return ret; 560 return ret;
481} 561}
482 562
483static int proc_ide_write_driver 563static ssize_t ide_driver_proc_write(struct file *file, const char __user *buffer,
484 (struct file *file, const char __user *buffer, unsigned long count, void *data) 564 size_t count, loff_t *pos)
485{ 565{
486 ide_drive_t *drive = (ide_drive_t *) data; 566 ide_drive_t *drive = (ide_drive_t *) PDE(file->f_path.dentry->d_inode)->data;
487 char name[32]; 567 char name[32];
488 568
489 if (!capable(CAP_SYS_ADMIN)) 569 if (!capable(CAP_SYS_ADMIN))
@@ -498,12 +578,19 @@ static int proc_ide_write_driver
498 return count; 578 return count;
499} 579}
500 580
501static int proc_ide_read_media 581static const struct file_operations ide_driver_proc_fops = {
502 (char *page, char **start, off_t off, int count, int *eof, void *data) 582 .owner = THIS_MODULE,
583 .open = ide_driver_proc_open,
584 .read = seq_read,
585 .llseek = seq_lseek,
586 .release = single_release,
587 .write = ide_driver_proc_write,
588};
589
590static int ide_media_proc_show(struct seq_file *m, void *v)
503{ 591{
504 ide_drive_t *drive = (ide_drive_t *) data; 592 ide_drive_t *drive = (ide_drive_t *) m->private;
505 const char *media; 593 const char *media;
506 int len;
507 594
508 switch (drive->media) { 595 switch (drive->media) {
509 case ide_disk: media = "disk\n"; break; 596 case ide_disk: media = "disk\n"; break;
@@ -513,20 +600,30 @@ static int proc_ide_read_media
513 case ide_optical: media = "optical\n"; break; 600 case ide_optical: media = "optical\n"; break;
514 default: media = "UNKNOWN\n"; break; 601 default: media = "UNKNOWN\n"; break;
515 } 602 }
516 strcpy(page, media); 603 seq_puts(m, media);
517 len = strlen(media); 604 return 0;
518 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 605}
606
607static int ide_media_proc_open(struct inode *inode, struct file *file)
608{
609 return single_open(file, ide_media_proc_show, PDE(inode)->data);
519} 610}
520 611
612static const struct file_operations ide_media_proc_fops = {
613 .owner = THIS_MODULE,
614 .open = ide_media_proc_open,
615 .read = seq_read,
616 .llseek = seq_lseek,
617 .release = single_release,
618};
619
521static ide_proc_entry_t generic_drive_entries[] = { 620static ide_proc_entry_t generic_drive_entries[] = {
522 { "driver", S_IFREG|S_IRUGO, proc_ide_read_driver, 621 { "driver", S_IFREG|S_IRUGO, &ide_driver_proc_fops },
523 proc_ide_write_driver }, 622 { "identify", S_IFREG|S_IRUSR, &ide_identify_proc_fops},
524 { "identify", S_IFREG|S_IRUSR, proc_ide_read_identify, NULL }, 623 { "media", S_IFREG|S_IRUGO, &ide_media_proc_fops },
525 { "media", S_IFREG|S_IRUGO, proc_ide_read_media, NULL }, 624 { "model", S_IFREG|S_IRUGO, &ide_dmodel_proc_fops },
526 { "model", S_IFREG|S_IRUGO, proc_ide_read_dmodel, NULL }, 625 { "settings", S_IFREG|S_IRUSR|S_IWUSR, &ide_settings_proc_fops},
527 { "settings", S_IFREG|S_IRUSR|S_IWUSR, proc_ide_read_settings, 626 {}
528 proc_ide_write_settings },
529 { NULL, 0, NULL, NULL }
530}; 627};
531 628
532static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data) 629static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data)
@@ -536,11 +633,8 @@ static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p
536 if (!dir || !p) 633 if (!dir || !p)
537 return; 634 return;
538 while (p->name != NULL) { 635 while (p->name != NULL) {
539 ent = create_proc_entry(p->name, p->mode, dir); 636 ent = proc_create_data(p->name, p->mode, dir, p->proc_fops, data);
540 if (!ent) return; 637 if (!ent) return;
541 ent->data = data;
542 ent->read_proc = p->read_proc;
543 ent->write_proc = p->write_proc;
544 p++; 638 p++;
545 } 639 }
546} 640}
@@ -623,10 +717,10 @@ void ide_proc_unregister_device(ide_drive_t *drive)
623} 717}
624 718
625static ide_proc_entry_t hwif_entries[] = { 719static ide_proc_entry_t hwif_entries[] = {
626 { "channel", S_IFREG|S_IRUGO, proc_ide_read_channel, NULL }, 720 { "channel", S_IFREG|S_IRUGO, &ide_channel_proc_fops },
627 { "mate", S_IFREG|S_IRUGO, proc_ide_read_mate, NULL }, 721 { "mate", S_IFREG|S_IRUGO, &ide_mate_proc_fops },
628 { "model", S_IFREG|S_IRUGO, proc_ide_read_imodel, NULL }, 722 { "model", S_IFREG|S_IRUGO, &ide_imodel_proc_fops },
629 { NULL, 0, NULL, NULL } 723 {}
630}; 724};
631 725
632void ide_proc_register_port(ide_hwif_t *hwif) 726void ide_proc_register_port(ide_hwif_t *hwif)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index bc5fb12b913c..9d6f62baac27 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -31,6 +31,7 @@
31#include <linux/major.h> 31#include <linux/major.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/genhd.h> 33#include <linux/genhd.h>
34#include <linux/seq_file.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35#include <linux/pci.h> 36#include <linux/pci.h>
36#include <linux/ide.h> 37#include <linux/ide.h>
@@ -47,28 +48,13 @@
47#include <asm/unaligned.h> 48#include <asm/unaligned.h>
48#include <linux/mtio.h> 49#include <linux/mtio.h>
49 50
50enum {
51 /* output errors only */
52 DBG_ERR = (1 << 0),
53 /* output all sense key/asc */
54 DBG_SENSE = (1 << 1),
55 /* info regarding all chrdev-related procedures */
56 DBG_CHRDEV = (1 << 2),
57 /* all remaining procedures */
58 DBG_PROCS = (1 << 3),
59};
60
61/* define to see debug info */ 51/* define to see debug info */
62#define IDETAPE_DEBUG_LOG 0 52#undef IDETAPE_DEBUG_LOG
63 53
64#if IDETAPE_DEBUG_LOG 54#ifdef IDETAPE_DEBUG_LOG
65#define debug_log(lvl, fmt, args...) \ 55#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args)
66{ \
67 if (tape->debug_mask & lvl) \
68 printk(KERN_INFO "ide-tape: " fmt, ## args); \
69}
70#else 56#else
71#define debug_log(lvl, fmt, args...) do {} while (0) 57#define ide_debug_log(lvl, fmt, args...) do {} while (0)
72#endif 58#endif
73 59
74/**************************** Tunable parameters *****************************/ 60/**************************** Tunable parameters *****************************/
@@ -170,7 +156,8 @@ typedef struct ide_tape_obj {
170 * other device. Note that at most we will have only one DSC (usually 156 * other device. Note that at most we will have only one DSC (usually
171 * data transfer) request in the device request queue. 157 * data transfer) request in the device request queue.
172 */ 158 */
173 struct request *postponed_rq; 159 bool postponed_rq;
160
174 /* The time in which we started polling for DSC */ 161 /* The time in which we started polling for DSC */
175 unsigned long dsc_polling_start; 162 unsigned long dsc_polling_start;
176 /* Timer used to poll for dsc */ 163 /* Timer used to poll for dsc */
@@ -230,8 +217,6 @@ typedef struct ide_tape_obj {
230 char drv_write_prot; 217 char drv_write_prot;
231 /* the tape is write protected (hardware or opened as read-only) */ 218 /* the tape is write protected (hardware or opened as read-only) */
232 char write_prot; 219 char write_prot;
233
234 u32 debug_mask;
235} idetape_tape_t; 220} idetape_tape_t;
236 221
237static DEFINE_MUTEX(idetape_ref_mutex); 222static DEFINE_MUTEX(idetape_ref_mutex);
@@ -290,8 +275,9 @@ static void idetape_analyze_error(ide_drive_t *drive)
290 tape->asc = sense[12]; 275 tape->asc = sense[12];
291 tape->ascq = sense[13]; 276 tape->ascq = sense[13];
292 277
293 debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", 278 ide_debug_log(IDE_DBG_FUNC,
294 pc->c[0], tape->sense_key, tape->asc, tape->ascq); 279 "cmd: 0x%x, sense key = %x, asc = %x, ascq = %x",
280 rq->cmd[0], tape->sense_key, tape->asc, tape->ascq);
295 281
296 /* correct remaining bytes to transfer */ 282 /* correct remaining bytes to transfer */
297 if (pc->flags & PC_FLAG_DMA_ERROR) 283 if (pc->flags & PC_FLAG_DMA_ERROR)
@@ -344,7 +330,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
344 int uptodate = pc->error ? 0 : 1; 330 int uptodate = pc->error ? 0 : 1;
345 int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; 331 int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
346 332
347 debug_log(DBG_PROCS, "Enter %s\n", __func__); 333 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc: %d, err: %d", rq->cmd[0],
334 dsc, err);
348 335
349 if (dsc) 336 if (dsc)
350 ide_tape_handle_dsc(drive); 337 ide_tape_handle_dsc(drive);
@@ -387,13 +374,14 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
387 * Postpone the current request so that ide.c will be able to service requests 374 * Postpone the current request so that ide.c will be able to service requests
388 * from another device on the same port while we are polling for DSC. 375 * from another device on the same port while we are polling for DSC.
389 */ 376 */
390static void idetape_postpone_request(ide_drive_t *drive) 377static void ide_tape_stall_queue(ide_drive_t *drive)
391{ 378{
392 idetape_tape_t *tape = drive->driver_data; 379 idetape_tape_t *tape = drive->driver_data;
393 380
394 debug_log(DBG_PROCS, "Enter %s\n", __func__); 381 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu",
382 drive->hwif->rq->cmd[0], tape->dsc_poll_freq);
395 383
396 tape->postponed_rq = drive->hwif->rq; 384 tape->postponed_rq = true;
397 385
398 ide_stall_queue(drive, tape->dsc_poll_freq); 386 ide_stall_queue(drive, tape->dsc_poll_freq);
399} 387}
@@ -407,7 +395,7 @@ static void ide_tape_handle_dsc(ide_drive_t *drive)
407 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; 395 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST;
408 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; 396 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT;
409 /* Allow ide.c to handle other requests */ 397 /* Allow ide.c to handle other requests */
410 idetape_postpone_request(drive); 398 ide_tape_stall_queue(drive);
411} 399}
412 400
413/* 401/*
@@ -488,7 +476,8 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
488 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); 476 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
489 return ide_stopped; 477 return ide_stopped;
490 } 478 }
491 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); 479 ide_debug_log(IDE_DBG_SENSE, "retry #%d, cmd: 0x%02x", pc->retries,
480 pc->c[0]);
492 481
493 pc->retries++; 482 pc->retries++;
494 483
@@ -579,12 +568,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
579 ide_hwif_t *hwif = drive->hwif; 568 ide_hwif_t *hwif = drive->hwif;
580 idetape_tape_t *tape = drive->driver_data; 569 idetape_tape_t *tape = drive->driver_data;
581 struct ide_atapi_pc *pc = NULL; 570 struct ide_atapi_pc *pc = NULL;
582 struct request *postponed_rq = tape->postponed_rq;
583 struct ide_cmd cmd; 571 struct ide_cmd cmd;
584 u8 stat; 572 u8 stat;
585 573
586 debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n" 574 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u",
587 (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); 575 rq->cmd[0], (unsigned long long)blk_rq_pos(rq),
576 blk_rq_sectors(rq));
588 577
589 BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); 578 BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq)));
590 579
@@ -594,18 +583,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
594 goto out; 583 goto out;
595 } 584 }
596 585
597 if (postponed_rq != NULL)
598 if (rq != postponed_rq) {
599 printk(KERN_ERR "ide-tape: ide-tape.c bug - "
600 "Two DSC requests were queued\n");
601 drive->failed_pc = NULL;
602 rq->errors = 0;
603 ide_complete_rq(drive, 0, blk_rq_bytes(rq));
604 return ide_stopped;
605 }
606
607 tape->postponed_rq = NULL;
608
609 /* 586 /*
610 * If the tape is still busy, postpone our request and service 587 * If the tape is still busy, postpone our request and service
611 * the other device meanwhile. 588 * the other device meanwhile.
@@ -623,7 +600,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
623 600
624 if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) && 601 if (!(drive->atapi_flags & IDE_AFLAG_IGNORE_DSC) &&
625 !(stat & ATA_DSC)) { 602 !(stat & ATA_DSC)) {
626 if (postponed_rq == NULL) { 603 if (!tape->postponed_rq) {
627 tape->dsc_polling_start = jiffies; 604 tape->dsc_polling_start = jiffies;
628 tape->dsc_poll_freq = tape->best_dsc_rw_freq; 605 tape->dsc_poll_freq = tape->best_dsc_rw_freq;
629 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT; 606 tape->dsc_timeout = jiffies + IDETAPE_DSC_RW_TIMEOUT;
@@ -640,10 +617,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
640 tape->dsc_polling_start + 617 tape->dsc_polling_start +
641 IDETAPE_DSC_MA_THRESHOLD)) 618 IDETAPE_DSC_MA_THRESHOLD))
642 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; 619 tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW;
643 idetape_postpone_request(drive); 620 ide_tape_stall_queue(drive);
644 return ide_stopped; 621 return ide_stopped;
645 } else 622 } else {
646 drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC; 623 drive->atapi_flags &= ~IDE_AFLAG_IGNORE_DSC;
624 tape->postponed_rq = false;
625 }
647 626
648 if (rq->cmd[13] & REQ_IDETAPE_READ) { 627 if (rq->cmd[13] & REQ_IDETAPE_READ) {
649 pc = &tape->queued_pc; 628 pc = &tape->queued_pc;
@@ -745,7 +724,7 @@ static int ide_tape_read_position(ide_drive_t *drive)
745 struct ide_atapi_pc pc; 724 struct ide_atapi_pc pc;
746 u8 buf[20]; 725 u8 buf[20];
747 726
748 debug_log(DBG_PROCS, "Enter %s\n", __func__); 727 ide_debug_log(IDE_DBG_FUNC, "enter");
749 728
750 /* prep cmd */ 729 /* prep cmd */
751 ide_init_pc(&pc); 730 ide_init_pc(&pc);
@@ -756,9 +735,9 @@ static int ide_tape_read_position(ide_drive_t *drive)
756 return -1; 735 return -1;
757 736
758 if (!pc.error) { 737 if (!pc.error) {
759 debug_log(DBG_SENSE, "BOP - %s\n", 738 ide_debug_log(IDE_DBG_FUNC, "BOP - %s",
760 (buf[0] & 0x80) ? "Yes" : "No"); 739 (buf[0] & 0x80) ? "Yes" : "No");
761 debug_log(DBG_SENSE, "EOP - %s\n", 740 ide_debug_log(IDE_DBG_FUNC, "EOP - %s",
762 (buf[0] & 0x40) ? "Yes" : "No"); 741 (buf[0] & 0x40) ? "Yes" : "No");
763 742
764 if (buf[0] & 0x4) { 743 if (buf[0] & 0x4) {
@@ -768,8 +747,8 @@ static int ide_tape_read_position(ide_drive_t *drive)
768 &drive->atapi_flags); 747 &drive->atapi_flags);
769 return -1; 748 return -1;
770 } else { 749 } else {
771 debug_log(DBG_SENSE, "Block Location - %u\n", 750 ide_debug_log(IDE_DBG_FUNC, "Block Location: %u",
772 be32_to_cpup((__be32 *)&buf[4])); 751 be32_to_cpup((__be32 *)&buf[4]));
773 752
774 tape->partition = buf[1]; 753 tape->partition = buf[1];
775 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); 754 tape->first_frame = be32_to_cpup((__be32 *)&buf[4]);
@@ -866,7 +845,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
866 struct request *rq; 845 struct request *rq;
867 int ret; 846 int ret;
868 847
869 debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); 848 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, size: %d", cmd, size);
849
870 BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); 850 BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE);
871 BUG_ON(size < 0 || size % tape->blk_size); 851 BUG_ON(size < 0 || size % tape->blk_size);
872 852
@@ -1029,7 +1009,7 @@ static int idetape_rewind_tape(ide_drive_t *drive)
1029 struct ide_atapi_pc pc; 1009 struct ide_atapi_pc pc;
1030 int ret; 1010 int ret;
1031 1011
1032 debug_log(DBG_SENSE, "Enter %s\n", __func__); 1012 ide_debug_log(IDE_DBG_FUNC, "enter");
1033 1013
1034 idetape_create_rewind_cmd(drive, &pc); 1014 idetape_create_rewind_cmd(drive, &pc);
1035 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); 1015 ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0);
@@ -1055,7 +1035,7 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd,
1055 int nr_stages; 1035 int nr_stages;
1056 } config; 1036 } config;
1057 1037
1058 debug_log(DBG_PROCS, "Enter %s\n", __func__); 1038 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%04x", cmd);
1059 1039
1060 switch (cmd) { 1040 switch (cmd) {
1061 case 0x0340: 1041 case 0x0340:
@@ -1085,6 +1065,9 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
1085 int retval, count = 0; 1065 int retval, count = 0;
1086 int sprev = !!(tape->caps[4] & 0x20); 1066 int sprev = !!(tape->caps[4] & 0x20);
1087 1067
1068
1069 ide_debug_log(IDE_DBG_FUNC, "mt_op: %d, mt_count: %d", mt_op, mt_count);
1070
1088 if (mt_count == 0) 1071 if (mt_count == 0)
1089 return 0; 1072 return 0;
1090 if (MTBSF == mt_op || MTBSFM == mt_op) { 1073 if (MTBSF == mt_op || MTBSFM == mt_op) {
@@ -1148,7 +1131,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
1148 ssize_t ret = 0; 1131 ssize_t ret = 0;
1149 int rc; 1132 int rc;
1150 1133
1151 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 1134 ide_debug_log(IDE_DBG_FUNC, "count %Zd", count);
1152 1135
1153 if (tape->chrdev_dir != IDETAPE_DIR_READ) { 1136 if (tape->chrdev_dir != IDETAPE_DIR_READ) {
1154 if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) 1137 if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags))
@@ -1187,8 +1170,6 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
1187 } 1170 }
1188 1171
1189 if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { 1172 if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) {
1190 debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name);
1191
1192 idetape_space_over_filemarks(drive, MTFSF, 1); 1173 idetape_space_over_filemarks(drive, MTFSF, 1);
1193 return 0; 1174 return 0;
1194 } 1175 }
@@ -1209,7 +1190,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
1209 if (tape->write_prot) 1190 if (tape->write_prot)
1210 return -EACCES; 1191 return -EACCES;
1211 1192
1212 debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); 1193 ide_debug_log(IDE_DBG_FUNC, "count %Zd", count);
1213 1194
1214 /* Initialize write operation */ 1195 /* Initialize write operation */
1215 rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); 1196 rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE);
@@ -1273,8 +1254,8 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
1273 struct ide_atapi_pc pc; 1254 struct ide_atapi_pc pc;
1274 int i, retval; 1255 int i, retval;
1275 1256
1276 debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", 1257 ide_debug_log(IDE_DBG_FUNC, "MTIOCTOP ioctl: mt_op: %d, mt_count: %d",
1277 mt_op, mt_count); 1258 mt_op, mt_count);
1278 1259
1279 switch (mt_op) { 1260 switch (mt_op) {
1280 case MTFSF: 1261 case MTFSF:
@@ -1393,7 +1374,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
1393 int block_offset = 0, position = tape->first_frame; 1374 int block_offset = 0, position = tape->first_frame;
1394 void __user *argp = (void __user *)arg; 1375 void __user *argp = (void __user *)arg;
1395 1376
1396 debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); 1377 ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x", cmd);
1397 1378
1398 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { 1379 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
1399 ide_tape_flush_merge_buffer(drive); 1380 ide_tape_flush_merge_buffer(drive);
@@ -1461,6 +1442,9 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive)
1461 (buf[4 + 6] << 8) + 1442 (buf[4 + 6] << 8) +
1462 buf[4 + 7]; 1443 buf[4 + 7];
1463 tape->drv_write_prot = (buf[2] & 0x80) >> 7; 1444 tape->drv_write_prot = (buf[2] & 0x80) >> 7;
1445
1446 ide_debug_log(IDE_DBG_FUNC, "blk_size: %d, write_prot: %d",
1447 tape->blk_size, tape->drv_write_prot);
1464} 1448}
1465 1449
1466static int idetape_chrdev_open(struct inode *inode, struct file *filp) 1450static int idetape_chrdev_open(struct inode *inode, struct file *filp)
@@ -1480,7 +1464,10 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
1480 return -ENXIO; 1464 return -ENXIO;
1481 } 1465 }
1482 1466
1483 debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 1467 drive = tape->drive;
1468 filp->private_data = tape;
1469
1470 ide_debug_log(IDE_DBG_FUNC, "enter");
1484 1471
1485 /* 1472 /*
1486 * We really want to do nonseekable_open(inode, filp); here, but some 1473 * We really want to do nonseekable_open(inode, filp); here, but some
@@ -1489,9 +1476,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
1489 */ 1476 */
1490 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1477 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
1491 1478
1492 drive = tape->drive;
1493
1494 filp->private_data = tape;
1495 1479
1496 if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { 1480 if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) {
1497 retval = -EBUSY; 1481 retval = -EBUSY;
@@ -1570,7 +1554,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp)
1570 lock_kernel(); 1554 lock_kernel();
1571 tape = drive->driver_data; 1555 tape = drive->driver_data;
1572 1556
1573 debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 1557 ide_debug_log(IDE_DBG_FUNC, "enter");
1574 1558
1575 if (tape->chrdev_dir == IDETAPE_DIR_WRITE) 1559 if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
1576 idetape_write_release(drive, minor); 1560 idetape_write_release(drive, minor);
@@ -1707,7 +1691,6 @@ static int divf_buffer_size(ide_drive_t *drive) { return 1024; }
1707 1691
1708ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); 1692ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP);
1709 1693
1710ide_tape_devset_rw_field(debug_mask, debug_mask);
1711ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); 1694ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq);
1712 1695
1713ide_tape_devset_r_field(avg_speed, avg_speed); 1696ide_tape_devset_r_field(avg_speed, avg_speed);
@@ -1719,7 +1702,6 @@ static const struct ide_proc_devset idetape_settings[] = {
1719 __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), 1702 __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL),
1720 __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), 1703 __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer),
1721 __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), 1704 __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size),
1722 __IDE_PROC_DEVSET(debug_mask, 0, 0xffff, NULL, NULL),
1723 __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), 1705 __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL),
1724 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), 1706 __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL),
1725 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1707 __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX,
@@ -1746,7 +1728,9 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
1746 int buffer_size; 1728 int buffer_size;
1747 u16 *ctl = (u16 *)&tape->caps[12]; 1729 u16 *ctl = (u16 *)&tape->caps[12];
1748 1730
1749 drive->pc_callback = ide_tape_callback; 1731 ide_debug_log(IDE_DBG_FUNC, "minor: %d", minor);
1732
1733 drive->pc_callback = ide_tape_callback;
1750 1734
1751 drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 1735 drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP;
1752 1736
@@ -1833,22 +1817,32 @@ static void ide_tape_release(struct device *dev)
1833} 1817}
1834 1818
1835#ifdef CONFIG_IDE_PROC_FS 1819#ifdef CONFIG_IDE_PROC_FS
1836static int proc_idetape_read_name 1820static int idetape_name_proc_show(struct seq_file *m, void *v)
1837 (char *page, char **start, off_t off, int count, int *eof, void *data)
1838{ 1821{
1839 ide_drive_t *drive = (ide_drive_t *) data; 1822 ide_drive_t *drive = (ide_drive_t *) m->private;
1840 idetape_tape_t *tape = drive->driver_data; 1823 idetape_tape_t *tape = drive->driver_data;
1841 char *out = page;
1842 int len;
1843 1824
1844 len = sprintf(out, "%s\n", tape->name); 1825 seq_printf(m, "%s\n", tape->name);
1845 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1826 return 0;
1827}
1828
1829static int idetape_name_proc_open(struct inode *inode, struct file *file)
1830{
1831 return single_open(file, idetape_name_proc_show, PDE(inode)->data);
1846} 1832}
1847 1833
1834static const struct file_operations idetape_name_proc_fops = {
1835 .owner = THIS_MODULE,
1836 .open = idetape_name_proc_open,
1837 .read = seq_read,
1838 .llseek = seq_lseek,
1839 .release = single_release,
1840};
1841
1848static ide_proc_entry_t idetape_proc[] = { 1842static ide_proc_entry_t idetape_proc[] = {
1849 { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL }, 1843 { "capacity", S_IFREG|S_IRUGO, &ide_capacity_proc_fops },
1850 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, 1844 { "name", S_IFREG|S_IRUGO, &idetape_name_proc_fops },
1851 { NULL, 0, NULL, NULL } 1845 {}
1852}; 1846};
1853 1847
1854static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive) 1848static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)
@@ -1932,7 +1926,9 @@ static int ide_tape_probe(ide_drive_t *drive)
1932 struct gendisk *g; 1926 struct gendisk *g;
1933 int minor; 1927 int minor;
1934 1928
1935 if (!strstr("ide-tape", drive->driver_req)) 1929 ide_debug_log(IDE_DBG_FUNC, "enter");
1930
1931 if (!strstr(DRV_NAME, drive->driver_req))
1936 goto failed; 1932 goto failed;
1937 1933
1938 if (drive->media != ide_tape) 1934 if (drive->media != ide_tape)
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 75b85a8cd2d4..cc8633cbe133 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -19,8 +19,8 @@
19#include <linux/hdreg.h> 19#include <linux/hdreg.h>
20#include <linux/ide.h> 20#include <linux/ide.h>
21#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
22#include <linux/uaccess.h>
22 23
23#include <asm/uaccess.h>
24#include <asm/io.h> 24#include <asm/io.h>
25 25
26void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd) 26void ide_tf_readback(ide_drive_t *drive, struct ide_cmd *cmd)
@@ -53,7 +53,7 @@ void ide_tf_dump(const char *s, struct ide_cmd *cmd)
53#endif 53#endif
54} 54}
55 55
56int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) 56int taskfile_lib_get_identify(ide_drive_t *drive, u8 *buf)
57{ 57{
58 struct ide_cmd cmd; 58 struct ide_cmd cmd;
59 59
@@ -86,7 +86,7 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
86 if (orig_cmd->protocol == ATA_PROT_PIO && 86 if (orig_cmd->protocol == ATA_PROT_PIO &&
87 (orig_cmd->tf_flags & IDE_TFLAG_MULTI_PIO) && 87 (orig_cmd->tf_flags & IDE_TFLAG_MULTI_PIO) &&
88 drive->mult_count == 0) { 88 drive->mult_count == 0) {
89 printk(KERN_ERR "%s: multimode not set!\n", drive->name); 89 pr_err("%s: multimode not set!\n", drive->name);
90 return ide_stopped; 90 return ide_stopped;
91 } 91 }
92 92
@@ -214,7 +214,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
214 } 214 }
215 215
216 if (stat & ATA_BUSY) 216 if (stat & ATA_BUSY)
217 printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); 217 pr_err("%s: drive still BUSY!\n", drive->name);
218 218
219 return stat; 219 return stat;
220} 220}
@@ -225,8 +225,8 @@ void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
225 ide_hwif_t *hwif = drive->hwif; 225 ide_hwif_t *hwif = drive->hwif;
226 struct scatterlist *sg = hwif->sg_table; 226 struct scatterlist *sg = hwif->sg_table;
227 struct scatterlist *cursg = cmd->cursg; 227 struct scatterlist *cursg = cmd->cursg;
228 unsigned long uninitialized_var(flags);
228 struct page *page; 229 struct page *page;
229 unsigned long flags;
230 unsigned int offset; 230 unsigned int offset;
231 u8 *buf; 231 u8 *buf;
232 232
@@ -236,6 +236,7 @@ void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
236 236
237 while (len) { 237 while (len) {
238 unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs); 238 unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs);
239 int page_is_high;
239 240
240 if (nr_bytes > PAGE_SIZE) 241 if (nr_bytes > PAGE_SIZE)
241 nr_bytes = PAGE_SIZE; 242 nr_bytes = PAGE_SIZE;
@@ -247,7 +248,8 @@ void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
247 page = nth_page(page, (offset >> PAGE_SHIFT)); 248 page = nth_page(page, (offset >> PAGE_SHIFT));
248 offset %= PAGE_SIZE; 249 offset %= PAGE_SIZE;
249 250
250 if (PageHighMem(page)) 251 page_is_high = PageHighMem(page);
252 if (page_is_high)
251 local_irq_save(flags); 253 local_irq_save(flags);
252 254
253 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset; 255 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
@@ -268,7 +270,7 @@ void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
268 270
269 kunmap_atomic(buf, KM_BIO_SRC_IRQ); 271 kunmap_atomic(buf, KM_BIO_SRC_IRQ);
270 272
271 if (PageHighMem(page)) 273 if (page_is_high)
272 local_irq_restore(flags); 274 local_irq_restore(flags);
273 275
274 len -= nr_bytes; 276 len -= nr_bytes;
@@ -322,10 +324,17 @@ static void ide_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd)
322void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat) 324void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat)
323{ 325{
324 struct request *rq = drive->hwif->rq; 326 struct request *rq = drive->hwif->rq;
325 u8 err = ide_read_error(drive); 327 u8 err = ide_read_error(drive), nsect = cmd->tf.nsect;
328 u8 set_xfer = !!(cmd->tf_flags & IDE_TFLAG_SET_XFER);
326 329
327 ide_complete_cmd(drive, cmd, stat, err); 330 ide_complete_cmd(drive, cmd, stat, err);
328 rq->errors = err; 331 rq->errors = err;
332
333 if (err == 0 && set_xfer) {
334 ide_set_xfer_rate(drive, nsect);
335 ide_driveid_update(drive);
336 }
337
329 ide_complete_rq(drive, err ? -EIO : 0, blk_rq_bytes(rq)); 338 ide_complete_rq(drive, err ? -EIO : 0, blk_rq_bytes(rq));
330} 339}
331 340
@@ -398,8 +407,7 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive,
398 407
399 if (ide_wait_stat(&startstop, drive, ATA_DRQ, 408 if (ide_wait_stat(&startstop, drive, ATA_DRQ,
400 drive->bad_wstat, WAIT_DRQ)) { 409 drive->bad_wstat, WAIT_DRQ)) {
401 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n", 410 pr_err("%s: no DRQ after issuing %sWRITE%s\n", drive->name,
402 drive->name,
403 (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "", 411 (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "",
404 (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : ""); 412 (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : "");
405 return startstop; 413 return startstop;
@@ -449,7 +457,6 @@ put_req:
449 blk_put_request(rq); 457 blk_put_request(rq);
450 return error; 458 return error;
451} 459}
452
453EXPORT_SYMBOL(ide_raw_taskfile); 460EXPORT_SYMBOL(ide_raw_taskfile);
454 461
455int ide_no_data_taskfile(ide_drive_t *drive, struct ide_cmd *cmd) 462int ide_no_data_taskfile(ide_drive_t *drive, struct ide_cmd *cmd)
@@ -475,10 +482,9 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
475 u16 nsect = 0; 482 u16 nsect = 0;
476 char __user *buf = (char __user *)arg; 483 char __user *buf = (char __user *)arg;
477 484
478// printk("IDE Taskfile ...\n");
479
480 req_task = kzalloc(tasksize, GFP_KERNEL); 485 req_task = kzalloc(tasksize, GFP_KERNEL);
481 if (req_task == NULL) return -ENOMEM; 486 if (req_task == NULL)
487 return -ENOMEM;
482 if (copy_from_user(req_task, buf, tasksize)) { 488 if (copy_from_user(req_task, buf, tasksize)) {
483 kfree(req_task); 489 kfree(req_task);
484 return -EFAULT; 490 return -EFAULT;
@@ -486,7 +492,7 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
486 492
487 taskout = req_task->out_size; 493 taskout = req_task->out_size;
488 taskin = req_task->in_size; 494 taskin = req_task->in_size;
489 495
490 if (taskin > 65536 || taskout > 65536) { 496 if (taskin > 65536 || taskout > 65536) {
491 err = -EINVAL; 497 err = -EINVAL;
492 goto abort; 498 goto abort;
@@ -576,51 +582,49 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
576 cmd.protocol = ATA_PROT_DMA; 582 cmd.protocol = ATA_PROT_DMA;
577 583
578 switch (req_task->data_phase) { 584 switch (req_task->data_phase) {
579 case TASKFILE_MULTI_OUT: 585 case TASKFILE_MULTI_OUT:
580 if (!drive->mult_count) { 586 if (!drive->mult_count) {
581 /* (hs): give up if multcount is not set */ 587 /* (hs): give up if multcount is not set */
582 printk(KERN_ERR "%s: %s Multimode Write " \ 588 pr_err("%s: %s Multimode Write multcount is not set\n",
583 "multcount is not set\n", 589 drive->name, __func__);
584 drive->name, __func__); 590 err = -EPERM;
585 err = -EPERM; 591 goto abort;
586 goto abort; 592 }
587 } 593 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
588 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO; 594 /* fall through */
589 /* fall through */ 595 case TASKFILE_OUT:
590 case TASKFILE_OUT: 596 cmd.protocol = ATA_PROT_PIO;
591 cmd.protocol = ATA_PROT_PIO; 597 /* fall through */
592 /* fall through */ 598 case TASKFILE_OUT_DMAQ:
593 case TASKFILE_OUT_DMAQ: 599 case TASKFILE_OUT_DMA:
594 case TASKFILE_OUT_DMA: 600 cmd.tf_flags |= IDE_TFLAG_WRITE;
595 cmd.tf_flags |= IDE_TFLAG_WRITE; 601 nsect = taskout / SECTOR_SIZE;
596 nsect = taskout / SECTOR_SIZE; 602 data_buf = outbuf;
597 data_buf = outbuf; 603 break;
598 break; 604 case TASKFILE_MULTI_IN:
599 case TASKFILE_MULTI_IN: 605 if (!drive->mult_count) {
600 if (!drive->mult_count) { 606 /* (hs): give up if multcount is not set */
601 /* (hs): give up if multcount is not set */ 607 pr_err("%s: %s Multimode Read multcount is not set\n",
602 printk(KERN_ERR "%s: %s Multimode Read failure " \ 608 drive->name, __func__);
603 "multcount is not set\n", 609 err = -EPERM;
604 drive->name, __func__);
605 err = -EPERM;
606 goto abort;
607 }
608 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
609 /* fall through */
610 case TASKFILE_IN:
611 cmd.protocol = ATA_PROT_PIO;
612 /* fall through */
613 case TASKFILE_IN_DMAQ:
614 case TASKFILE_IN_DMA:
615 nsect = taskin / SECTOR_SIZE;
616 data_buf = inbuf;
617 break;
618 case TASKFILE_NO_DATA:
619 cmd.protocol = ATA_PROT_NODATA;
620 break;
621 default:
622 err = -EFAULT;
623 goto abort; 610 goto abort;
611 }
612 cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
613 /* fall through */
614 case TASKFILE_IN:
615 cmd.protocol = ATA_PROT_PIO;
616 /* fall through */
617 case TASKFILE_IN_DMAQ:
618 case TASKFILE_IN_DMA:
619 nsect = taskin / SECTOR_SIZE;
620 data_buf = inbuf;
621 break;
622 case TASKFILE_NO_DATA:
623 cmd.protocol = ATA_PROT_NODATA;
624 break;
625 default:
626 err = -EFAULT;
627 goto abort;
624 } 628 }
625 629
626 if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA) 630 if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA)
@@ -629,7 +633,7 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
629 nsect = (cmd.hob.nsect << 8) | cmd.tf.nsect; 633 nsect = (cmd.hob.nsect << 8) | cmd.tf.nsect;
630 634
631 if (!nsect) { 635 if (!nsect) {
632 printk(KERN_ERR "%s: in/out command without data\n", 636 pr_err("%s: in/out command without data\n",
633 drive->name); 637 drive->name);
634 err = -EFAULT; 638 err = -EFAULT;
635 goto abort; 639 goto abort;
@@ -671,8 +675,6 @@ abort:
671 kfree(outbuf); 675 kfree(outbuf);
672 kfree(inbuf); 676 kfree(inbuf);
673 677
674// printk("IDE Taskfile ioctl ended. rc = %i\n", err);
675
676 return err; 678 return err;
677} 679}
678#endif 680#endif
diff --git a/drivers/ide/palm_bk3710.c b/drivers/ide/palm_bk3710.c
index 3c1dc0152153..f8eddf05ecb8 100644
--- a/drivers/ide/palm_bk3710.c
+++ b/drivers/ide/palm_bk3710.c
@@ -318,7 +318,7 @@ static int __init palm_bk3710_probe(struct platform_device *pdev)
318 int i, rc; 318 int i, rc;
319 struct ide_hw hw, *hws[] = { &hw }; 319 struct ide_hw hw, *hws[] = { &hw };
320 320
321 clk = clk_get(&pdev->dev, "IDECLK"); 321 clk = clk_get(&pdev->dev, NULL);
322 if (IS_ERR(clk)) 322 if (IS_ERR(clk))
323 return -ENODEV; 323 return -ENODEV;
324 324
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 76f9668221a4..79cd3e9fdf2e 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * Based on a previous implementations by Kevin O'Connor 9 * Based on a previous implementations by Kevin O'Connor
10 * <kevin_at_koconnor.net> and Alex Osborne <bobofdoom@gmail.com> and 10 * <kevin_at_koconnor.net> and Alex Osborne <bobofdoom@gmail.com> and
11 * on some suggestions by Nicolas Pitre <nico@cam.org>. 11 * on some suggestions by Nicolas Pitre <nico@fluxnic.net>.
12 * 12 *
13 * 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
14 * 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
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index a0f68386c12f..588a5b0bc4b5 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -294,10 +294,11 @@ static void macio_setup_interrupts(struct macio_dev *dev)
294 int i = 0, j = 0; 294 int i = 0, j = 0;
295 295
296 for (;;) { 296 for (;;) {
297 struct resource *res = &dev->interrupt[j]; 297 struct resource *res;
298 298
299 if (j >= MACIO_DEV_COUNT_IRQS) 299 if (j >= MACIO_DEV_COUNT_IRQS)
300 break; 300 break;
301 res = &dev->interrupt[j];
301 irq = irq_of_parse_and_map(np, i++); 302 irq = irq_of_parse_and_map(np, i++);
302 if (irq == NO_IRQ) 303 if (irq == NO_IRQ)
303 break; 304 break;
@@ -321,9 +322,10 @@ static void macio_setup_resources(struct macio_dev *dev,
321 int index; 322 int index;
322 323
323 for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) { 324 for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) {
324 struct resource *res = &dev->resource[index]; 325 struct resource *res;
325 if (index >= MACIO_DEV_COUNT_RESOURCES) 326 if (index >= MACIO_DEV_COUNT_RESOURCES)
326 break; 327 break;
328 res = &dev->resource[index];
327 *res = r; 329 *res = r;
328 res->name = dev_name(&dev->ofdev.dev); 330 res->name = dev_name(&dev->ofdev.dev);
329 331
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 40023313a760..8b9364434aa0 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -239,8 +239,8 @@ setup_hardware( void )
239 * to be on the safe side (OSX doesn't)... 239 * to be on the safe side (OSX doesn't)...
240 */ 240 */
241 if( x.overheat_temp == (80 << 8) ) { 241 if( x.overheat_temp == (80 << 8) ) {
242 x.overheat_temp = 65 << 8; 242 x.overheat_temp = 75 << 8;
243 x.overheat_hyst = 60 << 8; 243 x.overheat_hyst = 70 << 8;
244 write_reg( x.thermostat, 2, x.overheat_hyst, 2 ); 244 write_reg( x.thermostat, 2, x.overheat_hyst, 2 );
245 write_reg( x.thermostat, 3, x.overheat_temp, 2 ); 245 write_reg( x.thermostat, 3, x.overheat_temp, 2 );
246 246
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c
index 16792a68a449..655474b29e21 100644
--- a/drivers/media/common/ir-functions.c
+++ b/drivers/media/common/ir-functions.c
@@ -58,13 +58,24 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
58/* -------------------------------------------------------------------------- */ 58/* -------------------------------------------------------------------------- */
59 59
60void ir_input_init(struct input_dev *dev, struct ir_input_state *ir, 60void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
61 int ir_type, IR_KEYTAB_TYPE *ir_codes) 61 int ir_type, struct ir_scancode_table *ir_codes)
62{ 62{
63 int i; 63 int i;
64 64
65 ir->ir_type = ir_type; 65 ir->ir_type = ir_type;
66
67 memset(ir->ir_codes, sizeof(ir->ir_codes), 0);
68
69 /*
70 * FIXME: This is a temporary workaround to use the new IR tables
71 * with the old approach. Later patches will replace this to a
72 * proper method
73 */
74
66 if (ir_codes) 75 if (ir_codes)
67 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); 76 for (i = 0; i < ir_codes->size; i++)
77 if (ir_codes->scan[i].scancode < IR_KEYTAB_SIZE)
78 ir->ir_codes[ir_codes->scan[i].scancode] = ir_codes->scan[i].keycode;
68 79
69 dev->keycode = ir->ir_codes; 80 dev->keycode = ir->ir_codes;
70 dev->keycodesize = sizeof(IR_KEYTAB_TYPE); 81 dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c
index 4216328552f6..f6790172736a 100644
--- a/drivers/media/common/ir-keymaps.c
+++ b/drivers/media/common/ir-keymaps.c
@@ -1,8 +1,6 @@
1/* 1/*
2 2 Keytables for supported remote controls, used on drivers/media
3 3 devices.
4 Keytables for supported remote controls. This file is part of
5 video4linux.
6 4
7 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -17,7 +15,13 @@
17 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
20 19
20/*
21 * NOTICE FOR DEVELOPERS:
22 * The IR mappings should be as close as possible to what's
23 * specified at:
24 * http://linuxtv.org/wiki/index.php/Remote_Controllers
21 */ 25 */
22#include <linux/module.h> 26#include <linux/module.h>
23 27
@@ -25,589 +29,627 @@
25#include <media/ir-common.h> 29#include <media/ir-common.h>
26 30
27/* empty keytable, can be used as placeholder for not-yet created keytables */ 31/* empty keytable, can be used as placeholder for not-yet created keytables */
28IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = { 32static struct ir_scancode ir_codes_empty[] = {
29 [ 0x2a ] = KEY_COFFEE, 33 { 0x2a, KEY_COFFEE },
30}; 34};
31 35
32EXPORT_SYMBOL_GPL(ir_codes_empty); 36struct ir_scancode_table ir_codes_empty_table = {
37 .scan = ir_codes_empty,
38 .size = ARRAY_SIZE(ir_codes_empty),
39};
40EXPORT_SYMBOL_GPL(ir_codes_empty_table);
33 41
34/* Michal Majchrowicz <mmajchrowicz@gmail.com> */ 42/* Michal Majchrowicz <mmajchrowicz@gmail.com> */
35IR_KEYTAB_TYPE ir_codes_proteus_2309[IR_KEYTAB_SIZE] = { 43static struct ir_scancode ir_codes_proteus_2309[] = {
36 /* numeric */ 44 /* numeric */
37 [ 0x00 ] = KEY_0, 45 { 0x00, KEY_0 },
38 [ 0x01 ] = KEY_1, 46 { 0x01, KEY_1 },
39 [ 0x02 ] = KEY_2, 47 { 0x02, KEY_2 },
40 [ 0x03 ] = KEY_3, 48 { 0x03, KEY_3 },
41 [ 0x04 ] = KEY_4, 49 { 0x04, KEY_4 },
42 [ 0x05 ] = KEY_5, 50 { 0x05, KEY_5 },
43 [ 0x06 ] = KEY_6, 51 { 0x06, KEY_6 },
44 [ 0x07 ] = KEY_7, 52 { 0x07, KEY_7 },
45 [ 0x08 ] = KEY_8, 53 { 0x08, KEY_8 },
46 [ 0x09 ] = KEY_9, 54 { 0x09, KEY_9 },
47 55
48 [ 0x5c ] = KEY_POWER, /* power */ 56 { 0x5c, KEY_POWER }, /* power */
49 [ 0x20 ] = KEY_F, /* full screen */ 57 { 0x20, KEY_ZOOM }, /* full screen */
50 [ 0x0f ] = KEY_BACKSPACE, /* recall */ 58 { 0x0f, KEY_BACKSPACE }, /* recall */
51 [ 0x1b ] = KEY_ENTER, /* mute */ 59 { 0x1b, KEY_ENTER }, /* mute */
52 [ 0x41 ] = KEY_RECORD, /* record */ 60 { 0x41, KEY_RECORD }, /* record */
53 [ 0x43 ] = KEY_STOP, /* stop */ 61 { 0x43, KEY_STOP }, /* stop */
54 [ 0x16 ] = KEY_S, 62 { 0x16, KEY_S },
55 [ 0x1a ] = KEY_Q, /* off */ 63 { 0x1a, KEY_POWER2 }, /* off */
56 [ 0x2e ] = KEY_RED, 64 { 0x2e, KEY_RED },
57 [ 0x1f ] = KEY_DOWN, /* channel - */ 65 { 0x1f, KEY_CHANNELDOWN }, /* channel - */
58 [ 0x1c ] = KEY_UP, /* channel + */ 66 { 0x1c, KEY_CHANNELUP }, /* channel + */
59 [ 0x10 ] = KEY_LEFT, /* volume - */ 67 { 0x10, KEY_VOLUMEDOWN }, /* volume - */
60 [ 0x1e ] = KEY_RIGHT, /* volume + */ 68 { 0x1e, KEY_VOLUMEUP }, /* volume + */
61 [ 0x14 ] = KEY_F1, 69 { 0x14, KEY_F1 },
62}; 70};
63 71
64EXPORT_SYMBOL_GPL(ir_codes_proteus_2309); 72struct ir_scancode_table ir_codes_proteus_2309_table = {
73 .scan = ir_codes_proteus_2309,
74 .size = ARRAY_SIZE(ir_codes_proteus_2309),
75};
76EXPORT_SYMBOL_GPL(ir_codes_proteus_2309_table);
77
65/* Matt Jesson <dvb@jesson.eclipse.co.uk */ 78/* Matt Jesson <dvb@jesson.eclipse.co.uk */
66IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE] = { 79static struct ir_scancode ir_codes_avermedia_dvbt[] = {
67 [ 0x28 ] = KEY_0, //'0' / 'enter' 80 { 0x28, KEY_0 }, /* '0' / 'enter' */
68 [ 0x22 ] = KEY_1, //'1' 81 { 0x22, KEY_1 }, /* '1' */
69 [ 0x12 ] = KEY_2, //'2' / 'up arrow' 82 { 0x12, KEY_2 }, /* '2' / 'up arrow' */
70 [ 0x32 ] = KEY_3, //'3' 83 { 0x32, KEY_3 }, /* '3' */
71 [ 0x24 ] = KEY_4, //'4' / 'left arrow' 84 { 0x24, KEY_4 }, /* '4' / 'left arrow' */
72 [ 0x14 ] = KEY_5, //'5' 85 { 0x14, KEY_5 }, /* '5' */
73 [ 0x34 ] = KEY_6, //'6' / 'right arrow' 86 { 0x34, KEY_6 }, /* '6' / 'right arrow' */
74 [ 0x26 ] = KEY_7, //'7' 87 { 0x26, KEY_7 }, /* '7' */
75 [ 0x16 ] = KEY_8, //'8' / 'down arrow' 88 { 0x16, KEY_8 }, /* '8' / 'down arrow' */
76 [ 0x36 ] = KEY_9, //'9' 89 { 0x36, KEY_9 }, /* '9' */
77 90
78 [ 0x20 ] = KEY_LIST, // 'source' 91 { 0x20, KEY_LIST }, /* 'source' */
79 [ 0x10 ] = KEY_TEXT, // 'teletext' 92 { 0x10, KEY_TEXT }, /* 'teletext' */
80 [ 0x00 ] = KEY_POWER, // 'power' 93 { 0x00, KEY_POWER }, /* 'power' */
81 [ 0x04 ] = KEY_AUDIO, // 'audio' 94 { 0x04, KEY_AUDIO }, /* 'audio' */
82 [ 0x06 ] = KEY_ZOOM, // 'full screen' 95 { 0x06, KEY_ZOOM }, /* 'full screen' */
83 [ 0x18 ] = KEY_VIDEO, // 'display' 96 { 0x18, KEY_VIDEO }, /* 'display' */
84 [ 0x38 ] = KEY_SEARCH, // 'loop' 97 { 0x38, KEY_SEARCH }, /* 'loop' */
85 [ 0x08 ] = KEY_INFO, // 'preview' 98 { 0x08, KEY_INFO }, /* 'preview' */
86 [ 0x2a ] = KEY_REWIND, // 'backward <<' 99 { 0x2a, KEY_REWIND }, /* 'backward <<' */
87 [ 0x1a ] = KEY_FASTFORWARD, // 'forward >>' 100 { 0x1a, KEY_FASTFORWARD }, /* 'forward >>' */
88 [ 0x3a ] = KEY_RECORD, // 'capture' 101 { 0x3a, KEY_RECORD }, /* 'capture' */
89 [ 0x0a ] = KEY_MUTE, // 'mute' 102 { 0x0a, KEY_MUTE }, /* 'mute' */
90 [ 0x2c ] = KEY_RECORD, // 'record' 103 { 0x2c, KEY_RECORD }, /* 'record' */
91 [ 0x1c ] = KEY_PAUSE, // 'pause' 104 { 0x1c, KEY_PAUSE }, /* 'pause' */
92 [ 0x3c ] = KEY_STOP, // 'stop' 105 { 0x3c, KEY_STOP }, /* 'stop' */
93 [ 0x0c ] = KEY_PLAY, // 'play' 106 { 0x0c, KEY_PLAY }, /* 'play' */
94 [ 0x2e ] = KEY_RED, // 'red' 107 { 0x2e, KEY_RED }, /* 'red' */
95 [ 0x01 ] = KEY_BLUE, // 'blue' / 'cancel' 108 { 0x01, KEY_BLUE }, /* 'blue' / 'cancel' */
96 [ 0x0e ] = KEY_YELLOW, // 'yellow' / 'ok' 109 { 0x0e, KEY_YELLOW }, /* 'yellow' / 'ok' */
97 [ 0x21 ] = KEY_GREEN, // 'green' 110 { 0x21, KEY_GREEN }, /* 'green' */
98 [ 0x11 ] = KEY_CHANNELDOWN, // 'channel -' 111 { 0x11, KEY_CHANNELDOWN }, /* 'channel -' */
99 [ 0x31 ] = KEY_CHANNELUP, // 'channel +' 112 { 0x31, KEY_CHANNELUP }, /* 'channel +' */
100 [ 0x1e ] = KEY_VOLUMEDOWN, // 'volume -' 113 { 0x1e, KEY_VOLUMEDOWN }, /* 'volume -' */
101 [ 0x3e ] = KEY_VOLUMEUP, // 'volume +' 114 { 0x3e, KEY_VOLUMEUP }, /* 'volume +' */
102}; 115};
103 116
104EXPORT_SYMBOL_GPL(ir_codes_avermedia_dvbt); 117struct ir_scancode_table ir_codes_avermedia_dvbt_table = {
118 .scan = ir_codes_avermedia_dvbt,
119 .size = ARRAY_SIZE(ir_codes_avermedia_dvbt),
120};
121EXPORT_SYMBOL_GPL(ir_codes_avermedia_dvbt_table);
105 122
106/* Mauro Carvalho Chehab <mchehab@infradead.org> */ 123/* Mauro Carvalho Chehab <mchehab@infradead.org> */
107IR_KEYTAB_TYPE ir_codes_avermedia_m135a[IR_KEYTAB_SIZE] = { 124static struct ir_scancode ir_codes_avermedia_m135a[] = {
108 [0x00] = KEY_POWER2, 125 { 0x00, KEY_POWER2 },
109 [0x2e] = KEY_DOT, /* '.' */ 126 { 0x2e, KEY_DOT }, /* '.' */
110 [0x01] = KEY_MODE, /* TV/FM */ 127 { 0x01, KEY_MODE }, /* TV/FM */
111 128
112 [0x05] = KEY_1, 129 { 0x05, KEY_1 },
113 [0x06] = KEY_2, 130 { 0x06, KEY_2 },
114 [0x07] = KEY_3, 131 { 0x07, KEY_3 },
115 [0x09] = KEY_4, 132 { 0x09, KEY_4 },
116 [0x0a] = KEY_5, 133 { 0x0a, KEY_5 },
117 [0x0b] = KEY_6, 134 { 0x0b, KEY_6 },
118 [0x0d] = KEY_7, 135 { 0x0d, KEY_7 },
119 [0x0e] = KEY_8, 136 { 0x0e, KEY_8 },
120 [0x0f] = KEY_9, 137 { 0x0f, KEY_9 },
121 [0x11] = KEY_0, 138 { 0x11, KEY_0 },
122 139
123 [0x13] = KEY_RIGHT, /* -> */ 140 { 0x13, KEY_RIGHT }, /* -> */
124 [0x12] = KEY_LEFT, /* <- */ 141 { 0x12, KEY_LEFT }, /* <- */
125 142
126 [0x17] = KEY_SLEEP, /* Capturar Imagem */ 143 { 0x17, KEY_SLEEP }, /* Capturar Imagem */
127 [0x10] = KEY_SHUFFLE, /* Amostra */ 144 { 0x10, KEY_SHUFFLE }, /* Amostra */
128 145
129 /* FIXME: The keys bellow aren't ok */ 146 /* FIXME: The keys bellow aren't ok */
130 147
131 [0x43] = KEY_CHANNELUP, 148 { 0x43, KEY_CHANNELUP },
132 [0x42] = KEY_CHANNELDOWN, 149 { 0x42, KEY_CHANNELDOWN },
133 [0x1f] = KEY_VOLUMEUP, 150 { 0x1f, KEY_VOLUMEUP },
134 [0x1e] = KEY_VOLUMEDOWN, 151 { 0x1e, KEY_VOLUMEDOWN },
135 [0x0c] = KEY_ENTER, 152 { 0x0c, KEY_ENTER },
136 153
137 [0x14] = KEY_MUTE, 154 { 0x14, KEY_MUTE },
138 [0x08] = KEY_AUDIO, 155 { 0x08, KEY_AUDIO },
139 156
140 [0x03] = KEY_TEXT, 157 { 0x03, KEY_TEXT },
141 [0x04] = KEY_EPG, 158 { 0x04, KEY_EPG },
142 [0x2b] = KEY_TV2, /* TV2 */ 159 { 0x2b, KEY_TV2 }, /* TV2 */
143 160
144 [0x1d] = KEY_RED, 161 { 0x1d, KEY_RED },
145 [0x1c] = KEY_YELLOW, 162 { 0x1c, KEY_YELLOW },
146 [0x41] = KEY_GREEN, 163 { 0x41, KEY_GREEN },
147 [0x40] = KEY_BLUE, 164 { 0x40, KEY_BLUE },
148 165
149 [0x1a] = KEY_PLAYPAUSE, 166 { 0x1a, KEY_PLAYPAUSE },
150 [0x19] = KEY_RECORD, 167 { 0x19, KEY_RECORD },
151 [0x18] = KEY_PLAY, 168 { 0x18, KEY_PLAY },
152 [0x1b] = KEY_STOP, 169 { 0x1b, KEY_STOP },
153}; 170};
154EXPORT_SYMBOL_GPL(ir_codes_avermedia_m135a); 171
172struct ir_scancode_table ir_codes_avermedia_m135a_table = {
173 .scan = ir_codes_avermedia_m135a,
174 .size = ARRAY_SIZE(ir_codes_avermedia_m135a),
175};
176EXPORT_SYMBOL_GPL(ir_codes_avermedia_m135a_table);
155 177
156/* Oldrich Jedlicka <oldium.pro@seznam.cz> */ 178/* Oldrich Jedlicka <oldium.pro@seznam.cz> */
157IR_KEYTAB_TYPE ir_codes_avermedia_cardbus[IR_KEYTAB_SIZE] = { 179static struct ir_scancode ir_codes_avermedia_cardbus[] = {
158 [0x00] = KEY_POWER, 180 { 0x00, KEY_POWER },
159 [0x01] = KEY_TUNER, /* TV/FM */ 181 { 0x01, KEY_TUNER }, /* TV/FM */
160 [0x03] = KEY_TEXT, /* Teletext */ 182 { 0x03, KEY_TEXT }, /* Teletext */
161 [0x04] = KEY_EPG, 183 { 0x04, KEY_EPG },
162 [0x05] = KEY_1, 184 { 0x05, KEY_1 },
163 [0x06] = KEY_2, 185 { 0x06, KEY_2 },
164 [0x07] = KEY_3, 186 { 0x07, KEY_3 },
165 [0x08] = KEY_AUDIO, 187 { 0x08, KEY_AUDIO },
166 [0x09] = KEY_4, 188 { 0x09, KEY_4 },
167 [0x0a] = KEY_5, 189 { 0x0a, KEY_5 },
168 [0x0b] = KEY_6, 190 { 0x0b, KEY_6 },
169 [0x0c] = KEY_ZOOM, /* Full screen */ 191 { 0x0c, KEY_ZOOM }, /* Full screen */
170 [0x0d] = KEY_7, 192 { 0x0d, KEY_7 },
171 [0x0e] = KEY_8, 193 { 0x0e, KEY_8 },
172 [0x0f] = KEY_9, 194 { 0x0f, KEY_9 },
173 [0x10] = KEY_PAGEUP, /* 16-CH PREV */ 195 { 0x10, KEY_PAGEUP }, /* 16-CH PREV */
174 [0x11] = KEY_0, 196 { 0x11, KEY_0 },
175 [0x12] = KEY_INFO, 197 { 0x12, KEY_INFO },
176 [0x13] = KEY_AGAIN, /* CH RTN - channel return */ 198 { 0x13, KEY_AGAIN }, /* CH RTN - channel return */
177 [0x14] = KEY_MUTE, 199 { 0x14, KEY_MUTE },
178 [0x15] = KEY_EDIT, /* Autoscan */ 200 { 0x15, KEY_EDIT }, /* Autoscan */
179 [0x17] = KEY_SAVE, /* Screenshot */ 201 { 0x17, KEY_SAVE }, /* Screenshot */
180 [0x18] = KEY_PLAYPAUSE, 202 { 0x18, KEY_PLAYPAUSE },
181 [0x19] = KEY_RECORD, 203 { 0x19, KEY_RECORD },
182 [0x1a] = KEY_PLAY, 204 { 0x1a, KEY_PLAY },
183 [0x1b] = KEY_STOP, 205 { 0x1b, KEY_STOP },
184 [0x1c] = KEY_FASTFORWARD, 206 { 0x1c, KEY_FASTFORWARD },
185 [0x1d] = KEY_REWIND, 207 { 0x1d, KEY_REWIND },
186 [0x1e] = KEY_VOLUMEDOWN, 208 { 0x1e, KEY_VOLUMEDOWN },
187 [0x1f] = KEY_VOLUMEUP, 209 { 0x1f, KEY_VOLUMEUP },
188 [0x22] = KEY_SLEEP, /* Sleep */ 210 { 0x22, KEY_SLEEP }, /* Sleep */
189 [0x23] = KEY_ZOOM, /* Aspect */ 211 { 0x23, KEY_ZOOM }, /* Aspect */
190 [0x26] = KEY_SCREEN, /* Pos */ 212 { 0x26, KEY_SCREEN }, /* Pos */
191 [0x27] = KEY_ANGLE, /* Size */ 213 { 0x27, KEY_ANGLE }, /* Size */
192 [0x28] = KEY_SELECT, /* Select */ 214 { 0x28, KEY_SELECT }, /* Select */
193 [0x29] = KEY_BLUE, /* Blue/Picture */ 215 { 0x29, KEY_BLUE }, /* Blue/Picture */
194 [0x2a] = KEY_BACKSPACE, /* Back */ 216 { 0x2a, KEY_BACKSPACE }, /* Back */
195 [0x2b] = KEY_MEDIA, /* PIP (Picture-in-picture) */ 217 { 0x2b, KEY_MEDIA }, /* PIP (Picture-in-picture) */
196 [0x2c] = KEY_DOWN, 218 { 0x2c, KEY_DOWN },
197 [0x2e] = KEY_DOT, 219 { 0x2e, KEY_DOT },
198 [0x2f] = KEY_TV, /* Live TV */ 220 { 0x2f, KEY_TV }, /* Live TV */
199 [0x32] = KEY_LEFT, 221 { 0x32, KEY_LEFT },
200 [0x33] = KEY_CLEAR, /* Clear */ 222 { 0x33, KEY_CLEAR }, /* Clear */
201 [0x35] = KEY_RED, /* Red/TV */ 223 { 0x35, KEY_RED }, /* Red/TV */
202 [0x36] = KEY_UP, 224 { 0x36, KEY_UP },
203 [0x37] = KEY_HOME, /* Home */ 225 { 0x37, KEY_HOME }, /* Home */
204 [0x39] = KEY_GREEN, /* Green/Video */ 226 { 0x39, KEY_GREEN }, /* Green/Video */
205 [0x3d] = KEY_YELLOW, /* Yellow/Music */ 227 { 0x3d, KEY_YELLOW }, /* Yellow/Music */
206 [0x3e] = KEY_OK, /* Ok */ 228 { 0x3e, KEY_OK }, /* Ok */
207 [0x3f] = KEY_RIGHT, 229 { 0x3f, KEY_RIGHT },
208 [0x40] = KEY_NEXT, /* Next */ 230 { 0x40, KEY_NEXT }, /* Next */
209 [0x41] = KEY_PREVIOUS, /* Previous */ 231 { 0x41, KEY_PREVIOUS }, /* Previous */
210 [0x42] = KEY_CHANNELDOWN, /* Channel down */ 232 { 0x42, KEY_CHANNELDOWN }, /* Channel down */
211 [0x43] = KEY_CHANNELUP /* Channel up */ 233 { 0x43, KEY_CHANNELUP }, /* Channel up */
212}; 234};
213EXPORT_SYMBOL_GPL(ir_codes_avermedia_cardbus); 235
236struct ir_scancode_table ir_codes_avermedia_cardbus_table = {
237 .scan = ir_codes_avermedia_cardbus,
238 .size = ARRAY_SIZE(ir_codes_avermedia_cardbus),
239};
240EXPORT_SYMBOL_GPL(ir_codes_avermedia_cardbus_table);
214 241
215/* Attila Kondoros <attila.kondoros@chello.hu> */ 242/* Attila Kondoros <attila.kondoros@chello.hu> */
216IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE] = { 243static struct ir_scancode ir_codes_apac_viewcomp[] = {
217 244
218 [ 0x01 ] = KEY_1, 245 { 0x01, KEY_1 },
219 [ 0x02 ] = KEY_2, 246 { 0x02, KEY_2 },
220 [ 0x03 ] = KEY_3, 247 { 0x03, KEY_3 },
221 [ 0x04 ] = KEY_4, 248 { 0x04, KEY_4 },
222 [ 0x05 ] = KEY_5, 249 { 0x05, KEY_5 },
223 [ 0x06 ] = KEY_6, 250 { 0x06, KEY_6 },
224 [ 0x07 ] = KEY_7, 251 { 0x07, KEY_7 },
225 [ 0x08 ] = KEY_8, 252 { 0x08, KEY_8 },
226 [ 0x09 ] = KEY_9, 253 { 0x09, KEY_9 },
227 [ 0x00 ] = KEY_0, 254 { 0x00, KEY_0 },
228 [ 0x17 ] = KEY_LAST, // +100 255 { 0x17, KEY_LAST }, /* +100 */
229 [ 0x0a ] = KEY_LIST, // recall 256 { 0x0a, KEY_LIST }, /* recall */
230 257
231 258
232 [ 0x1c ] = KEY_TUNER, // TV/FM 259 { 0x1c, KEY_TUNER }, /* TV/FM */
233 [ 0x15 ] = KEY_SEARCH, // scan 260 { 0x15, KEY_SEARCH }, /* scan */
234 [ 0x12 ] = KEY_POWER, // power 261 { 0x12, KEY_POWER }, /* power */
235 [ 0x1f ] = KEY_VOLUMEDOWN, // vol up 262 { 0x1f, KEY_VOLUMEDOWN }, /* vol up */
236 [ 0x1b ] = KEY_VOLUMEUP, // vol down 263 { 0x1b, KEY_VOLUMEUP }, /* vol down */
237 [ 0x1e ] = KEY_CHANNELDOWN, // chn up 264 { 0x1e, KEY_CHANNELDOWN }, /* chn up */
238 [ 0x1a ] = KEY_CHANNELUP, // chn down 265 { 0x1a, KEY_CHANNELUP }, /* chn down */
239 266
240 [ 0x11 ] = KEY_VIDEO, // video 267 { 0x11, KEY_VIDEO }, /* video */
241 [ 0x0f ] = KEY_ZOOM, // full screen 268 { 0x0f, KEY_ZOOM }, /* full screen */
242 [ 0x13 ] = KEY_MUTE, // mute/unmute 269 { 0x13, KEY_MUTE }, /* mute/unmute */
243 [ 0x10 ] = KEY_TEXT, // min 270 { 0x10, KEY_TEXT }, /* min */
244 271
245 [ 0x0d ] = KEY_STOP, // freeze 272 { 0x0d, KEY_STOP }, /* freeze */
246 [ 0x0e ] = KEY_RECORD, // record 273 { 0x0e, KEY_RECORD }, /* record */
247 [ 0x1d ] = KEY_PLAYPAUSE, // stop 274 { 0x1d, KEY_PLAYPAUSE }, /* stop */
248 [ 0x19 ] = KEY_PLAY, // play 275 { 0x19, KEY_PLAY }, /* play */
249 276
250 [ 0x16 ] = KEY_GOTO, // osd 277 { 0x16, KEY_GOTO }, /* osd */
251 [ 0x14 ] = KEY_REFRESH, // default 278 { 0x14, KEY_REFRESH }, /* default */
252 [ 0x0c ] = KEY_KPPLUS, // fine tune >>>> 279 { 0x0c, KEY_KPPLUS }, /* fine tune >>>> */
253 [ 0x18 ] = KEY_KPMINUS // fine tune <<<< 280 { 0x18, KEY_KPMINUS }, /* fine tune <<<< */
254}; 281};
255 282
256EXPORT_SYMBOL_GPL(ir_codes_apac_viewcomp); 283struct ir_scancode_table ir_codes_apac_viewcomp_table = {
284 .scan = ir_codes_apac_viewcomp,
285 .size = ARRAY_SIZE(ir_codes_apac_viewcomp),
286};
287EXPORT_SYMBOL_GPL(ir_codes_apac_viewcomp_table);
257 288
258/* ---------------------------------------------------------------------- */ 289/* ---------------------------------------------------------------------- */
259 290
260IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = { 291static struct ir_scancode ir_codes_pixelview[] = {
261 292
262 [ 0x1e ] = KEY_POWER, // power 293 { 0x1e, KEY_POWER }, /* power */
263 [ 0x07 ] = KEY_MEDIA, // source 294 { 0x07, KEY_MEDIA }, /* source */
264 [ 0x1c ] = KEY_SEARCH, // scan 295 { 0x1c, KEY_SEARCH }, /* scan */
265 296
266/* FIXME: duplicate keycodes?
267 *
268 * These four keys seem to share the same GPIO as CH+, CH-, <<< and >>>
269 * The GPIO values are
270 * 6397fb for both "Scan <" and "CH -",
271 * 639ffb for "Scan >" and "CH+",
272 * 6384fb for "Tune <" and "<<<",
273 * 638cfb for "Tune >" and ">>>", regardless of the mask.
274 *
275 * [ 0x17 ] = KEY_BACK, // fm scan <<
276 * [ 0x1f ] = KEY_FORWARD, // fm scan >>
277 *
278 * [ 0x04 ] = KEY_LEFT, // fm tuning <
279 * [ 0x0c ] = KEY_RIGHT, // fm tuning >
280 *
281 * For now, these four keys are disabled. Pressing them will generate
282 * the CH+/CH-/<<</>>> events
283 */
284 297
285 [ 0x03 ] = KEY_TUNER, // TV/FM 298 { 0x03, KEY_TUNER }, /* TV/FM */
286 299
287 [ 0x00 ] = KEY_RECORD, 300 { 0x00, KEY_RECORD },
288 [ 0x08 ] = KEY_STOP, 301 { 0x08, KEY_STOP },
289 [ 0x11 ] = KEY_PLAY, 302 { 0x11, KEY_PLAY },
290 303
291 [ 0x1a ] = KEY_PLAYPAUSE, // freeze 304 { 0x1a, KEY_PLAYPAUSE }, /* freeze */
292 [ 0x19 ] = KEY_ZOOM, // zoom 305 { 0x19, KEY_ZOOM }, /* zoom */
293 [ 0x0f ] = KEY_TEXT, // min 306 { 0x0f, KEY_TEXT }, /* min */
294 307
295 [ 0x01 ] = KEY_1, 308 { 0x01, KEY_1 },
296 [ 0x0b ] = KEY_2, 309 { 0x0b, KEY_2 },
297 [ 0x1b ] = KEY_3, 310 { 0x1b, KEY_3 },
298 [ 0x05 ] = KEY_4, 311 { 0x05, KEY_4 },
299 [ 0x09 ] = KEY_5, 312 { 0x09, KEY_5 },
300 [ 0x15 ] = KEY_6, 313 { 0x15, KEY_6 },
301 [ 0x06 ] = KEY_7, 314 { 0x06, KEY_7 },
302 [ 0x0a ] = KEY_8, 315 { 0x0a, KEY_8 },
303 [ 0x12 ] = KEY_9, 316 { 0x12, KEY_9 },
304 [ 0x02 ] = KEY_0, 317 { 0x02, KEY_0 },
305 [ 0x10 ] = KEY_LAST, // +100 318 { 0x10, KEY_LAST }, /* +100 */
306 [ 0x13 ] = KEY_LIST, // recall 319 { 0x13, KEY_LIST }, /* recall */
307 320
308 [ 0x1f ] = KEY_CHANNELUP, // chn down 321 { 0x1f, KEY_CHANNELUP }, /* chn down */
309 [ 0x17 ] = KEY_CHANNELDOWN, // chn up 322 { 0x17, KEY_CHANNELDOWN }, /* chn up */
310 [ 0x16 ] = KEY_VOLUMEUP, // vol down 323 { 0x16, KEY_VOLUMEUP }, /* vol down */
311 [ 0x14 ] = KEY_VOLUMEDOWN, // vol up 324 { 0x14, KEY_VOLUMEDOWN }, /* vol up */
312 325
313 [ 0x04 ] = KEY_KPMINUS, // <<< 326 { 0x04, KEY_KPMINUS }, /* <<< */
314 [ 0x0e ] = KEY_SETUP, // function 327 { 0x0e, KEY_SETUP }, /* function */
315 [ 0x0c ] = KEY_KPPLUS, // >>> 328 { 0x0c, KEY_KPPLUS }, /* >>> */
316 329
317 [ 0x0d ] = KEY_GOTO, // mts 330 { 0x0d, KEY_GOTO }, /* mts */
318 [ 0x1d ] = KEY_REFRESH, // reset 331 { 0x1d, KEY_REFRESH }, /* reset */
319 [ 0x18 ] = KEY_MUTE // mute/unmute 332 { 0x18, KEY_MUTE }, /* mute/unmute */
320}; 333};
321 334
322EXPORT_SYMBOL_GPL(ir_codes_pixelview); 335struct ir_scancode_table ir_codes_pixelview_table = {
336 .scan = ir_codes_pixelview,
337 .size = ARRAY_SIZE(ir_codes_pixelview),
338};
339EXPORT_SYMBOL_GPL(ir_codes_pixelview_table);
323 340
324/* 341/*
325 Mauro Carvalho Chehab <mchehab@infradead.org> 342 Mauro Carvalho Chehab <mchehab@infradead.org>
326 present on PV MPEG 8000GT 343 present on PV MPEG 8000GT
327 */ 344 */
328IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE] = { 345static struct ir_scancode ir_codes_pixelview_new[] = {
329 [0x3c] = KEY_PAUSE, /* Timeshift */ 346 { 0x3c, KEY_TIME }, /* Timeshift */
330 [0x12] = KEY_POWER, 347 { 0x12, KEY_POWER },
331 348
332 [0x3d] = KEY_1, 349 { 0x3d, KEY_1 },
333 [0x38] = KEY_2, 350 { 0x38, KEY_2 },
334 [0x18] = KEY_3, 351 { 0x18, KEY_3 },
335 [0x35] = KEY_4, 352 { 0x35, KEY_4 },
336 [0x39] = KEY_5, 353 { 0x39, KEY_5 },
337 [0x15] = KEY_6, 354 { 0x15, KEY_6 },
338 [0x36] = KEY_7, 355 { 0x36, KEY_7 },
339 [0x3a] = KEY_8, 356 { 0x3a, KEY_8 },
340 [0x1e] = KEY_9, 357 { 0x1e, KEY_9 },
341 [0x3e] = KEY_0, 358 { 0x3e, KEY_0 },
342 359
343 [0x1c] = KEY_AGAIN, /* LOOP */ 360 { 0x1c, KEY_AGAIN }, /* LOOP */
344 [0x3f] = KEY_MEDIA, /* Source */ 361 { 0x3f, KEY_MEDIA }, /* Source */
345 [0x1f] = KEY_LAST, /* +100 */ 362 { 0x1f, KEY_LAST }, /* +100 */
346 [0x1b] = KEY_MUTE, 363 { 0x1b, KEY_MUTE },
347 364
348 [0x17] = KEY_CHANNELDOWN, 365 { 0x17, KEY_CHANNELDOWN },
349 [0x16] = KEY_CHANNELUP, 366 { 0x16, KEY_CHANNELUP },
350 [0x10] = KEY_VOLUMEUP, 367 { 0x10, KEY_VOLUMEUP },
351 [0x14] = KEY_VOLUMEDOWN, 368 { 0x14, KEY_VOLUMEDOWN },
352 [0x13] = KEY_ZOOM, 369 { 0x13, KEY_ZOOM },
353 370
354 [0x19] = KEY_SHUFFLE, /* SNAPSHOT */ 371 { 0x19, KEY_CAMERA }, /* SNAPSHOT */
355 [0x1a] = KEY_SEARCH, /* scan */ 372 { 0x1a, KEY_SEARCH }, /* scan */
356 373
357 [0x37] = KEY_REWIND, /* << */ 374 { 0x37, KEY_REWIND }, /* << */
358 [0x32] = KEY_RECORD, /* o (red) */ 375 { 0x32, KEY_RECORD }, /* o (red) */
359 [0x33] = KEY_FORWARD, /* >> */ 376 { 0x33, KEY_FORWARD }, /* >> */
360 [0x11] = KEY_STOP, /* square */ 377 { 0x11, KEY_STOP }, /* square */
361 [0x3b] = KEY_PLAY, /* > */ 378 { 0x3b, KEY_PLAY }, /* > */
362 [0x30] = KEY_PLAYPAUSE, /* || */ 379 { 0x30, KEY_PLAYPAUSE }, /* || */
363 380
364 [0x31] = KEY_TV, 381 { 0x31, KEY_TV },
365 [0x34] = KEY_RADIO, 382 { 0x34, KEY_RADIO },
366}; 383};
367EXPORT_SYMBOL_GPL(ir_codes_pixelview_new); 384
368 385struct ir_scancode_table ir_codes_pixelview_new_table = {
369IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE] = { 386 .scan = ir_codes_pixelview_new,
370 [ 0x00 ] = KEY_0, 387 .size = ARRAY_SIZE(ir_codes_pixelview_new),
371 [ 0x01 ] = KEY_1, 388};
372 [ 0x02 ] = KEY_2, 389EXPORT_SYMBOL_GPL(ir_codes_pixelview_new_table);
373 [ 0x03 ] = KEY_3, 390
374 [ 0x04 ] = KEY_4, 391static struct ir_scancode ir_codes_nebula[] = {
375 [ 0x05 ] = KEY_5, 392 { 0x00, KEY_0 },
376 [ 0x06 ] = KEY_6, 393 { 0x01, KEY_1 },
377 [ 0x07 ] = KEY_7, 394 { 0x02, KEY_2 },
378 [ 0x08 ] = KEY_8, 395 { 0x03, KEY_3 },
379 [ 0x09 ] = KEY_9, 396 { 0x04, KEY_4 },
380 [ 0x0a ] = KEY_TV, 397 { 0x05, KEY_5 },
381 [ 0x0b ] = KEY_AUX, 398 { 0x06, KEY_6 },
382 [ 0x0c ] = KEY_DVD, 399 { 0x07, KEY_7 },
383 [ 0x0d ] = KEY_POWER, 400 { 0x08, KEY_8 },
384 [ 0x0e ] = KEY_MHP, /* labelled 'Picture' */ 401 { 0x09, KEY_9 },
385 [ 0x0f ] = KEY_AUDIO, 402 { 0x0a, KEY_TV },
386 [ 0x10 ] = KEY_INFO, 403 { 0x0b, KEY_AUX },
387 [ 0x11 ] = KEY_F13, /* 16:9 */ 404 { 0x0c, KEY_DVD },
388 [ 0x12 ] = KEY_F14, /* 14:9 */ 405 { 0x0d, KEY_POWER },
389 [ 0x13 ] = KEY_EPG, 406 { 0x0e, KEY_MHP }, /* labelled 'Picture' */
390 [ 0x14 ] = KEY_EXIT, 407 { 0x0f, KEY_AUDIO },
391 [ 0x15 ] = KEY_MENU, 408 { 0x10, KEY_INFO },
392 [ 0x16 ] = KEY_UP, 409 { 0x11, KEY_F13 }, /* 16:9 */
393 [ 0x17 ] = KEY_DOWN, 410 { 0x12, KEY_F14 }, /* 14:9 */
394 [ 0x18 ] = KEY_LEFT, 411 { 0x13, KEY_EPG },
395 [ 0x19 ] = KEY_RIGHT, 412 { 0x14, KEY_EXIT },
396 [ 0x1a ] = KEY_ENTER, 413 { 0x15, KEY_MENU },
397 [ 0x1b ] = KEY_CHANNELUP, 414 { 0x16, KEY_UP },
398 [ 0x1c ] = KEY_CHANNELDOWN, 415 { 0x17, KEY_DOWN },
399 [ 0x1d ] = KEY_VOLUMEUP, 416 { 0x18, KEY_LEFT },
400 [ 0x1e ] = KEY_VOLUMEDOWN, 417 { 0x19, KEY_RIGHT },
401 [ 0x1f ] = KEY_RED, 418 { 0x1a, KEY_ENTER },
402 [ 0x20 ] = KEY_GREEN, 419 { 0x1b, KEY_CHANNELUP },
403 [ 0x21 ] = KEY_YELLOW, 420 { 0x1c, KEY_CHANNELDOWN },
404 [ 0x22 ] = KEY_BLUE, 421 { 0x1d, KEY_VOLUMEUP },
405 [ 0x23 ] = KEY_SUBTITLE, 422 { 0x1e, KEY_VOLUMEDOWN },
406 [ 0x24 ] = KEY_F15, /* AD */ 423 { 0x1f, KEY_RED },
407 [ 0x25 ] = KEY_TEXT, 424 { 0x20, KEY_GREEN },
408 [ 0x26 ] = KEY_MUTE, 425 { 0x21, KEY_YELLOW },
409 [ 0x27 ] = KEY_REWIND, 426 { 0x22, KEY_BLUE },
410 [ 0x28 ] = KEY_STOP, 427 { 0x23, KEY_SUBTITLE },
411 [ 0x29 ] = KEY_PLAY, 428 { 0x24, KEY_F15 }, /* AD */
412 [ 0x2a ] = KEY_FASTFORWARD, 429 { 0x25, KEY_TEXT },
413 [ 0x2b ] = KEY_F16, /* chapter */ 430 { 0x26, KEY_MUTE },
414 [ 0x2c ] = KEY_PAUSE, 431 { 0x27, KEY_REWIND },
415 [ 0x2d ] = KEY_PLAY, 432 { 0x28, KEY_STOP },
416 [ 0x2e ] = KEY_RECORD, 433 { 0x29, KEY_PLAY },
417 [ 0x2f ] = KEY_F17, /* picture in picture */ 434 { 0x2a, KEY_FASTFORWARD },
418 [ 0x30 ] = KEY_KPPLUS, /* zoom in */ 435 { 0x2b, KEY_F16 }, /* chapter */
419 [ 0x31 ] = KEY_KPMINUS, /* zoom out */ 436 { 0x2c, KEY_PAUSE },
420 [ 0x32 ] = KEY_F18, /* capture */ 437 { 0x2d, KEY_PLAY },
421 [ 0x33 ] = KEY_F19, /* web */ 438 { 0x2e, KEY_RECORD },
422 [ 0x34 ] = KEY_EMAIL, 439 { 0x2f, KEY_F17 }, /* picture in picture */
423 [ 0x35 ] = KEY_PHONE, 440 { 0x30, KEY_KPPLUS }, /* zoom in */
424 [ 0x36 ] = KEY_PC 441 { 0x31, KEY_KPMINUS }, /* zoom out */
425}; 442 { 0x32, KEY_F18 }, /* capture */
426 443 { 0x33, KEY_F19 }, /* web */
427EXPORT_SYMBOL_GPL(ir_codes_nebula); 444 { 0x34, KEY_EMAIL },
445 { 0x35, KEY_PHONE },
446 { 0x36, KEY_PC },
447};
448
449struct ir_scancode_table ir_codes_nebula_table = {
450 .scan = ir_codes_nebula,
451 .size = ARRAY_SIZE(ir_codes_nebula),
452};
453EXPORT_SYMBOL_GPL(ir_codes_nebula_table);
428 454
429/* DigitalNow DNTV Live DVB-T Remote */ 455/* DigitalNow DNTV Live DVB-T Remote */
430IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = { 456static struct ir_scancode ir_codes_dntv_live_dvb_t[] = {
431 [ 0x00 ] = KEY_ESC, /* 'go up a level?' */ 457 { 0x00, KEY_ESC }, /* 'go up a level?' */
432 /* Keys 0 to 9 */ 458 /* Keys 0 to 9 */
433 [ 0x0a ] = KEY_0, 459 { 0x0a, KEY_0 },
434 [ 0x01 ] = KEY_1, 460 { 0x01, KEY_1 },
435 [ 0x02 ] = KEY_2, 461 { 0x02, KEY_2 },
436 [ 0x03 ] = KEY_3, 462 { 0x03, KEY_3 },
437 [ 0x04 ] = KEY_4, 463 { 0x04, KEY_4 },
438 [ 0x05 ] = KEY_5, 464 { 0x05, KEY_5 },
439 [ 0x06 ] = KEY_6, 465 { 0x06, KEY_6 },
440 [ 0x07 ] = KEY_7, 466 { 0x07, KEY_7 },
441 [ 0x08 ] = KEY_8, 467 { 0x08, KEY_8 },
442 [ 0x09 ] = KEY_9, 468 { 0x09, KEY_9 },
443 469
444 [ 0x0b ] = KEY_TUNER, /* tv/fm */ 470 { 0x0b, KEY_TUNER }, /* tv/fm */
445 [ 0x0c ] = KEY_SEARCH, /* scan */ 471 { 0x0c, KEY_SEARCH }, /* scan */
446 [ 0x0d ] = KEY_STOP, 472 { 0x0d, KEY_STOP },
447 [ 0x0e ] = KEY_PAUSE, 473 { 0x0e, KEY_PAUSE },
448 [ 0x0f ] = KEY_LIST, /* source */ 474 { 0x0f, KEY_LIST }, /* source */
449 475
450 [ 0x10 ] = KEY_MUTE, 476 { 0x10, KEY_MUTE },
451 [ 0x11 ] = KEY_REWIND, /* backward << */ 477 { 0x11, KEY_REWIND }, /* backward << */
452 [ 0x12 ] = KEY_POWER, 478 { 0x12, KEY_POWER },
453 [ 0x13 ] = KEY_S, /* snap */ 479 { 0x13, KEY_CAMERA }, /* snap */
454 [ 0x14 ] = KEY_AUDIO, /* stereo */ 480 { 0x14, KEY_AUDIO }, /* stereo */
455 [ 0x15 ] = KEY_CLEAR, /* reset */ 481 { 0x15, KEY_CLEAR }, /* reset */
456 [ 0x16 ] = KEY_PLAY, 482 { 0x16, KEY_PLAY },
457 [ 0x17 ] = KEY_ENTER, 483 { 0x17, KEY_ENTER },
458 [ 0x18 ] = KEY_ZOOM, /* full screen */ 484 { 0x18, KEY_ZOOM }, /* full screen */
459 [ 0x19 ] = KEY_FASTFORWARD, /* forward >> */ 485 { 0x19, KEY_FASTFORWARD }, /* forward >> */
460 [ 0x1a ] = KEY_CHANNELUP, 486 { 0x1a, KEY_CHANNELUP },
461 [ 0x1b ] = KEY_VOLUMEUP, 487 { 0x1b, KEY_VOLUMEUP },
462 [ 0x1c ] = KEY_INFO, /* preview */ 488 { 0x1c, KEY_INFO }, /* preview */
463 [ 0x1d ] = KEY_RECORD, /* record */ 489 { 0x1d, KEY_RECORD }, /* record */
464 [ 0x1e ] = KEY_CHANNELDOWN, 490 { 0x1e, KEY_CHANNELDOWN },
465 [ 0x1f ] = KEY_VOLUMEDOWN, 491 { 0x1f, KEY_VOLUMEDOWN },
466}; 492};
467 493
468EXPORT_SYMBOL_GPL(ir_codes_dntv_live_dvb_t); 494struct ir_scancode_table ir_codes_dntv_live_dvb_t_table = {
495 .scan = ir_codes_dntv_live_dvb_t,
496 .size = ARRAY_SIZE(ir_codes_dntv_live_dvb_t),
497};
498EXPORT_SYMBOL_GPL(ir_codes_dntv_live_dvb_t_table);
469 499
470/* ---------------------------------------------------------------------- */ 500/* ---------------------------------------------------------------------- */
471 501
472/* IO-DATA BCTV7E Remote */ 502/* IO-DATA BCTV7E Remote */
473IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = { 503static struct ir_scancode ir_codes_iodata_bctv7e[] = {
474 [ 0x40 ] = KEY_TV, 504 { 0x40, KEY_TV },
475 [ 0x20 ] = KEY_RADIO, /* FM */ 505 { 0x20, KEY_RADIO }, /* FM */
476 [ 0x60 ] = KEY_EPG, 506 { 0x60, KEY_EPG },
477 [ 0x00 ] = KEY_POWER, 507 { 0x00, KEY_POWER },
478 508
479 /* Keys 0 to 9 */ 509 /* Keys 0 to 9 */
480 [ 0x44 ] = KEY_0, /* 10 */ 510 { 0x44, KEY_0 }, /* 10 */
481 [ 0x50 ] = KEY_1, 511 { 0x50, KEY_1 },
482 [ 0x30 ] = KEY_2, 512 { 0x30, KEY_2 },
483 [ 0x70 ] = KEY_3, 513 { 0x70, KEY_3 },
484 [ 0x48 ] = KEY_4, 514 { 0x48, KEY_4 },
485 [ 0x28 ] = KEY_5, 515 { 0x28, KEY_5 },
486 [ 0x68 ] = KEY_6, 516 { 0x68, KEY_6 },
487 [ 0x58 ] = KEY_7, 517 { 0x58, KEY_7 },
488 [ 0x38 ] = KEY_8, 518 { 0x38, KEY_8 },
489 [ 0x78 ] = KEY_9, 519 { 0x78, KEY_9 },
490 520
491 [ 0x10 ] = KEY_L, /* Live */ 521 { 0x10, KEY_L }, /* Live */
492 [ 0x08 ] = KEY_T, /* Time Shift */ 522 { 0x08, KEY_TIME }, /* Time Shift */
493 523
494 [ 0x18 ] = KEY_PLAYPAUSE, /* Play */ 524 { 0x18, KEY_PLAYPAUSE }, /* Play */
495 525
496 [ 0x24 ] = KEY_ENTER, /* 11 */ 526 { 0x24, KEY_ENTER }, /* 11 */
497 [ 0x64 ] = KEY_ESC, /* 12 */ 527 { 0x64, KEY_ESC }, /* 12 */
498 [ 0x04 ] = KEY_M, /* Multi */ 528 { 0x04, KEY_M }, /* Multi */
499 529
500 [ 0x54 ] = KEY_VIDEO, 530 { 0x54, KEY_VIDEO },
501 [ 0x34 ] = KEY_CHANNELUP, 531 { 0x34, KEY_CHANNELUP },
502 [ 0x74 ] = KEY_VOLUMEUP, 532 { 0x74, KEY_VOLUMEUP },
503 [ 0x14 ] = KEY_MUTE, 533 { 0x14, KEY_MUTE },
504 534
505 [ 0x4c ] = KEY_S, /* SVIDEO */ 535 { 0x4c, KEY_VCR }, /* SVIDEO */
506 [ 0x2c ] = KEY_CHANNELDOWN, 536 { 0x2c, KEY_CHANNELDOWN },
507 [ 0x6c ] = KEY_VOLUMEDOWN, 537 { 0x6c, KEY_VOLUMEDOWN },
508 [ 0x0c ] = KEY_ZOOM, 538 { 0x0c, KEY_ZOOM },
509 539
510 [ 0x5c ] = KEY_PAUSE, 540 { 0x5c, KEY_PAUSE },
511 [ 0x3c ] = KEY_C, /* || (red) */ 541 { 0x3c, KEY_RED }, /* || (red) */
512 [ 0x7c ] = KEY_RECORD, /* recording */ 542 { 0x7c, KEY_RECORD }, /* recording */
513 [ 0x1c ] = KEY_STOP, 543 { 0x1c, KEY_STOP },
514 544
515 [ 0x41 ] = KEY_REWIND, /* backward << */ 545 { 0x41, KEY_REWIND }, /* backward << */
516 [ 0x21 ] = KEY_PLAY, 546 { 0x21, KEY_PLAY },
517 [ 0x61 ] = KEY_FASTFORWARD, /* forward >> */ 547 { 0x61, KEY_FASTFORWARD }, /* forward >> */
518 [ 0x01 ] = KEY_NEXT, /* skip >| */ 548 { 0x01, KEY_NEXT }, /* skip >| */
519}; 549};
520 550
521EXPORT_SYMBOL_GPL(ir_codes_iodata_bctv7e); 551struct ir_scancode_table ir_codes_iodata_bctv7e_table = {
552 .scan = ir_codes_iodata_bctv7e,
553 .size = ARRAY_SIZE(ir_codes_iodata_bctv7e),
554};
555EXPORT_SYMBOL_GPL(ir_codes_iodata_bctv7e_table);
522 556
523/* ---------------------------------------------------------------------- */ 557/* ---------------------------------------------------------------------- */
524 558
525/* ADS Tech Instant TV DVB-T PCI Remote */ 559/* ADS Tech Instant TV DVB-T PCI Remote */
526IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = { 560static struct ir_scancode ir_codes_adstech_dvb_t_pci[] = {
527 /* Keys 0 to 9 */ 561 /* Keys 0 to 9 */
528 [ 0x4d ] = KEY_0, 562 { 0x4d, KEY_0 },
529 [ 0x57 ] = KEY_1, 563 { 0x57, KEY_1 },
530 [ 0x4f ] = KEY_2, 564 { 0x4f, KEY_2 },
531 [ 0x53 ] = KEY_3, 565 { 0x53, KEY_3 },
532 [ 0x56 ] = KEY_4, 566 { 0x56, KEY_4 },
533 [ 0x4e ] = KEY_5, 567 { 0x4e, KEY_5 },
534 [ 0x5e ] = KEY_6, 568 { 0x5e, KEY_6 },
535 [ 0x54 ] = KEY_7, 569 { 0x54, KEY_7 },
536 [ 0x4c ] = KEY_8, 570 { 0x4c, KEY_8 },
537 [ 0x5c ] = KEY_9, 571 { 0x5c, KEY_9 },
538 572
539 [ 0x5b ] = KEY_POWER, 573 { 0x5b, KEY_POWER },
540 [ 0x5f ] = KEY_MUTE, 574 { 0x5f, KEY_MUTE },
541 [ 0x55 ] = KEY_GOTO, 575 { 0x55, KEY_GOTO },
542 [ 0x5d ] = KEY_SEARCH, 576 { 0x5d, KEY_SEARCH },
543 [ 0x17 ] = KEY_EPG, /* Guide */ 577 { 0x17, KEY_EPG }, /* Guide */
544 [ 0x1f ] = KEY_MENU, 578 { 0x1f, KEY_MENU },
545 [ 0x0f ] = KEY_UP, 579 { 0x0f, KEY_UP },
546 [ 0x46 ] = KEY_DOWN, 580 { 0x46, KEY_DOWN },
547 [ 0x16 ] = KEY_LEFT, 581 { 0x16, KEY_LEFT },
548 [ 0x1e ] = KEY_RIGHT, 582 { 0x1e, KEY_RIGHT },
549 [ 0x0e ] = KEY_SELECT, /* Enter */ 583 { 0x0e, KEY_SELECT }, /* Enter */
550 [ 0x5a ] = KEY_INFO, 584 { 0x5a, KEY_INFO },
551 [ 0x52 ] = KEY_EXIT, 585 { 0x52, KEY_EXIT },
552 [ 0x59 ] = KEY_PREVIOUS, 586 { 0x59, KEY_PREVIOUS },
553 [ 0x51 ] = KEY_NEXT, 587 { 0x51, KEY_NEXT },
554 [ 0x58 ] = KEY_REWIND, 588 { 0x58, KEY_REWIND },
555 [ 0x50 ] = KEY_FORWARD, 589 { 0x50, KEY_FORWARD },
556 [ 0x44 ] = KEY_PLAYPAUSE, 590 { 0x44, KEY_PLAYPAUSE },
557 [ 0x07 ] = KEY_STOP, 591 { 0x07, KEY_STOP },
558 [ 0x1b ] = KEY_RECORD, 592 { 0x1b, KEY_RECORD },
559 [ 0x13 ] = KEY_TUNER, /* Live */ 593 { 0x13, KEY_TUNER }, /* Live */
560 [ 0x0a ] = KEY_A, 594 { 0x0a, KEY_A },
561 [ 0x12 ] = KEY_B, 595 { 0x12, KEY_B },
562 [ 0x03 ] = KEY_PROG1, /* 1 */ 596 { 0x03, KEY_PROG1 }, /* 1 */
563 [ 0x01 ] = KEY_PROG2, /* 2 */ 597 { 0x01, KEY_PROG2 }, /* 2 */
564 [ 0x00 ] = KEY_PROG3, /* 3 */ 598 { 0x00, KEY_PROG3 }, /* 3 */
565 [ 0x06 ] = KEY_DVD, 599 { 0x06, KEY_DVD },
566 [ 0x48 ] = KEY_AUX, /* Photo */ 600 { 0x48, KEY_AUX }, /* Photo */
567 [ 0x40 ] = KEY_VIDEO, 601 { 0x40, KEY_VIDEO },
568 [ 0x19 ] = KEY_AUDIO, /* Music */ 602 { 0x19, KEY_AUDIO }, /* Music */
569 [ 0x0b ] = KEY_CHANNELUP, 603 { 0x0b, KEY_CHANNELUP },
570 [ 0x08 ] = KEY_CHANNELDOWN, 604 { 0x08, KEY_CHANNELDOWN },
571 [ 0x15 ] = KEY_VOLUMEUP, 605 { 0x15, KEY_VOLUMEUP },
572 [ 0x1c ] = KEY_VOLUMEDOWN, 606 { 0x1c, KEY_VOLUMEDOWN },
573}; 607};
574 608
575EXPORT_SYMBOL_GPL(ir_codes_adstech_dvb_t_pci); 609struct ir_scancode_table ir_codes_adstech_dvb_t_pci_table = {
610 .scan = ir_codes_adstech_dvb_t_pci,
611 .size = ARRAY_SIZE(ir_codes_adstech_dvb_t_pci),
612};
613EXPORT_SYMBOL_GPL(ir_codes_adstech_dvb_t_pci_table);
576 614
577/* ---------------------------------------------------------------------- */ 615/* ---------------------------------------------------------------------- */
578 616
579/* MSI TV@nywhere MASTER remote */ 617/* MSI TV@nywhere MASTER remote */
580 618
581IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = { 619static struct ir_scancode ir_codes_msi_tvanywhere[] = {
582 /* Keys 0 to 9 */ 620 /* Keys 0 to 9 */
583 [ 0x00 ] = KEY_0, 621 { 0x00, KEY_0 },
584 [ 0x01 ] = KEY_1, 622 { 0x01, KEY_1 },
585 [ 0x02 ] = KEY_2, 623 { 0x02, KEY_2 },
586 [ 0x03 ] = KEY_3, 624 { 0x03, KEY_3 },
587 [ 0x04 ] = KEY_4, 625 { 0x04, KEY_4 },
588 [ 0x05 ] = KEY_5, 626 { 0x05, KEY_5 },
589 [ 0x06 ] = KEY_6, 627 { 0x06, KEY_6 },
590 [ 0x07 ] = KEY_7, 628 { 0x07, KEY_7 },
591 [ 0x08 ] = KEY_8, 629 { 0x08, KEY_8 },
592 [ 0x09 ] = KEY_9, 630 { 0x09, KEY_9 },
593 631
594 [ 0x0c ] = KEY_MUTE, 632 { 0x0c, KEY_MUTE },
595 [ 0x0f ] = KEY_SCREEN, /* Full Screen */ 633 { 0x0f, KEY_SCREEN }, /* Full Screen */
596 [ 0x10 ] = KEY_F, /* Funtion */ 634 { 0x10, KEY_FN }, /* Funtion */
597 [ 0x11 ] = KEY_T, /* Time shift */ 635 { 0x11, KEY_TIME }, /* Time shift */
598 [ 0x12 ] = KEY_POWER, 636 { 0x12, KEY_POWER },
599 [ 0x13 ] = KEY_MEDIA, /* MTS */ 637 { 0x13, KEY_MEDIA }, /* MTS */
600 [ 0x14 ] = KEY_SLOW, 638 { 0x14, KEY_SLOW },
601 [ 0x16 ] = KEY_REWIND, /* backward << */ 639 { 0x16, KEY_REWIND }, /* backward << */
602 [ 0x17 ] = KEY_ENTER, /* Return */ 640 { 0x17, KEY_ENTER }, /* Return */
603 [ 0x18 ] = KEY_FASTFORWARD, /* forward >> */ 641 { 0x18, KEY_FASTFORWARD }, /* forward >> */
604 [ 0x1a ] = KEY_CHANNELUP, 642 { 0x1a, KEY_CHANNELUP },
605 [ 0x1b ] = KEY_VOLUMEUP, 643 { 0x1b, KEY_VOLUMEUP },
606 [ 0x1e ] = KEY_CHANNELDOWN, 644 { 0x1e, KEY_CHANNELDOWN },
607 [ 0x1f ] = KEY_VOLUMEDOWN, 645 { 0x1f, KEY_VOLUMEDOWN },
608}; 646};
609 647
610EXPORT_SYMBOL_GPL(ir_codes_msi_tvanywhere); 648struct ir_scancode_table ir_codes_msi_tvanywhere_table = {
649 .scan = ir_codes_msi_tvanywhere,
650 .size = ARRAY_SIZE(ir_codes_msi_tvanywhere),
651};
652EXPORT_SYMBOL_GPL(ir_codes_msi_tvanywhere_table);
611 653
612/* ---------------------------------------------------------------------- */ 654/* ---------------------------------------------------------------------- */
613 655
@@ -626,7 +668,7 @@ EXPORT_SYMBOL_GPL(ir_codes_msi_tvanywhere);
626 668
627*/ 669*/
628 670
629IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE] = { 671static struct ir_scancode ir_codes_msi_tvanywhere_plus[] = {
630 672
631/* ---- Remote Button Layout ---- 673/* ---- Remote Button Layout ----
632 674
@@ -648,596 +690,645 @@ IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE] = {
648 << FUNC >> RESET 690 << FUNC >> RESET
649*/ 691*/
650 692
651 [0x01] = KEY_KP1, /* 1 */ 693 { 0x01, KEY_1 }, /* 1 */
652 [0x0b] = KEY_KP2, /* 2 */ 694 { 0x0b, KEY_2 }, /* 2 */
653 [0x1b] = KEY_KP3, /* 3 */ 695 { 0x1b, KEY_3 }, /* 3 */
654 [0x05] = KEY_KP4, /* 4 */ 696 { 0x05, KEY_4 }, /* 4 */
655 [0x09] = KEY_KP5, /* 5 */ 697 { 0x09, KEY_5 }, /* 5 */
656 [0x15] = KEY_KP6, /* 6 */ 698 { 0x15, KEY_6 }, /* 6 */
657 [0x06] = KEY_KP7, /* 7 */ 699 { 0x06, KEY_7 }, /* 7 */
658 [0x0a] = KEY_KP8, /* 8 */ 700 { 0x0a, KEY_8 }, /* 8 */
659 [0x12] = KEY_KP9, /* 9 */ 701 { 0x12, KEY_9 }, /* 9 */
660 [0x02] = KEY_KP0, /* 0 */ 702 { 0x02, KEY_0 }, /* 0 */
661 [0x10] = KEY_KPPLUS, /* + */ 703 { 0x10, KEY_KPPLUS }, /* + */
662 [0x13] = KEY_AGAIN, /* Recall */ 704 { 0x13, KEY_AGAIN }, /* Recall */
663 705
664 [0x1e] = KEY_POWER, /* Power */ 706 { 0x1e, KEY_POWER }, /* Power */
665 [0x07] = KEY_TUNER, /* Source */ 707 { 0x07, KEY_TUNER }, /* Source */
666 [0x1c] = KEY_SEARCH, /* Scan */ 708 { 0x1c, KEY_SEARCH }, /* Scan */
667 [0x18] = KEY_MUTE, /* Mute */ 709 { 0x18, KEY_MUTE }, /* Mute */
668 710
669 [0x03] = KEY_RADIO, /* TV/FM */ 711 { 0x03, KEY_RADIO }, /* TV/FM */
670 /* The next four keys are duplicates that appear to send the 712 /* The next four keys are duplicates that appear to send the
671 same IR code as Ch+, Ch-, >>, and << . The raw code assigned 713 same IR code as Ch+, Ch-, >>, and << . The raw code assigned
672 to them is the actual code + 0x20 - they will never be 714 to them is the actual code + 0x20 - they will never be
673 detected as such unless some way is discovered to distinguish 715 detected as such unless some way is discovered to distinguish
674 these buttons from those that have the same code. */ 716 these buttons from those that have the same code. */
675 [0x3f] = KEY_RIGHT, /* |> and Ch+ */ 717 { 0x3f, KEY_RIGHT }, /* |> and Ch+ */
676 [0x37] = KEY_LEFT, /* <| and Ch- */ 718 { 0x37, KEY_LEFT }, /* <| and Ch- */
677 [0x2c] = KEY_UP, /* ^^Up and >> */ 719 { 0x2c, KEY_UP }, /* ^^Up and >> */
678 [0x24] = KEY_DOWN, /* vvDn and << */ 720 { 0x24, KEY_DOWN }, /* vvDn and << */
679 721
680 [0x00] = KEY_RECORD, /* Record */ 722 { 0x00, KEY_RECORD }, /* Record */
681 [0x08] = KEY_STOP, /* Stop */ 723 { 0x08, KEY_STOP }, /* Stop */
682 [0x11] = KEY_PLAY, /* Play */ 724 { 0x11, KEY_PLAY }, /* Play */
683 725
684 [0x0f] = KEY_CLOSE, /* Minimize */ 726 { 0x0f, KEY_CLOSE }, /* Minimize */
685 [0x19] = KEY_ZOOM, /* Zoom */ 727 { 0x19, KEY_ZOOM }, /* Zoom */
686 [0x1a] = KEY_SHUFFLE, /* Snapshot */ 728 { 0x1a, KEY_CAMERA }, /* Snapshot */
687 [0x0d] = KEY_LANGUAGE, /* MTS */ 729 { 0x0d, KEY_LANGUAGE }, /* MTS */
688 730
689 [0x14] = KEY_VOLUMEDOWN, /* Vol- */ 731 { 0x14, KEY_VOLUMEDOWN }, /* Vol- */
690 [0x16] = KEY_VOLUMEUP, /* Vol+ */ 732 { 0x16, KEY_VOLUMEUP }, /* Vol+ */
691 [0x17] = KEY_CHANNELDOWN, /* Ch- */ 733 { 0x17, KEY_CHANNELDOWN }, /* Ch- */
692 [0x1f] = KEY_CHANNELUP, /* Ch+ */ 734 { 0x1f, KEY_CHANNELUP }, /* Ch+ */
735
736 { 0x04, KEY_REWIND }, /* << */
737 { 0x0e, KEY_MENU }, /* Function */
738 { 0x0c, KEY_FASTFORWARD }, /* >> */
739 { 0x1d, KEY_RESTART }, /* Reset */
740};
693 741
694 [0x04] = KEY_REWIND, /* << */ 742struct ir_scancode_table ir_codes_msi_tvanywhere_plus_table = {
695 [0x0e] = KEY_MENU, /* Function */ 743 .scan = ir_codes_msi_tvanywhere_plus,
696 [0x0c] = KEY_FASTFORWARD, /* >> */ 744 .size = ARRAY_SIZE(ir_codes_msi_tvanywhere_plus),
697 [0x1d] = KEY_RESTART, /* Reset */
698}; 745};
699EXPORT_SYMBOL_GPL(ir_codes_msi_tvanywhere_plus); 746EXPORT_SYMBOL_GPL(ir_codes_msi_tvanywhere_plus_table);
700 747
701/* ---------------------------------------------------------------------- */ 748/* ---------------------------------------------------------------------- */
702 749
703/* Cinergy 1400 DVB-T */ 750/* Cinergy 1400 DVB-T */
704IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE] = { 751static struct ir_scancode ir_codes_cinergy_1400[] = {
705 [ 0x01 ] = KEY_POWER, 752 { 0x01, KEY_POWER },
706 [ 0x02 ] = KEY_1, 753 { 0x02, KEY_1 },
707 [ 0x03 ] = KEY_2, 754 { 0x03, KEY_2 },
708 [ 0x04 ] = KEY_3, 755 { 0x04, KEY_3 },
709 [ 0x05 ] = KEY_4, 756 { 0x05, KEY_4 },
710 [ 0x06 ] = KEY_5, 757 { 0x06, KEY_5 },
711 [ 0x07 ] = KEY_6, 758 { 0x07, KEY_6 },
712 [ 0x08 ] = KEY_7, 759 { 0x08, KEY_7 },
713 [ 0x09 ] = KEY_8, 760 { 0x09, KEY_8 },
714 [ 0x0a ] = KEY_9, 761 { 0x0a, KEY_9 },
715 [ 0x0c ] = KEY_0, 762 { 0x0c, KEY_0 },
716 763
717 [ 0x0b ] = KEY_VIDEO, 764 { 0x0b, KEY_VIDEO },
718 [ 0x0d ] = KEY_REFRESH, 765 { 0x0d, KEY_REFRESH },
719 [ 0x0e ] = KEY_SELECT, 766 { 0x0e, KEY_SELECT },
720 [ 0x0f ] = KEY_EPG, 767 { 0x0f, KEY_EPG },
721 [ 0x10 ] = KEY_UP, 768 { 0x10, KEY_UP },
722 [ 0x11 ] = KEY_LEFT, 769 { 0x11, KEY_LEFT },
723 [ 0x12 ] = KEY_OK, 770 { 0x12, KEY_OK },
724 [ 0x13 ] = KEY_RIGHT, 771 { 0x13, KEY_RIGHT },
725 [ 0x14 ] = KEY_DOWN, 772 { 0x14, KEY_DOWN },
726 [ 0x15 ] = KEY_TEXT, 773 { 0x15, KEY_TEXT },
727 [ 0x16 ] = KEY_INFO, 774 { 0x16, KEY_INFO },
728 775
729 [ 0x17 ] = KEY_RED, 776 { 0x17, KEY_RED },
730 [ 0x18 ] = KEY_GREEN, 777 { 0x18, KEY_GREEN },
731 [ 0x19 ] = KEY_YELLOW, 778 { 0x19, KEY_YELLOW },
732 [ 0x1a ] = KEY_BLUE, 779 { 0x1a, KEY_BLUE },
733 780
734 [ 0x1b ] = KEY_CHANNELUP, 781 { 0x1b, KEY_CHANNELUP },
735 [ 0x1c ] = KEY_VOLUMEUP, 782 { 0x1c, KEY_VOLUMEUP },
736 [ 0x1d ] = KEY_MUTE, 783 { 0x1d, KEY_MUTE },
737 [ 0x1e ] = KEY_VOLUMEDOWN, 784 { 0x1e, KEY_VOLUMEDOWN },
738 [ 0x1f ] = KEY_CHANNELDOWN, 785 { 0x1f, KEY_CHANNELDOWN },
739 786
740 [ 0x40 ] = KEY_PAUSE, 787 { 0x40, KEY_PAUSE },
741 [ 0x4c ] = KEY_PLAY, 788 { 0x4c, KEY_PLAY },
742 [ 0x58 ] = KEY_RECORD, 789 { 0x58, KEY_RECORD },
743 [ 0x54 ] = KEY_PREVIOUS, 790 { 0x54, KEY_PREVIOUS },
744 [ 0x48 ] = KEY_STOP, 791 { 0x48, KEY_STOP },
745 [ 0x5c ] = KEY_NEXT, 792 { 0x5c, KEY_NEXT },
746}; 793};
747 794
748EXPORT_SYMBOL_GPL(ir_codes_cinergy_1400); 795struct ir_scancode_table ir_codes_cinergy_1400_table = {
796 .scan = ir_codes_cinergy_1400,
797 .size = ARRAY_SIZE(ir_codes_cinergy_1400),
798};
799EXPORT_SYMBOL_GPL(ir_codes_cinergy_1400_table);
749 800
750/* ---------------------------------------------------------------------- */ 801/* ---------------------------------------------------------------------- */
751 802
752/* AVERTV STUDIO 303 Remote */ 803/* AVERTV STUDIO 303 Remote */
753IR_KEYTAB_TYPE ir_codes_avertv_303[IR_KEYTAB_SIZE] = { 804static struct ir_scancode ir_codes_avertv_303[] = {
754 [ 0x2a ] = KEY_1, 805 { 0x2a, KEY_1 },
755 [ 0x32 ] = KEY_2, 806 { 0x32, KEY_2 },
756 [ 0x3a ] = KEY_3, 807 { 0x3a, KEY_3 },
757 [ 0x4a ] = KEY_4, 808 { 0x4a, KEY_4 },
758 [ 0x52 ] = KEY_5, 809 { 0x52, KEY_5 },
759 [ 0x5a ] = KEY_6, 810 { 0x5a, KEY_6 },
760 [ 0x6a ] = KEY_7, 811 { 0x6a, KEY_7 },
761 [ 0x72 ] = KEY_8, 812 { 0x72, KEY_8 },
762 [ 0x7a ] = KEY_9, 813 { 0x7a, KEY_9 },
763 [ 0x0e ] = KEY_0, 814 { 0x0e, KEY_0 },
764 815
765 [ 0x02 ] = KEY_POWER, 816 { 0x02, KEY_POWER },
766 [ 0x22 ] = KEY_VIDEO, 817 { 0x22, KEY_VIDEO },
767 [ 0x42 ] = KEY_AUDIO, 818 { 0x42, KEY_AUDIO },
768 [ 0x62 ] = KEY_ZOOM, 819 { 0x62, KEY_ZOOM },
769 [ 0x0a ] = KEY_TV, 820 { 0x0a, KEY_TV },
770 [ 0x12 ] = KEY_CD, 821 { 0x12, KEY_CD },
771 [ 0x1a ] = KEY_TEXT, 822 { 0x1a, KEY_TEXT },
772 823
773 [ 0x16 ] = KEY_SUBTITLE, 824 { 0x16, KEY_SUBTITLE },
774 [ 0x1e ] = KEY_REWIND, 825 { 0x1e, KEY_REWIND },
775 [ 0x06 ] = KEY_PRINT, 826 { 0x06, KEY_PRINT },
776 827
777 [ 0x2e ] = KEY_SEARCH, 828 { 0x2e, KEY_SEARCH },
778 [ 0x36 ] = KEY_SLEEP, 829 { 0x36, KEY_SLEEP },
779 [ 0x3e ] = KEY_SHUFFLE, 830 { 0x3e, KEY_SHUFFLE },
780 [ 0x26 ] = KEY_MUTE, 831 { 0x26, KEY_MUTE },
781 832
782 [ 0x4e ] = KEY_RECORD, 833 { 0x4e, KEY_RECORD },
783 [ 0x56 ] = KEY_PAUSE, 834 { 0x56, KEY_PAUSE },
784 [ 0x5e ] = KEY_STOP, 835 { 0x5e, KEY_STOP },
785 [ 0x46 ] = KEY_PLAY, 836 { 0x46, KEY_PLAY },
786 837
787 [ 0x6e ] = KEY_RED, 838 { 0x6e, KEY_RED },
788 [ 0x0b ] = KEY_GREEN, 839 { 0x0b, KEY_GREEN },
789 [ 0x66 ] = KEY_YELLOW, 840 { 0x66, KEY_YELLOW },
790 [ 0x03 ] = KEY_BLUE, 841 { 0x03, KEY_BLUE },
791 842
792 [ 0x76 ] = KEY_LEFT, 843 { 0x76, KEY_LEFT },
793 [ 0x7e ] = KEY_RIGHT, 844 { 0x7e, KEY_RIGHT },
794 [ 0x13 ] = KEY_DOWN, 845 { 0x13, KEY_DOWN },
795 [ 0x1b ] = KEY_UP, 846 { 0x1b, KEY_UP },
796}; 847};
797 848
798EXPORT_SYMBOL_GPL(ir_codes_avertv_303); 849struct ir_scancode_table ir_codes_avertv_303_table = {
850 .scan = ir_codes_avertv_303,
851 .size = ARRAY_SIZE(ir_codes_avertv_303),
852};
853EXPORT_SYMBOL_GPL(ir_codes_avertv_303_table);
799 854
800/* ---------------------------------------------------------------------- */ 855/* ---------------------------------------------------------------------- */
801 856
802/* DigitalNow DNTV Live! DVB-T Pro Remote */ 857/* DigitalNow DNTV Live! DVB-T Pro Remote */
803IR_KEYTAB_TYPE ir_codes_dntv_live_dvbt_pro[IR_KEYTAB_SIZE] = { 858static struct ir_scancode ir_codes_dntv_live_dvbt_pro[] = {
804 [ 0x16 ] = KEY_POWER, 859 { 0x16, KEY_POWER },
805 [ 0x5b ] = KEY_HOME, 860 { 0x5b, KEY_HOME },
806 861
807 [ 0x55 ] = KEY_TV, /* live tv */ 862 { 0x55, KEY_TV }, /* live tv */
808 [ 0x58 ] = KEY_TUNER, /* digital Radio */ 863 { 0x58, KEY_TUNER }, /* digital Radio */
809 [ 0x5a ] = KEY_RADIO, /* FM radio */ 864 { 0x5a, KEY_RADIO }, /* FM radio */
810 [ 0x59 ] = KEY_DVD, /* dvd menu */ 865 { 0x59, KEY_DVD }, /* dvd menu */
811 [ 0x03 ] = KEY_1, 866 { 0x03, KEY_1 },
812 [ 0x01 ] = KEY_2, 867 { 0x01, KEY_2 },
813 [ 0x06 ] = KEY_3, 868 { 0x06, KEY_3 },
814 [ 0x09 ] = KEY_4, 869 { 0x09, KEY_4 },
815 [ 0x1d ] = KEY_5, 870 { 0x1d, KEY_5 },
816 [ 0x1f ] = KEY_6, 871 { 0x1f, KEY_6 },
817 [ 0x0d ] = KEY_7, 872 { 0x0d, KEY_7 },
818 [ 0x19 ] = KEY_8, 873 { 0x19, KEY_8 },
819 [ 0x1b ] = KEY_9, 874 { 0x1b, KEY_9 },
820 [ 0x0c ] = KEY_CANCEL, 875 { 0x0c, KEY_CANCEL },
821 [ 0x15 ] = KEY_0, 876 { 0x15, KEY_0 },
822 [ 0x4a ] = KEY_CLEAR, 877 { 0x4a, KEY_CLEAR },
823 [ 0x13 ] = KEY_BACK, 878 { 0x13, KEY_BACK },
824 [ 0x00 ] = KEY_TAB, 879 { 0x00, KEY_TAB },
825 [ 0x4b ] = KEY_UP, 880 { 0x4b, KEY_UP },
826 [ 0x4e ] = KEY_LEFT, 881 { 0x4e, KEY_LEFT },
827 [ 0x4f ] = KEY_OK, 882 { 0x4f, KEY_OK },
828 [ 0x52 ] = KEY_RIGHT, 883 { 0x52, KEY_RIGHT },
829 [ 0x51 ] = KEY_DOWN, 884 { 0x51, KEY_DOWN },
830 [ 0x1e ] = KEY_VOLUMEUP, 885 { 0x1e, KEY_VOLUMEUP },
831 [ 0x0a ] = KEY_VOLUMEDOWN, 886 { 0x0a, KEY_VOLUMEDOWN },
832 [ 0x02 ] = KEY_CHANNELDOWN, 887 { 0x02, KEY_CHANNELDOWN },
833 [ 0x05 ] = KEY_CHANNELUP, 888 { 0x05, KEY_CHANNELUP },
834 [ 0x11 ] = KEY_RECORD, 889 { 0x11, KEY_RECORD },
835 [ 0x14 ] = KEY_PLAY, 890 { 0x14, KEY_PLAY },
836 [ 0x4c ] = KEY_PAUSE, 891 { 0x4c, KEY_PAUSE },
837 [ 0x1a ] = KEY_STOP, 892 { 0x1a, KEY_STOP },
838 [ 0x40 ] = KEY_REWIND, 893 { 0x40, KEY_REWIND },
839 [ 0x12 ] = KEY_FASTFORWARD, 894 { 0x12, KEY_FASTFORWARD },
840 [ 0x41 ] = KEY_PREVIOUSSONG, /* replay |< */ 895 { 0x41, KEY_PREVIOUSSONG }, /* replay |< */
841 [ 0x42 ] = KEY_NEXTSONG, /* skip >| */ 896 { 0x42, KEY_NEXTSONG }, /* skip >| */
842 [ 0x54 ] = KEY_CAMERA, /* capture */ 897 { 0x54, KEY_CAMERA }, /* capture */
843 [ 0x50 ] = KEY_LANGUAGE, /* sap */ 898 { 0x50, KEY_LANGUAGE }, /* sap */
844 [ 0x47 ] = KEY_TV2, /* pip */ 899 { 0x47, KEY_TV2 }, /* pip */
845 [ 0x4d ] = KEY_SCREEN, 900 { 0x4d, KEY_SCREEN },
846 [ 0x43 ] = KEY_SUBTITLE, 901 { 0x43, KEY_SUBTITLE },
847 [ 0x10 ] = KEY_MUTE, 902 { 0x10, KEY_MUTE },
848 [ 0x49 ] = KEY_AUDIO, /* l/r */ 903 { 0x49, KEY_AUDIO }, /* l/r */
849 [ 0x07 ] = KEY_SLEEP, 904 { 0x07, KEY_SLEEP },
850 [ 0x08 ] = KEY_VIDEO, /* a/v */ 905 { 0x08, KEY_VIDEO }, /* a/v */
851 [ 0x0e ] = KEY_PREVIOUS, /* recall */ 906 { 0x0e, KEY_PREVIOUS }, /* recall */
852 [ 0x45 ] = KEY_ZOOM, /* zoom + */ 907 { 0x45, KEY_ZOOM }, /* zoom + */
853 [ 0x46 ] = KEY_ANGLE, /* zoom - */ 908 { 0x46, KEY_ANGLE }, /* zoom - */
854 [ 0x56 ] = KEY_RED, 909 { 0x56, KEY_RED },
855 [ 0x57 ] = KEY_GREEN, 910 { 0x57, KEY_GREEN },
856 [ 0x5c ] = KEY_YELLOW, 911 { 0x5c, KEY_YELLOW },
857 [ 0x5d ] = KEY_BLUE, 912 { 0x5d, KEY_BLUE },
858}; 913};
859 914
860EXPORT_SYMBOL_GPL(ir_codes_dntv_live_dvbt_pro); 915struct ir_scancode_table ir_codes_dntv_live_dvbt_pro_table = {
861 916 .scan = ir_codes_dntv_live_dvbt_pro,
862IR_KEYTAB_TYPE ir_codes_em_terratec[IR_KEYTAB_SIZE] = { 917 .size = ARRAY_SIZE(ir_codes_dntv_live_dvbt_pro),
863 [ 0x01 ] = KEY_CHANNEL, 918};
864 [ 0x02 ] = KEY_SELECT, 919EXPORT_SYMBOL_GPL(ir_codes_dntv_live_dvbt_pro_table);
865 [ 0x03 ] = KEY_MUTE, 920
866 [ 0x04 ] = KEY_POWER, 921static struct ir_scancode ir_codes_em_terratec[] = {
867 [ 0x05 ] = KEY_1, 922 { 0x01, KEY_CHANNEL },
868 [ 0x06 ] = KEY_2, 923 { 0x02, KEY_SELECT },
869 [ 0x07 ] = KEY_3, 924 { 0x03, KEY_MUTE },
870 [ 0x08 ] = KEY_CHANNELUP, 925 { 0x04, KEY_POWER },
871 [ 0x09 ] = KEY_4, 926 { 0x05, KEY_1 },
872 [ 0x0a ] = KEY_5, 927 { 0x06, KEY_2 },
873 [ 0x0b ] = KEY_6, 928 { 0x07, KEY_3 },
874 [ 0x0c ] = KEY_CHANNELDOWN, 929 { 0x08, KEY_CHANNELUP },
875 [ 0x0d ] = KEY_7, 930 { 0x09, KEY_4 },
876 [ 0x0e ] = KEY_8, 931 { 0x0a, KEY_5 },
877 [ 0x0f ] = KEY_9, 932 { 0x0b, KEY_6 },
878 [ 0x10 ] = KEY_VOLUMEUP, 933 { 0x0c, KEY_CHANNELDOWN },
879 [ 0x11 ] = KEY_0, 934 { 0x0d, KEY_7 },
880 [ 0x12 ] = KEY_MENU, 935 { 0x0e, KEY_8 },
881 [ 0x13 ] = KEY_PRINT, 936 { 0x0f, KEY_9 },
882 [ 0x14 ] = KEY_VOLUMEDOWN, 937 { 0x10, KEY_VOLUMEUP },
883 [ 0x16 ] = KEY_PAUSE, 938 { 0x11, KEY_0 },
884 [ 0x18 ] = KEY_RECORD, 939 { 0x12, KEY_MENU },
885 [ 0x19 ] = KEY_REWIND, 940 { 0x13, KEY_PRINT },
886 [ 0x1a ] = KEY_PLAY, 941 { 0x14, KEY_VOLUMEDOWN },
887 [ 0x1b ] = KEY_FORWARD, 942 { 0x16, KEY_PAUSE },
888 [ 0x1c ] = KEY_BACKSPACE, 943 { 0x18, KEY_RECORD },
889 [ 0x1e ] = KEY_STOP, 944 { 0x19, KEY_REWIND },
890 [ 0x40 ] = KEY_ZOOM, 945 { 0x1a, KEY_PLAY },
891}; 946 { 0x1b, KEY_FORWARD },
892 947 { 0x1c, KEY_BACKSPACE },
893EXPORT_SYMBOL_GPL(ir_codes_em_terratec); 948 { 0x1e, KEY_STOP },
894 949 { 0x40, KEY_ZOOM },
895IR_KEYTAB_TYPE ir_codes_pinnacle_grey[IR_KEYTAB_SIZE] = { 950};
896 [ 0x3a ] = KEY_0, 951
897 [ 0x31 ] = KEY_1, 952struct ir_scancode_table ir_codes_em_terratec_table = {
898 [ 0x32 ] = KEY_2, 953 .scan = ir_codes_em_terratec,
899 [ 0x33 ] = KEY_3, 954 .size = ARRAY_SIZE(ir_codes_em_terratec),
900 [ 0x34 ] = KEY_4, 955};
901 [ 0x35 ] = KEY_5, 956EXPORT_SYMBOL_GPL(ir_codes_em_terratec_table);
902 [ 0x36 ] = KEY_6, 957
903 [ 0x37 ] = KEY_7, 958static struct ir_scancode ir_codes_pinnacle_grey[] = {
904 [ 0x38 ] = KEY_8, 959 { 0x3a, KEY_0 },
905 [ 0x39 ] = KEY_9, 960 { 0x31, KEY_1 },
906 961 { 0x32, KEY_2 },
907 [ 0x2f ] = KEY_POWER, 962 { 0x33, KEY_3 },
908 963 { 0x34, KEY_4 },
909 [ 0x2e ] = KEY_P, 964 { 0x35, KEY_5 },
910 [ 0x1f ] = KEY_L, 965 { 0x36, KEY_6 },
911 [ 0x2b ] = KEY_I, 966 { 0x37, KEY_7 },
912 967 { 0x38, KEY_8 },
913 [ 0x2d ] = KEY_SCREEN, 968 { 0x39, KEY_9 },
914 [ 0x1e ] = KEY_ZOOM, 969
915 [ 0x1b ] = KEY_VOLUMEUP, 970 { 0x2f, KEY_POWER },
916 [ 0x0f ] = KEY_VOLUMEDOWN, 971
917 [ 0x17 ] = KEY_CHANNELUP, 972 { 0x2e, KEY_P },
918 [ 0x1c ] = KEY_CHANNELDOWN, 973 { 0x1f, KEY_L },
919 [ 0x25 ] = KEY_INFO, 974 { 0x2b, KEY_I },
920 975
921 [ 0x3c ] = KEY_MUTE, 976 { 0x2d, KEY_SCREEN },
922 977 { 0x1e, KEY_ZOOM },
923 [ 0x3d ] = KEY_LEFT, 978 { 0x1b, KEY_VOLUMEUP },
924 [ 0x3b ] = KEY_RIGHT, 979 { 0x0f, KEY_VOLUMEDOWN },
925 980 { 0x17, KEY_CHANNELUP },
926 [ 0x3f ] = KEY_UP, 981 { 0x1c, KEY_CHANNELDOWN },
927 [ 0x3e ] = KEY_DOWN, 982 { 0x25, KEY_INFO },
928 [ 0x1a ] = KEY_ENTER, 983
929 984 { 0x3c, KEY_MUTE },
930 [ 0x1d ] = KEY_MENU, 985
931 [ 0x19 ] = KEY_AGAIN, 986 { 0x3d, KEY_LEFT },
932 [ 0x16 ] = KEY_PREVIOUSSONG, 987 { 0x3b, KEY_RIGHT },
933 [ 0x13 ] = KEY_NEXTSONG, 988
934 [ 0x15 ] = KEY_PAUSE, 989 { 0x3f, KEY_UP },
935 [ 0x0e ] = KEY_REWIND, 990 { 0x3e, KEY_DOWN },
936 [ 0x0d ] = KEY_PLAY, 991 { 0x1a, KEY_ENTER },
937 [ 0x0b ] = KEY_STOP, 992
938 [ 0x07 ] = KEY_FORWARD, 993 { 0x1d, KEY_MENU },
939 [ 0x27 ] = KEY_RECORD, 994 { 0x19, KEY_AGAIN },
940 [ 0x26 ] = KEY_TUNER, 995 { 0x16, KEY_PREVIOUSSONG },
941 [ 0x29 ] = KEY_TEXT, 996 { 0x13, KEY_NEXTSONG },
942 [ 0x2a ] = KEY_MEDIA, 997 { 0x15, KEY_PAUSE },
943 [ 0x18 ] = KEY_EPG, 998 { 0x0e, KEY_REWIND },
944}; 999 { 0x0d, KEY_PLAY },
945 1000 { 0x0b, KEY_STOP },
946EXPORT_SYMBOL_GPL(ir_codes_pinnacle_grey); 1001 { 0x07, KEY_FORWARD },
947 1002 { 0x27, KEY_RECORD },
948IR_KEYTAB_TYPE ir_codes_flyvideo[IR_KEYTAB_SIZE] = { 1003 { 0x26, KEY_TUNER },
949 [ 0x0f ] = KEY_0, 1004 { 0x29, KEY_TEXT },
950 [ 0x03 ] = KEY_1, 1005 { 0x2a, KEY_MEDIA },
951 [ 0x04 ] = KEY_2, 1006 { 0x18, KEY_EPG },
952 [ 0x05 ] = KEY_3, 1007};
953 [ 0x07 ] = KEY_4, 1008
954 [ 0x08 ] = KEY_5, 1009struct ir_scancode_table ir_codes_pinnacle_grey_table = {
955 [ 0x09 ] = KEY_6, 1010 .scan = ir_codes_pinnacle_grey,
956 [ 0x0b ] = KEY_7, 1011 .size = ARRAY_SIZE(ir_codes_pinnacle_grey),
957 [ 0x0c ] = KEY_8, 1012};
958 [ 0x0d ] = KEY_9, 1013EXPORT_SYMBOL_GPL(ir_codes_pinnacle_grey_table);
959 1014
960 [ 0x0e ] = KEY_MODE, // Air/Cable 1015static struct ir_scancode ir_codes_flyvideo[] = {
961 [ 0x11 ] = KEY_VIDEO, // Video 1016 { 0x0f, KEY_0 },
962 [ 0x15 ] = KEY_AUDIO, // Audio 1017 { 0x03, KEY_1 },
963 [ 0x00 ] = KEY_POWER, // Power 1018 { 0x04, KEY_2 },
964 [ 0x18 ] = KEY_TUNER, // AV Source 1019 { 0x05, KEY_3 },
965 [ 0x02 ] = KEY_ZOOM, // Fullscreen 1020 { 0x07, KEY_4 },
966 [ 0x1a ] = KEY_LANGUAGE, // Stereo 1021 { 0x08, KEY_5 },
967 [ 0x1b ] = KEY_MUTE, // Mute 1022 { 0x09, KEY_6 },
968 [ 0x14 ] = KEY_VOLUMEUP, // Volume + 1023 { 0x0b, KEY_7 },
969 [ 0x17 ] = KEY_VOLUMEDOWN, // Volume - 1024 { 0x0c, KEY_8 },
970 [ 0x12 ] = KEY_CHANNELUP, // Channel + 1025 { 0x0d, KEY_9 },
971 [ 0x13 ] = KEY_CHANNELDOWN, // Channel - 1026
972 [ 0x06 ] = KEY_AGAIN, // Recall 1027 { 0x0e, KEY_MODE }, /* Air/Cable */
973 [ 0x10 ] = KEY_ENTER, // Enter 1028 { 0x11, KEY_VIDEO }, /* Video */
974 1029 { 0x15, KEY_AUDIO }, /* Audio */
975 [ 0x19 ] = KEY_BACK, // Rewind ( <<< ) 1030 { 0x00, KEY_POWER }, /* Power */
976 [ 0x1f ] = KEY_FORWARD, // Forward ( >>> ) 1031 { 0x18, KEY_TUNER }, /* AV Source */
977 [ 0x0a ] = KEY_ANGLE, // (no label, may be used as the PAUSE button) 1032 { 0x02, KEY_ZOOM }, /* Fullscreen */
978}; 1033 { 0x1a, KEY_LANGUAGE }, /* Stereo */
979 1034 { 0x1b, KEY_MUTE }, /* Mute */
980EXPORT_SYMBOL_GPL(ir_codes_flyvideo); 1035 { 0x14, KEY_VOLUMEUP }, /* Volume + */
981 1036 { 0x17, KEY_VOLUMEDOWN },/* Volume - */
982IR_KEYTAB_TYPE ir_codes_flydvb[IR_KEYTAB_SIZE] = { 1037 { 0x12, KEY_CHANNELUP },/* Channel + */
983 [ 0x01 ] = KEY_ZOOM, // Full Screen 1038 { 0x13, KEY_CHANNELDOWN },/* Channel - */
984 [ 0x00 ] = KEY_POWER, // Power 1039 { 0x06, KEY_AGAIN }, /* Recall */
985 1040 { 0x10, KEY_ENTER }, /* Enter */
986 [ 0x03 ] = KEY_1, 1041
987 [ 0x04 ] = KEY_2, 1042 { 0x19, KEY_BACK }, /* Rewind ( <<< ) */
988 [ 0x05 ] = KEY_3, 1043 { 0x1f, KEY_FORWARD }, /* Forward ( >>> ) */
989 [ 0x07 ] = KEY_4, 1044 { 0x0a, KEY_ANGLE }, /* no label, may be used as the PAUSE button */
990 [ 0x08 ] = KEY_5, 1045};
991 [ 0x09 ] = KEY_6, 1046
992 [ 0x0b ] = KEY_7, 1047struct ir_scancode_table ir_codes_flyvideo_table = {
993 [ 0x0c ] = KEY_8, 1048 .scan = ir_codes_flyvideo,
994 [ 0x0d ] = KEY_9, 1049 .size = ARRAY_SIZE(ir_codes_flyvideo),
995 [ 0x06 ] = KEY_AGAIN, // Recall 1050};
996 [ 0x0f ] = KEY_0, 1051EXPORT_SYMBOL_GPL(ir_codes_flyvideo_table);
997 [ 0x10 ] = KEY_MUTE, // Mute 1052
998 [ 0x02 ] = KEY_RADIO, // TV/Radio 1053static struct ir_scancode ir_codes_flydvb[] = {
999 [ 0x1b ] = KEY_LANGUAGE, // SAP (Second Audio Program) 1054 { 0x01, KEY_ZOOM }, /* Full Screen */
1000 1055 { 0x00, KEY_POWER }, /* Power */
1001 [ 0x14 ] = KEY_VOLUMEUP, // VOL+ 1056
1002 [ 0x17 ] = KEY_VOLUMEDOWN, // VOL- 1057 { 0x03, KEY_1 },
1003 [ 0x12 ] = KEY_CHANNELUP, // CH+ 1058 { 0x04, KEY_2 },
1004 [ 0x13 ] = KEY_CHANNELDOWN, // CH- 1059 { 0x05, KEY_3 },
1005 [ 0x1d ] = KEY_ENTER, // Enter 1060 { 0x07, KEY_4 },
1006 1061 { 0x08, KEY_5 },
1007 [ 0x1a ] = KEY_MODE, // PIP 1062 { 0x09, KEY_6 },
1008 [ 0x18 ] = KEY_TUNER, // Source 1063 { 0x0b, KEY_7 },
1009 1064 { 0x0c, KEY_8 },
1010 [ 0x1e ] = KEY_RECORD, // Record/Pause 1065 { 0x0d, KEY_9 },
1011 [ 0x15 ] = KEY_ANGLE, // Swap (no label on key) 1066 { 0x06, KEY_AGAIN }, /* Recall */
1012 [ 0x1c ] = KEY_PAUSE, // Timeshift/Pause 1067 { 0x0f, KEY_0 },
1013 [ 0x19 ] = KEY_BACK, // Rewind << 1068 { 0x10, KEY_MUTE }, /* Mute */
1014 [ 0x0a ] = KEY_PLAYPAUSE, // Play/Pause 1069 { 0x02, KEY_RADIO }, /* TV/Radio */
1015 [ 0x1f ] = KEY_FORWARD, // Forward >> 1070 { 0x1b, KEY_LANGUAGE }, /* SAP (Second Audio Program) */
1016 [ 0x16 ] = KEY_PREVIOUS, // Back |<< 1071
1017 [ 0x11 ] = KEY_STOP, // Stop 1072 { 0x14, KEY_VOLUMEUP }, /* VOL+ */
1018 [ 0x0e ] = KEY_NEXT, // End >>| 1073 { 0x17, KEY_VOLUMEDOWN }, /* VOL- */
1019}; 1074 { 0x12, KEY_CHANNELUP }, /* CH+ */
1020 1075 { 0x13, KEY_CHANNELDOWN }, /* CH- */
1021EXPORT_SYMBOL_GPL(ir_codes_flydvb); 1076 { 0x1d, KEY_ENTER }, /* Enter */
1022 1077
1023IR_KEYTAB_TYPE ir_codes_cinergy[IR_KEYTAB_SIZE] = { 1078 { 0x1a, KEY_MODE }, /* PIP */
1024 [ 0x00 ] = KEY_0, 1079 { 0x18, KEY_TUNER }, /* Source */
1025 [ 0x01 ] = KEY_1, 1080
1026 [ 0x02 ] = KEY_2, 1081 { 0x1e, KEY_RECORD }, /* Record/Pause */
1027 [ 0x03 ] = KEY_3, 1082 { 0x15, KEY_ANGLE }, /* Swap (no label on key) */
1028 [ 0x04 ] = KEY_4, 1083 { 0x1c, KEY_PAUSE }, /* Timeshift/Pause */
1029 [ 0x05 ] = KEY_5, 1084 { 0x19, KEY_BACK }, /* Rewind << */
1030 [ 0x06 ] = KEY_6, 1085 { 0x0a, KEY_PLAYPAUSE }, /* Play/Pause */
1031 [ 0x07 ] = KEY_7, 1086 { 0x1f, KEY_FORWARD }, /* Forward >> */
1032 [ 0x08 ] = KEY_8, 1087 { 0x16, KEY_PREVIOUS }, /* Back |<< */
1033 [ 0x09 ] = KEY_9, 1088 { 0x11, KEY_STOP }, /* Stop */
1034 1089 { 0x0e, KEY_NEXT }, /* End >>| */
1035 [ 0x0a ] = KEY_POWER, 1090};
1036 [ 0x0b ] = KEY_PROG1, // app 1091
1037 [ 0x0c ] = KEY_ZOOM, // zoom/fullscreen 1092struct ir_scancode_table ir_codes_flydvb_table = {
1038 [ 0x0d ] = KEY_CHANNELUP, // channel 1093 .scan = ir_codes_flydvb,
1039 [ 0x0e ] = KEY_CHANNELDOWN, // channel- 1094 .size = ARRAY_SIZE(ir_codes_flydvb),
1040 [ 0x0f ] = KEY_VOLUMEUP, 1095};
1041 [ 0x10 ] = KEY_VOLUMEDOWN, 1096EXPORT_SYMBOL_GPL(ir_codes_flydvb_table);
1042 [ 0x11 ] = KEY_TUNER, // AV 1097
1043 [ 0x12 ] = KEY_NUMLOCK, // -/-- 1098static struct ir_scancode ir_codes_cinergy[] = {
1044 [ 0x13 ] = KEY_AUDIO, // audio 1099 { 0x00, KEY_0 },
1045 [ 0x14 ] = KEY_MUTE, 1100 { 0x01, KEY_1 },
1046 [ 0x15 ] = KEY_UP, 1101 { 0x02, KEY_2 },
1047 [ 0x16 ] = KEY_DOWN, 1102 { 0x03, KEY_3 },
1048 [ 0x17 ] = KEY_LEFT, 1103 { 0x04, KEY_4 },
1049 [ 0x18 ] = KEY_RIGHT, 1104 { 0x05, KEY_5 },
1050 [ 0x19 ] = BTN_LEFT, 1105 { 0x06, KEY_6 },
1051 [ 0x1a ] = BTN_RIGHT, 1106 { 0x07, KEY_7 },
1052 [ 0x1b ] = KEY_WWW, // text 1107 { 0x08, KEY_8 },
1053 [ 0x1c ] = KEY_REWIND, 1108 { 0x09, KEY_9 },
1054 [ 0x1d ] = KEY_FORWARD, 1109
1055 [ 0x1e ] = KEY_RECORD, 1110 { 0x0a, KEY_POWER },
1056 [ 0x1f ] = KEY_PLAY, 1111 { 0x0b, KEY_PROG1 }, /* app */
1057 [ 0x20 ] = KEY_PREVIOUSSONG, 1112 { 0x0c, KEY_ZOOM }, /* zoom/fullscreen */
1058 [ 0x21 ] = KEY_NEXTSONG, 1113 { 0x0d, KEY_CHANNELUP }, /* channel */
1059 [ 0x22 ] = KEY_PAUSE, 1114 { 0x0e, KEY_CHANNELDOWN }, /* channel- */
1060 [ 0x23 ] = KEY_STOP, 1115 { 0x0f, KEY_VOLUMEUP },
1061}; 1116 { 0x10, KEY_VOLUMEDOWN },
1062 1117 { 0x11, KEY_TUNER }, /* AV */
1063EXPORT_SYMBOL_GPL(ir_codes_cinergy); 1118 { 0x12, KEY_NUMLOCK }, /* -/-- */
1119 { 0x13, KEY_AUDIO }, /* audio */
1120 { 0x14, KEY_MUTE },
1121 { 0x15, KEY_UP },
1122 { 0x16, KEY_DOWN },
1123 { 0x17, KEY_LEFT },
1124 { 0x18, KEY_RIGHT },
1125 { 0x19, BTN_LEFT, },
1126 { 0x1a, BTN_RIGHT, },
1127 { 0x1b, KEY_WWW }, /* text */
1128 { 0x1c, KEY_REWIND },
1129 { 0x1d, KEY_FORWARD },
1130 { 0x1e, KEY_RECORD },
1131 { 0x1f, KEY_PLAY },
1132 { 0x20, KEY_PREVIOUSSONG },
1133 { 0x21, KEY_NEXTSONG },
1134 { 0x22, KEY_PAUSE },
1135 { 0x23, KEY_STOP },
1136};
1137
1138struct ir_scancode_table ir_codes_cinergy_table = {
1139 .scan = ir_codes_cinergy,
1140 .size = ARRAY_SIZE(ir_codes_cinergy),
1141};
1142EXPORT_SYMBOL_GPL(ir_codes_cinergy_table);
1064 1143
1065/* Alfons Geser <a.geser@cox.net> 1144/* Alfons Geser <a.geser@cox.net>
1066 * updates from Job D. R. Borges <jobdrb@ig.com.br> */ 1145 * updates from Job D. R. Borges <jobdrb@ig.com.br> */
1067IR_KEYTAB_TYPE ir_codes_eztv[IR_KEYTAB_SIZE] = { 1146static struct ir_scancode ir_codes_eztv[] = {
1068 [ 0x12 ] = KEY_POWER, 1147 { 0x12, KEY_POWER },
1069 [ 0x01 ] = KEY_TV, // DVR 1148 { 0x01, KEY_TV }, /* DVR */
1070 [ 0x15 ] = KEY_DVD, // DVD 1149 { 0x15, KEY_DVD }, /* DVD */
1071 [ 0x17 ] = KEY_AUDIO, // music 1150 { 0x17, KEY_AUDIO }, /* music */
1072 // DVR mode / DVD mode / music mode 1151 /* DVR mode / DVD mode / music mode */
1073 1152
1074 [ 0x1b ] = KEY_MUTE, // mute 1153 { 0x1b, KEY_MUTE }, /* mute */
1075 [ 0x02 ] = KEY_LANGUAGE, // MTS/SAP / audio / autoseek 1154 { 0x02, KEY_LANGUAGE }, /* MTS/SAP / audio / autoseek */
1076 [ 0x1e ] = KEY_SUBTITLE, // closed captioning / subtitle / seek 1155 { 0x1e, KEY_SUBTITLE }, /* closed captioning / subtitle / seek */
1077 [ 0x16 ] = KEY_ZOOM, // full screen 1156 { 0x16, KEY_ZOOM }, /* full screen */
1078 [ 0x1c ] = KEY_VIDEO, // video source / eject / delall 1157 { 0x1c, KEY_VIDEO }, /* video source / eject / delall */
1079 [ 0x1d ] = KEY_RESTART, // playback / angle / del 1158 { 0x1d, KEY_RESTART }, /* playback / angle / del */
1080 [ 0x2f ] = KEY_SEARCH, // scan / menu / playlist 1159 { 0x2f, KEY_SEARCH }, /* scan / menu / playlist */
1081 [ 0x30 ] = KEY_CHANNEL, // CH surfing / bookmark / memo 1160 { 0x30, KEY_CHANNEL }, /* CH surfing / bookmark / memo */
1082 1161
1083 [ 0x31 ] = KEY_HELP, // help 1162 { 0x31, KEY_HELP }, /* help */
1084 [ 0x32 ] = KEY_MODE, // num/memo 1163 { 0x32, KEY_MODE }, /* num/memo */
1085 [ 0x33 ] = KEY_ESC, // cancel 1164 { 0x33, KEY_ESC }, /* cancel */
1086 1165
1087 [ 0x0c ] = KEY_UP, // up 1166 { 0x0c, KEY_UP }, /* up */
1088 [ 0x10 ] = KEY_DOWN, // down 1167 { 0x10, KEY_DOWN }, /* down */
1089 [ 0x08 ] = KEY_LEFT, // left 1168 { 0x08, KEY_LEFT }, /* left */
1090 [ 0x04 ] = KEY_RIGHT, // right 1169 { 0x04, KEY_RIGHT }, /* right */
1091 [ 0x03 ] = KEY_SELECT, // select 1170 { 0x03, KEY_SELECT }, /* select */
1092 1171
1093 [ 0x1f ] = KEY_REWIND, // rewind 1172 { 0x1f, KEY_REWIND }, /* rewind */
1094 [ 0x20 ] = KEY_PLAYPAUSE, // play/pause 1173 { 0x20, KEY_PLAYPAUSE },/* play/pause */
1095 [ 0x29 ] = KEY_FORWARD, // forward 1174 { 0x29, KEY_FORWARD }, /* forward */
1096 [ 0x14 ] = KEY_AGAIN, // repeat 1175 { 0x14, KEY_AGAIN }, /* repeat */
1097 [ 0x2b ] = KEY_RECORD, // recording 1176 { 0x2b, KEY_RECORD }, /* recording */
1098 [ 0x2c ] = KEY_STOP, // stop 1177 { 0x2c, KEY_STOP }, /* stop */
1099 [ 0x2d ] = KEY_PLAY, // play 1178 { 0x2d, KEY_PLAY }, /* play */
1100 [ 0x2e ] = KEY_SHUFFLE, // snapshot / shuffle 1179 { 0x2e, KEY_CAMERA }, /* snapshot / shuffle */
1101 1180
1102 [ 0x00 ] = KEY_0, 1181 { 0x00, KEY_0 },
1103 [ 0x05 ] = KEY_1, 1182 { 0x05, KEY_1 },
1104 [ 0x06 ] = KEY_2, 1183 { 0x06, KEY_2 },
1105 [ 0x07 ] = KEY_3, 1184 { 0x07, KEY_3 },
1106 [ 0x09 ] = KEY_4, 1185 { 0x09, KEY_4 },
1107 [ 0x0a ] = KEY_5, 1186 { 0x0a, KEY_5 },
1108 [ 0x0b ] = KEY_6, 1187 { 0x0b, KEY_6 },
1109 [ 0x0d ] = KEY_7, 1188 { 0x0d, KEY_7 },
1110 [ 0x0e ] = KEY_8, 1189 { 0x0e, KEY_8 },
1111 [ 0x0f ] = KEY_9, 1190 { 0x0f, KEY_9 },
1112 1191
1113 [ 0x2a ] = KEY_VOLUMEUP, 1192 { 0x2a, KEY_VOLUMEUP },
1114 [ 0x11 ] = KEY_VOLUMEDOWN, 1193 { 0x11, KEY_VOLUMEDOWN },
1115 [ 0x18 ] = KEY_CHANNELUP, // CH.tracking up 1194 { 0x18, KEY_CHANNELUP },/* CH.tracking up */
1116 [ 0x19 ] = KEY_CHANNELDOWN, // CH.tracking down 1195 { 0x19, KEY_CHANNELDOWN },/* CH.tracking down */
1117 1196
1118 [ 0x13 ] = KEY_ENTER, // enter 1197 { 0x13, KEY_ENTER }, /* enter */
1119 [ 0x21 ] = KEY_DOT, // . (decimal dot) 1198 { 0x21, KEY_DOT }, /* . (decimal dot) */
1120}; 1199};
1121 1200
1122EXPORT_SYMBOL_GPL(ir_codes_eztv); 1201struct ir_scancode_table ir_codes_eztv_table = {
1202 .scan = ir_codes_eztv,
1203 .size = ARRAY_SIZE(ir_codes_eztv),
1204};
1205EXPORT_SYMBOL_GPL(ir_codes_eztv_table);
1123 1206
1124/* Alex Hermann <gaaf@gmx.net> */ 1207/* Alex Hermann <gaaf@gmx.net> */
1125IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE] = { 1208static struct ir_scancode ir_codes_avermedia[] = {
1126 [ 0x28 ] = KEY_1, 1209 { 0x28, KEY_1 },
1127 [ 0x18 ] = KEY_2, 1210 { 0x18, KEY_2 },
1128 [ 0x38 ] = KEY_3, 1211 { 0x38, KEY_3 },
1129 [ 0x24 ] = KEY_4, 1212 { 0x24, KEY_4 },
1130 [ 0x14 ] = KEY_5, 1213 { 0x14, KEY_5 },
1131 [ 0x34 ] = KEY_6, 1214 { 0x34, KEY_6 },
1132 [ 0x2c ] = KEY_7, 1215 { 0x2c, KEY_7 },
1133 [ 0x1c ] = KEY_8, 1216 { 0x1c, KEY_8 },
1134 [ 0x3c ] = KEY_9, 1217 { 0x3c, KEY_9 },
1135 [ 0x22 ] = KEY_0, 1218 { 0x22, KEY_0 },
1136 1219
1137 [ 0x20 ] = KEY_TV, /* TV/FM */ 1220 { 0x20, KEY_TV }, /* TV/FM */
1138 [ 0x10 ] = KEY_CD, /* CD */ 1221 { 0x10, KEY_CD }, /* CD */
1139 [ 0x30 ] = KEY_TEXT, /* TELETEXT */ 1222 { 0x30, KEY_TEXT }, /* TELETEXT */
1140 [ 0x00 ] = KEY_POWER, /* POWER */ 1223 { 0x00, KEY_POWER }, /* POWER */
1141 1224
1142 [ 0x08 ] = KEY_VIDEO, /* VIDEO */ 1225 { 0x08, KEY_VIDEO }, /* VIDEO */
1143 [ 0x04 ] = KEY_AUDIO, /* AUDIO */ 1226 { 0x04, KEY_AUDIO }, /* AUDIO */
1144 [ 0x0c ] = KEY_ZOOM, /* FULL SCREEN */ 1227 { 0x0c, KEY_ZOOM }, /* FULL SCREEN */
1145 1228
1146 [ 0x12 ] = KEY_SUBTITLE, /* DISPLAY */ 1229 { 0x12, KEY_SUBTITLE }, /* DISPLAY */
1147 [ 0x32 ] = KEY_REWIND, /* LOOP */ 1230 { 0x32, KEY_REWIND }, /* LOOP */
1148 [ 0x02 ] = KEY_PRINT, /* PREVIEW */ 1231 { 0x02, KEY_PRINT }, /* PREVIEW */
1149 1232
1150 [ 0x2a ] = KEY_SEARCH, /* AUTOSCAN */ 1233 { 0x2a, KEY_SEARCH }, /* AUTOSCAN */
1151 [ 0x1a ] = KEY_SLEEP, /* FREEZE */ 1234 { 0x1a, KEY_SLEEP }, /* FREEZE */
1152 [ 0x3a ] = KEY_SHUFFLE, /* SNAPSHOT */ 1235 { 0x3a, KEY_CAMERA }, /* SNAPSHOT */
1153 [ 0x0a ] = KEY_MUTE, /* MUTE */ 1236 { 0x0a, KEY_MUTE }, /* MUTE */
1154 1237
1155 [ 0x26 ] = KEY_RECORD, /* RECORD */ 1238 { 0x26, KEY_RECORD }, /* RECORD */
1156 [ 0x16 ] = KEY_PAUSE, /* PAUSE */ 1239 { 0x16, KEY_PAUSE }, /* PAUSE */
1157 [ 0x36 ] = KEY_STOP, /* STOP */ 1240 { 0x36, KEY_STOP }, /* STOP */
1158 [ 0x06 ] = KEY_PLAY, /* PLAY */ 1241 { 0x06, KEY_PLAY }, /* PLAY */
1159 1242
1160 [ 0x2e ] = KEY_RED, /* RED */ 1243 { 0x2e, KEY_RED }, /* RED */
1161 [ 0x21 ] = KEY_GREEN, /* GREEN */ 1244 { 0x21, KEY_GREEN }, /* GREEN */
1162 [ 0x0e ] = KEY_YELLOW, /* YELLOW */ 1245 { 0x0e, KEY_YELLOW }, /* YELLOW */
1163 [ 0x01 ] = KEY_BLUE, /* BLUE */ 1246 { 0x01, KEY_BLUE }, /* BLUE */
1164 1247
1165 [ 0x1e ] = KEY_VOLUMEDOWN, /* VOLUME- */ 1248 { 0x1e, KEY_VOLUMEDOWN }, /* VOLUME- */
1166 [ 0x3e ] = KEY_VOLUMEUP, /* VOLUME+ */ 1249 { 0x3e, KEY_VOLUMEUP }, /* VOLUME+ */
1167 [ 0x11 ] = KEY_CHANNELDOWN, /* CHANNEL/PAGE- */ 1250 { 0x11, KEY_CHANNELDOWN }, /* CHANNEL/PAGE- */
1168 [ 0x31 ] = KEY_CHANNELUP /* CHANNEL/PAGE+ */ 1251 { 0x31, KEY_CHANNELUP } /* CHANNEL/PAGE+ */
1169}; 1252};
1170 1253
1171EXPORT_SYMBOL_GPL(ir_codes_avermedia); 1254struct ir_scancode_table ir_codes_avermedia_table = {
1172 1255 .scan = ir_codes_avermedia,
1173IR_KEYTAB_TYPE ir_codes_videomate_tv_pvr[IR_KEYTAB_SIZE] = { 1256 .size = ARRAY_SIZE(ir_codes_avermedia),
1174 [ 0x14 ] = KEY_MUTE, 1257};
1175 [ 0x24 ] = KEY_ZOOM, 1258EXPORT_SYMBOL_GPL(ir_codes_avermedia_table);
1176 1259
1177 [ 0x01 ] = KEY_DVD, 1260static struct ir_scancode ir_codes_videomate_tv_pvr[] = {
1178 [ 0x23 ] = KEY_RADIO, 1261 { 0x14, KEY_MUTE },
1179 [ 0x00 ] = KEY_TV, 1262 { 0x24, KEY_ZOOM },
1180 1263
1181 [ 0x0a ] = KEY_REWIND, 1264 { 0x01, KEY_DVD },
1182 [ 0x08 ] = KEY_PLAYPAUSE, 1265 { 0x23, KEY_RADIO },
1183 [ 0x0f ] = KEY_FORWARD, 1266 { 0x00, KEY_TV },
1184 1267
1185 [ 0x02 ] = KEY_PREVIOUS, 1268 { 0x0a, KEY_REWIND },
1186 [ 0x07 ] = KEY_STOP, 1269 { 0x08, KEY_PLAYPAUSE },
1187 [ 0x06 ] = KEY_NEXT, 1270 { 0x0f, KEY_FORWARD },
1188 1271
1189 [ 0x0c ] = KEY_UP, 1272 { 0x02, KEY_PREVIOUS },
1190 [ 0x0e ] = KEY_DOWN, 1273 { 0x07, KEY_STOP },
1191 [ 0x0b ] = KEY_LEFT, 1274 { 0x06, KEY_NEXT },
1192 [ 0x0d ] = KEY_RIGHT, 1275
1193 [ 0x11 ] = KEY_OK, 1276 { 0x0c, KEY_UP },
1194 1277 { 0x0e, KEY_DOWN },
1195 [ 0x03 ] = KEY_MENU, 1278 { 0x0b, KEY_LEFT },
1196 [ 0x09 ] = KEY_SETUP, 1279 { 0x0d, KEY_RIGHT },
1197 [ 0x05 ] = KEY_VIDEO, 1280 { 0x11, KEY_OK },
1198 [ 0x22 ] = KEY_CHANNEL, 1281
1199 1282 { 0x03, KEY_MENU },
1200 [ 0x12 ] = KEY_VOLUMEUP, 1283 { 0x09, KEY_SETUP },
1201 [ 0x15 ] = KEY_VOLUMEDOWN, 1284 { 0x05, KEY_VIDEO },
1202 [ 0x10 ] = KEY_CHANNELUP, 1285 { 0x22, KEY_CHANNEL },
1203 [ 0x13 ] = KEY_CHANNELDOWN, 1286
1204 1287 { 0x12, KEY_VOLUMEUP },
1205 [ 0x04 ] = KEY_RECORD, 1288 { 0x15, KEY_VOLUMEDOWN },
1206 1289 { 0x10, KEY_CHANNELUP },
1207 [ 0x16 ] = KEY_1, 1290 { 0x13, KEY_CHANNELDOWN },
1208 [ 0x17 ] = KEY_2, 1291
1209 [ 0x18 ] = KEY_3, 1292 { 0x04, KEY_RECORD },
1210 [ 0x19 ] = KEY_4, 1293
1211 [ 0x1a ] = KEY_5, 1294 { 0x16, KEY_1 },
1212 [ 0x1b ] = KEY_6, 1295 { 0x17, KEY_2 },
1213 [ 0x1c ] = KEY_7, 1296 { 0x18, KEY_3 },
1214 [ 0x1d ] = KEY_8, 1297 { 0x19, KEY_4 },
1215 [ 0x1e ] = KEY_9, 1298 { 0x1a, KEY_5 },
1216 [ 0x1f ] = KEY_0, 1299 { 0x1b, KEY_6 },
1217 1300 { 0x1c, KEY_7 },
1218 [ 0x20 ] = KEY_LANGUAGE, 1301 { 0x1d, KEY_8 },
1219 [ 0x21 ] = KEY_SLEEP, 1302 { 0x1e, KEY_9 },
1220}; 1303 { 0x1f, KEY_0 },
1221 1304
1222EXPORT_SYMBOL_GPL(ir_codes_videomate_tv_pvr); 1305 { 0x20, KEY_LANGUAGE },
1306 { 0x21, KEY_SLEEP },
1307};
1308
1309struct ir_scancode_table ir_codes_videomate_tv_pvr_table = {
1310 .scan = ir_codes_videomate_tv_pvr,
1311 .size = ARRAY_SIZE(ir_codes_videomate_tv_pvr),
1312};
1313EXPORT_SYMBOL_GPL(ir_codes_videomate_tv_pvr_table);
1223 1314
1224/* Michael Tokarev <mjt@tls.msk.ru> 1315/* Michael Tokarev <mjt@tls.msk.ru>
1225 http://www.corpit.ru/mjt/beholdTV/remote_control.jpg 1316 http://www.corpit.ru/mjt/beholdTV/remote_control.jpg
1226 keytable is used by MANLI MTV00[ 0x0c ] and BeholdTV 40[13] at 1317 keytable is used by MANLI MTV00[0x0c] and BeholdTV 40[13] at
1227 least, and probably other cards too. 1318 least, and probably other cards too.
1228 The "ascii-art picture" below (in comments, first row 1319 The "ascii-art picture" below (in comments, first row
1229 is the keycode in hex, and subsequent row(s) shows 1320 is the keycode in hex, and subsequent row(s) shows
1230 the button labels (several variants when appropriate) 1321 the button labels (several variants when appropriate)
1231 helps to descide which keycodes to assign to the buttons. 1322 helps to descide which keycodes to assign to the buttons.
1232 */ 1323 */
1233IR_KEYTAB_TYPE ir_codes_manli[IR_KEYTAB_SIZE] = { 1324static struct ir_scancode ir_codes_manli[] = {
1234 1325
1235 /* 0x1c 0x12 * 1326 /* 0x1c 0x12 *
1236 * FUNCTION POWER * 1327 * FUNCTION POWER *
1237 * FM (|) * 1328 * FM (|) *
1238 * */ 1329 * */
1239 [ 0x1c ] = KEY_RADIO, /*XXX*/ 1330 { 0x1c, KEY_RADIO }, /*XXX*/
1240 [ 0x12 ] = KEY_POWER, 1331 { 0x12, KEY_POWER },
1241 1332
1242 /* 0x01 0x02 0x03 * 1333 /* 0x01 0x02 0x03 *
1243 * 1 2 3 * 1334 * 1 2 3 *
@@ -1248,29 +1339,29 @@ IR_KEYTAB_TYPE ir_codes_manli[IR_KEYTAB_SIZE] = {
1248 * 0x07 0x08 0x09 * 1339 * 0x07 0x08 0x09 *
1249 * 7 8 9 * 1340 * 7 8 9 *
1250 * */ 1341 * */
1251 [ 0x01 ] = KEY_1, 1342 { 0x01, KEY_1 },
1252 [ 0x02 ] = KEY_2, 1343 { 0x02, KEY_2 },
1253 [ 0x03 ] = KEY_3, 1344 { 0x03, KEY_3 },
1254 [ 0x04 ] = KEY_4, 1345 { 0x04, KEY_4 },
1255 [ 0x05 ] = KEY_5, 1346 { 0x05, KEY_5 },
1256 [ 0x06 ] = KEY_6, 1347 { 0x06, KEY_6 },
1257 [ 0x07 ] = KEY_7, 1348 { 0x07, KEY_7 },
1258 [ 0x08 ] = KEY_8, 1349 { 0x08, KEY_8 },
1259 [ 0x09 ] = KEY_9, 1350 { 0x09, KEY_9 },
1260 1351
1261 /* 0x0a 0x00 0x17 * 1352 /* 0x0a 0x00 0x17 *
1262 * RECALL 0 +100 * 1353 * RECALL 0 +100 *
1263 * PLUS * 1354 * PLUS *
1264 * */ 1355 * */
1265 [ 0x0a ] = KEY_AGAIN, /*XXX KEY_REWIND? */ 1356 { 0x0a, KEY_AGAIN }, /*XXX KEY_REWIND? */
1266 [ 0x00 ] = KEY_0, 1357 { 0x00, KEY_0 },
1267 [ 0x17 ] = KEY_DIGITS, /*XXX*/ 1358 { 0x17, KEY_DIGITS }, /*XXX*/
1268 1359
1269 /* 0x14 0x10 * 1360 /* 0x14 0x10 *
1270 * MENU INFO * 1361 * MENU INFO *
1271 * OSD */ 1362 * OSD */
1272 [ 0x14 ] = KEY_MENU, 1363 { 0x14, KEY_MENU },
1273 [ 0x10 ] = KEY_INFO, 1364 { 0x10, KEY_INFO },
1274 1365
1275 /* 0x0b * 1366 /* 0x0b *
1276 * Up * 1367 * Up *
@@ -1281,18 +1372,18 @@ IR_KEYTAB_TYPE ir_codes_manli[IR_KEYTAB_SIZE] = {
1281 * 0x015 * 1372 * 0x015 *
1282 * Down * 1373 * Down *
1283 * */ 1374 * */
1284 [ 0x0b ] = KEY_UP, /*XXX KEY_SCROLLUP? */ 1375 { 0x0b, KEY_UP },
1285 [ 0x18 ] = KEY_LEFT, /*XXX KEY_BACK? */ 1376 { 0x18, KEY_LEFT },
1286 [ 0x16 ] = KEY_OK, /*XXX KEY_SELECT? KEY_ENTER? */ 1377 { 0x16, KEY_OK }, /*XXX KEY_SELECT? KEY_ENTER? */
1287 [ 0x0c ] = KEY_RIGHT, /*XXX KEY_FORWARD? */ 1378 { 0x0c, KEY_RIGHT },
1288 [ 0x15 ] = KEY_DOWN, /*XXX KEY_SCROLLDOWN? */ 1379 { 0x15, KEY_DOWN },
1289 1380
1290 /* 0x11 0x0d * 1381 /* 0x11 0x0d *
1291 * TV/AV MODE * 1382 * TV/AV MODE *
1292 * SOURCE STEREO * 1383 * SOURCE STEREO *
1293 * */ 1384 * */
1294 [ 0x11 ] = KEY_TV, /*XXX*/ 1385 { 0x11, KEY_TV }, /*XXX*/
1295 [ 0x0d ] = KEY_MODE, /*XXX there's no KEY_STEREO */ 1386 { 0x0d, KEY_MODE }, /*XXX there's no KEY_STEREO */
1296 1387
1297 /* 0x0f 0x1b 0x1a * 1388 /* 0x0f 0x1b 0x1a *
1298 * AUDIO Vol+ Chan+ * 1389 * AUDIO Vol+ Chan+ *
@@ -1301,891 +1392,967 @@ IR_KEYTAB_TYPE ir_codes_manli[IR_KEYTAB_SIZE] = {
1301 * 0x0e 0x1f 0x1e * 1392 * 0x0e 0x1f 0x1e *
1302 * SLEEP Vol- Chan- * 1393 * SLEEP Vol- Chan- *
1303 * */ 1394 * */
1304 [ 0x0f ] = KEY_AUDIO, 1395 { 0x0f, KEY_AUDIO },
1305 [ 0x1b ] = KEY_VOLUMEUP, 1396 { 0x1b, KEY_VOLUMEUP },
1306 [ 0x1a ] = KEY_CHANNELUP, 1397 { 0x1a, KEY_CHANNELUP },
1307 [ 0x0e ] = KEY_SLEEP, /*XXX maybe KEY_PAUSE */ 1398 { 0x0e, KEY_TIME },
1308 [ 0x1f ] = KEY_VOLUMEDOWN, 1399 { 0x1f, KEY_VOLUMEDOWN },
1309 [ 0x1e ] = KEY_CHANNELDOWN, 1400 { 0x1e, KEY_CHANNELDOWN },
1310 1401
1311 /* 0x13 0x19 * 1402 /* 0x13 0x19 *
1312 * MUTE SNAPSHOT* 1403 * MUTE SNAPSHOT*
1313 * */ 1404 * */
1314 [ 0x13 ] = KEY_MUTE, 1405 { 0x13, KEY_MUTE },
1315 [ 0x19 ] = KEY_RECORD, /*XXX*/ 1406 { 0x19, KEY_CAMERA },
1316 1407
1317 // 0x1d unused ? 1408 /* 0x1d unused ? */
1318}; 1409};
1319 1410
1320EXPORT_SYMBOL_GPL(ir_codes_manli); 1411struct ir_scancode_table ir_codes_manli_table = {
1412 .scan = ir_codes_manli,
1413 .size = ARRAY_SIZE(ir_codes_manli),
1414};
1415EXPORT_SYMBOL_GPL(ir_codes_manli_table);
1321 1416
1322/* Mike Baikov <mike@baikov.com> */ 1417/* Mike Baikov <mike@baikov.com> */
1323IR_KEYTAB_TYPE ir_codes_gotview7135[IR_KEYTAB_SIZE] = { 1418static struct ir_scancode ir_codes_gotview7135[] = {
1324 1419
1325 [ 0x11 ] = KEY_POWER, 1420 { 0x11, KEY_POWER },
1326 [ 0x35 ] = KEY_TV, 1421 { 0x35, KEY_TV },
1327 [ 0x1b ] = KEY_0, 1422 { 0x1b, KEY_0 },
1328 [ 0x29 ] = KEY_1, 1423 { 0x29, KEY_1 },
1329 [ 0x19 ] = KEY_2, 1424 { 0x19, KEY_2 },
1330 [ 0x39 ] = KEY_3, 1425 { 0x39, KEY_3 },
1331 [ 0x1f ] = KEY_4, 1426 { 0x1f, KEY_4 },
1332 [ 0x2c ] = KEY_5, 1427 { 0x2c, KEY_5 },
1333 [ 0x21 ] = KEY_6, 1428 { 0x21, KEY_6 },
1334 [ 0x24 ] = KEY_7, 1429 { 0x24, KEY_7 },
1335 [ 0x18 ] = KEY_8, 1430 { 0x18, KEY_8 },
1336 [ 0x2b ] = KEY_9, 1431 { 0x2b, KEY_9 },
1337 [ 0x3b ] = KEY_AGAIN, /* LOOP */ 1432 { 0x3b, KEY_AGAIN }, /* LOOP */
1338 [ 0x06 ] = KEY_AUDIO, 1433 { 0x06, KEY_AUDIO },
1339 [ 0x31 ] = KEY_PRINT, /* PREVIEW */ 1434 { 0x31, KEY_PRINT }, /* PREVIEW */
1340 [ 0x3e ] = KEY_VIDEO, 1435 { 0x3e, KEY_VIDEO },
1341 [ 0x10 ] = KEY_CHANNELUP, 1436 { 0x10, KEY_CHANNELUP },
1342 [ 0x20 ] = KEY_CHANNELDOWN, 1437 { 0x20, KEY_CHANNELDOWN },
1343 [ 0x0c ] = KEY_VOLUMEDOWN, 1438 { 0x0c, KEY_VOLUMEDOWN },
1344 [ 0x28 ] = KEY_VOLUMEUP, 1439 { 0x28, KEY_VOLUMEUP },
1345 [ 0x08 ] = KEY_MUTE, 1440 { 0x08, KEY_MUTE },
1346 [ 0x26 ] = KEY_SEARCH, /*SCAN*/ 1441 { 0x26, KEY_SEARCH }, /* SCAN */
1347 [ 0x3f ] = KEY_SHUFFLE, /* SNAPSHOT */ 1442 { 0x3f, KEY_CAMERA }, /* SNAPSHOT */
1348 [ 0x12 ] = KEY_RECORD, 1443 { 0x12, KEY_RECORD },
1349 [ 0x32 ] = KEY_STOP, 1444 { 0x32, KEY_STOP },
1350 [ 0x3c ] = KEY_PLAY, 1445 { 0x3c, KEY_PLAY },
1351 [ 0x1d ] = KEY_REWIND, 1446 { 0x1d, KEY_REWIND },
1352 [ 0x2d ] = KEY_PAUSE, 1447 { 0x2d, KEY_PAUSE },
1353 [ 0x0d ] = KEY_FORWARD, 1448 { 0x0d, KEY_FORWARD },
1354 [ 0x05 ] = KEY_ZOOM, /*FULL*/ 1449 { 0x05, KEY_ZOOM }, /*FULL*/
1355 1450
1356 [ 0x2a ] = KEY_F21, /* LIVE TIMESHIFT */ 1451 { 0x2a, KEY_F21 }, /* LIVE TIMESHIFT */
1357 [ 0x0e ] = KEY_F22, /* MIN TIMESHIFT */ 1452 { 0x0e, KEY_F22 }, /* MIN TIMESHIFT */
1358 [ 0x1e ] = KEY_F23, /* TIMESHIFT */ 1453 { 0x1e, KEY_TIME }, /* TIMESHIFT */
1359 [ 0x38 ] = KEY_F24, /* NORMAL TIMESHIFT */ 1454 { 0x38, KEY_F24 }, /* NORMAL TIMESHIFT */
1360}; 1455};
1361 1456
1362EXPORT_SYMBOL_GPL(ir_codes_gotview7135); 1457struct ir_scancode_table ir_codes_gotview7135_table = {
1363 1458 .scan = ir_codes_gotview7135,
1364IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = { 1459 .size = ARRAY_SIZE(ir_codes_gotview7135),
1365 [ 0x03 ] = KEY_POWER, 1460};
1366 [ 0x6f ] = KEY_MUTE, 1461EXPORT_SYMBOL_GPL(ir_codes_gotview7135_table);
1367 [ 0x10 ] = KEY_BACKSPACE, /* Recall */ 1462
1368 1463static struct ir_scancode ir_codes_purpletv[] = {
1369 [ 0x11 ] = KEY_0, 1464 { 0x03, KEY_POWER },
1370 [ 0x04 ] = KEY_1, 1465 { 0x6f, KEY_MUTE },
1371 [ 0x05 ] = KEY_2, 1466 { 0x10, KEY_BACKSPACE }, /* Recall */
1372 [ 0x06 ] = KEY_3, 1467
1373 [ 0x08 ] = KEY_4, 1468 { 0x11, KEY_0 },
1374 [ 0x09 ] = KEY_5, 1469 { 0x04, KEY_1 },
1375 [ 0x0a ] = KEY_6, 1470 { 0x05, KEY_2 },
1376 [ 0x0c ] = KEY_7, 1471 { 0x06, KEY_3 },
1377 [ 0x0d ] = KEY_8, 1472 { 0x08, KEY_4 },
1378 [ 0x0e ] = KEY_9, 1473 { 0x09, KEY_5 },
1379 [ 0x12 ] = KEY_DOT, /* 100+ */ 1474 { 0x0a, KEY_6 },
1380 1475 { 0x0c, KEY_7 },
1381 [ 0x07 ] = KEY_VOLUMEUP, 1476 { 0x0d, KEY_8 },
1382 [ 0x0b ] = KEY_VOLUMEDOWN, 1477 { 0x0e, KEY_9 },
1383 [ 0x1a ] = KEY_KPPLUS, 1478 { 0x12, KEY_DOT }, /* 100+ */
1384 [ 0x18 ] = KEY_KPMINUS, 1479
1385 [ 0x15 ] = KEY_UP, 1480 { 0x07, KEY_VOLUMEUP },
1386 [ 0x1d ] = KEY_DOWN, 1481 { 0x0b, KEY_VOLUMEDOWN },
1387 [ 0x0f ] = KEY_CHANNELUP, 1482 { 0x1a, KEY_KPPLUS },
1388 [ 0x13 ] = KEY_CHANNELDOWN, 1483 { 0x18, KEY_KPMINUS },
1389 [ 0x48 ] = KEY_ZOOM, 1484 { 0x15, KEY_UP },
1390 1485 { 0x1d, KEY_DOWN },
1391 [ 0x1b ] = KEY_VIDEO, /* Video source */ 1486 { 0x0f, KEY_CHANNELUP },
1392 [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */ 1487 { 0x13, KEY_CHANNELDOWN },
1393 [ 0x19 ] = KEY_SEARCH, /* Auto Scan */ 1488 { 0x48, KEY_ZOOM },
1394 1489
1395 [ 0x4b ] = KEY_RECORD, 1490 { 0x1b, KEY_VIDEO }, /* Video source */
1396 [ 0x46 ] = KEY_PLAY, 1491 { 0x1f, KEY_CAMERA }, /* Snapshot */
1397 [ 0x45 ] = KEY_PAUSE, /* Pause */ 1492 { 0x49, KEY_LANGUAGE }, /* MTS Select */
1398 [ 0x44 ] = KEY_STOP, 1493 { 0x19, KEY_SEARCH }, /* Auto Scan */
1399 [ 0x40 ] = KEY_FORWARD, /* Forward ? */ 1494
1400 [ 0x42 ] = KEY_REWIND, /* Backward ? */ 1495 { 0x4b, KEY_RECORD },
1401 1496 { 0x46, KEY_PLAY },
1402}; 1497 { 0x45, KEY_PAUSE }, /* Pause */
1403 1498 { 0x44, KEY_STOP },
1404EXPORT_SYMBOL_GPL(ir_codes_purpletv); 1499 { 0x43, KEY_TIME }, /* Time Shift */
1500 { 0x17, KEY_CHANNEL }, /* SURF CH */
1501 { 0x40, KEY_FORWARD }, /* Forward ? */
1502 { 0x42, KEY_REWIND }, /* Backward ? */
1503
1504};
1505
1506struct ir_scancode_table ir_codes_purpletv_table = {
1507 .scan = ir_codes_purpletv,
1508 .size = ARRAY_SIZE(ir_codes_purpletv),
1509};
1510EXPORT_SYMBOL_GPL(ir_codes_purpletv_table);
1405 1511
1406/* Mapping for the 28 key remote control as seen at 1512/* Mapping for the 28 key remote control as seen at
1407 http://www.sednacomputer.com/photo/cardbus-tv.jpg 1513 http://www.sednacomputer.com/photo/cardbus-tv.jpg
1408 Pavel Mihaylov <bin@bash.info> 1514 Pavel Mihaylov <bin@bash.info>
1409 Also for the remote bundled with Kozumi KTV-01C card */ 1515 Also for the remote bundled with Kozumi KTV-01C card */
1410IR_KEYTAB_TYPE ir_codes_pctv_sedna[IR_KEYTAB_SIZE] = { 1516static struct ir_scancode ir_codes_pctv_sedna[] = {
1411 [ 0x00 ] = KEY_0, 1517 { 0x00, KEY_0 },
1412 [ 0x01 ] = KEY_1, 1518 { 0x01, KEY_1 },
1413 [ 0x02 ] = KEY_2, 1519 { 0x02, KEY_2 },
1414 [ 0x03 ] = KEY_3, 1520 { 0x03, KEY_3 },
1415 [ 0x04 ] = KEY_4, 1521 { 0x04, KEY_4 },
1416 [ 0x05 ] = KEY_5, 1522 { 0x05, KEY_5 },
1417 [ 0x06 ] = KEY_6, 1523 { 0x06, KEY_6 },
1418 [ 0x07 ] = KEY_7, 1524 { 0x07, KEY_7 },
1419 [ 0x08 ] = KEY_8, 1525 { 0x08, KEY_8 },
1420 [ 0x09 ] = KEY_9, 1526 { 0x09, KEY_9 },
1421 1527
1422 [ 0x0a ] = KEY_AGAIN, /* Recall */ 1528 { 0x0a, KEY_AGAIN }, /* Recall */
1423 [ 0x0b ] = KEY_CHANNELUP, 1529 { 0x0b, KEY_CHANNELUP },
1424 [ 0x0c ] = KEY_VOLUMEUP, 1530 { 0x0c, KEY_VOLUMEUP },
1425 [ 0x0d ] = KEY_MODE, /* Stereo */ 1531 { 0x0d, KEY_MODE }, /* Stereo */
1426 [ 0x0e ] = KEY_STOP, 1532 { 0x0e, KEY_STOP },
1427 [ 0x0f ] = KEY_PREVIOUSSONG, 1533 { 0x0f, KEY_PREVIOUSSONG },
1428 [ 0x10 ] = KEY_ZOOM, 1534 { 0x10, KEY_ZOOM },
1429 [ 0x11 ] = KEY_TUNER, /* Source */ 1535 { 0x11, KEY_TUNER }, /* Source */
1430 [ 0x12 ] = KEY_POWER, 1536 { 0x12, KEY_POWER },
1431 [ 0x13 ] = KEY_MUTE, 1537 { 0x13, KEY_MUTE },
1432 [ 0x15 ] = KEY_CHANNELDOWN, 1538 { 0x15, KEY_CHANNELDOWN },
1433 [ 0x18 ] = KEY_VOLUMEDOWN, 1539 { 0x18, KEY_VOLUMEDOWN },
1434 [ 0x19 ] = KEY_SHUFFLE, /* Snapshot */ 1540 { 0x19, KEY_CAMERA }, /* Snapshot */
1435 [ 0x1a ] = KEY_NEXTSONG, 1541 { 0x1a, KEY_NEXTSONG },
1436 [ 0x1b ] = KEY_TEXT, /* Time Shift */ 1542 { 0x1b, KEY_TIME }, /* Time Shift */
1437 [ 0x1c ] = KEY_RADIO, /* FM Radio */ 1543 { 0x1c, KEY_RADIO }, /* FM Radio */
1438 [ 0x1d ] = KEY_RECORD, 1544 { 0x1d, KEY_RECORD },
1439 [ 0x1e ] = KEY_PAUSE, 1545 { 0x1e, KEY_PAUSE },
1440 /* additional codes for Kozumi's remote */ 1546 /* additional codes for Kozumi's remote */
1441 [0x14] = KEY_INFO, /* OSD */ 1547 { 0x14, KEY_INFO }, /* OSD */
1442 [0x16] = KEY_OK, /* OK */ 1548 { 0x16, KEY_OK }, /* OK */
1443 [0x17] = KEY_DIGITS, /* Plus */ 1549 { 0x17, KEY_DIGITS }, /* Plus */
1444 [0x1f] = KEY_PLAY, /* Play */ 1550 { 0x1f, KEY_PLAY }, /* Play */
1445}; 1551};
1446 1552
1447EXPORT_SYMBOL_GPL(ir_codes_pctv_sedna); 1553struct ir_scancode_table ir_codes_pctv_sedna_table = {
1554 .scan = ir_codes_pctv_sedna,
1555 .size = ARRAY_SIZE(ir_codes_pctv_sedna),
1556};
1557EXPORT_SYMBOL_GPL(ir_codes_pctv_sedna_table);
1448 1558
1449/* Mark Phalan <phalanm@o2.ie> */ 1559/* Mark Phalan <phalanm@o2.ie> */
1450IR_KEYTAB_TYPE ir_codes_pv951[IR_KEYTAB_SIZE] = { 1560static struct ir_scancode ir_codes_pv951[] = {
1451 [ 0x00 ] = KEY_0, 1561 { 0x00, KEY_0 },
1452 [ 0x01 ] = KEY_1, 1562 { 0x01, KEY_1 },
1453 [ 0x02 ] = KEY_2, 1563 { 0x02, KEY_2 },
1454 [ 0x03 ] = KEY_3, 1564 { 0x03, KEY_3 },
1455 [ 0x04 ] = KEY_4, 1565 { 0x04, KEY_4 },
1456 [ 0x05 ] = KEY_5, 1566 { 0x05, KEY_5 },
1457 [ 0x06 ] = KEY_6, 1567 { 0x06, KEY_6 },
1458 [ 0x07 ] = KEY_7, 1568 { 0x07, KEY_7 },
1459 [ 0x08 ] = KEY_8, 1569 { 0x08, KEY_8 },
1460 [ 0x09 ] = KEY_9, 1570 { 0x09, KEY_9 },
1461 1571
1462 [ 0x12 ] = KEY_POWER, 1572 { 0x12, KEY_POWER },
1463 [ 0x10 ] = KEY_MUTE, 1573 { 0x10, KEY_MUTE },
1464 [ 0x1f ] = KEY_VOLUMEDOWN, 1574 { 0x1f, KEY_VOLUMEDOWN },
1465 [ 0x1b ] = KEY_VOLUMEUP, 1575 { 0x1b, KEY_VOLUMEUP },
1466 [ 0x1a ] = KEY_CHANNELUP, 1576 { 0x1a, KEY_CHANNELUP },
1467 [ 0x1e ] = KEY_CHANNELDOWN, 1577 { 0x1e, KEY_CHANNELDOWN },
1468 [ 0x0e ] = KEY_PAGEUP, 1578 { 0x0e, KEY_PAGEUP },
1469 [ 0x1d ] = KEY_PAGEDOWN, 1579 { 0x1d, KEY_PAGEDOWN },
1470 [ 0x13 ] = KEY_SOUND, 1580 { 0x13, KEY_SOUND },
1471 1581
1472 [ 0x18 ] = KEY_KPPLUSMINUS, /* CH +/- */ 1582 { 0x18, KEY_KPPLUSMINUS }, /* CH +/- */
1473 [ 0x16 ] = KEY_SUBTITLE, /* CC */ 1583 { 0x16, KEY_SUBTITLE }, /* CC */
1474 [ 0x0d ] = KEY_TEXT, /* TTX */ 1584 { 0x0d, KEY_TEXT }, /* TTX */
1475 [ 0x0b ] = KEY_TV, /* AIR/CBL */ 1585 { 0x0b, KEY_TV }, /* AIR/CBL */
1476 [ 0x11 ] = KEY_PC, /* PC/TV */ 1586 { 0x11, KEY_PC }, /* PC/TV */
1477 [ 0x17 ] = KEY_OK, /* CH RTN */ 1587 { 0x17, KEY_OK }, /* CH RTN */
1478 [ 0x19 ] = KEY_MODE, /* FUNC */ 1588 { 0x19, KEY_MODE }, /* FUNC */
1479 [ 0x0c ] = KEY_SEARCH, /* AUTOSCAN */ 1589 { 0x0c, KEY_SEARCH }, /* AUTOSCAN */
1480 1590
1481 /* Not sure what to do with these ones! */ 1591 /* Not sure what to do with these ones! */
1482 [ 0x0f ] = KEY_SELECT, /* SOURCE */ 1592 { 0x0f, KEY_SELECT }, /* SOURCE */
1483 [ 0x0a ] = KEY_KPPLUS, /* +100 */ 1593 { 0x0a, KEY_KPPLUS }, /* +100 */
1484 [ 0x14 ] = KEY_EQUAL, /* SYNC */ 1594 { 0x14, KEY_EQUAL }, /* SYNC */
1485 [ 0x1c ] = KEY_MEDIA, /* PC/TV */ 1595 { 0x1c, KEY_MEDIA }, /* PC/TV */
1486}; 1596};
1487 1597
1488EXPORT_SYMBOL_GPL(ir_codes_pv951); 1598struct ir_scancode_table ir_codes_pv951_table = {
1599 .scan = ir_codes_pv951,
1600 .size = ARRAY_SIZE(ir_codes_pv951),
1601};
1602EXPORT_SYMBOL_GPL(ir_codes_pv951_table);
1489 1603
1490/* generic RC5 keytable */ 1604/* generic RC5 keytable */
1491/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */ 1605/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
1492/* used by old (black) Hauppauge remotes */ 1606/* used by old (black) Hauppauge remotes */
1493IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = { 1607static struct ir_scancode ir_codes_rc5_tv[] = {
1494 /* Keys 0 to 9 */ 1608 /* Keys 0 to 9 */
1495 [ 0x00 ] = KEY_0, 1609 { 0x00, KEY_0 },
1496 [ 0x01 ] = KEY_1, 1610 { 0x01, KEY_1 },
1497 [ 0x02 ] = KEY_2, 1611 { 0x02, KEY_2 },
1498 [ 0x03 ] = KEY_3, 1612 { 0x03, KEY_3 },
1499 [ 0x04 ] = KEY_4, 1613 { 0x04, KEY_4 },
1500 [ 0x05 ] = KEY_5, 1614 { 0x05, KEY_5 },
1501 [ 0x06 ] = KEY_6, 1615 { 0x06, KEY_6 },
1502 [ 0x07 ] = KEY_7, 1616 { 0x07, KEY_7 },
1503 [ 0x08 ] = KEY_8, 1617 { 0x08, KEY_8 },
1504 [ 0x09 ] = KEY_9, 1618 { 0x09, KEY_9 },
1505 1619
1506 [ 0x0b ] = KEY_CHANNEL, /* channel / program (japan: 11) */ 1620 { 0x0b, KEY_CHANNEL }, /* channel / program (japan: 11) */
1507 [ 0x0c ] = KEY_POWER, /* standby */ 1621 { 0x0c, KEY_POWER }, /* standby */
1508 [ 0x0d ] = KEY_MUTE, /* mute / demute */ 1622 { 0x0d, KEY_MUTE }, /* mute / demute */
1509 [ 0x0f ] = KEY_TV, /* display */ 1623 { 0x0f, KEY_TV }, /* display */
1510 [ 0x10 ] = KEY_VOLUMEUP, 1624 { 0x10, KEY_VOLUMEUP },
1511 [ 0x11 ] = KEY_VOLUMEDOWN, 1625 { 0x11, KEY_VOLUMEDOWN },
1512 [ 0x12 ] = KEY_BRIGHTNESSUP, 1626 { 0x12, KEY_BRIGHTNESSUP },
1513 [ 0x13 ] = KEY_BRIGHTNESSDOWN, 1627 { 0x13, KEY_BRIGHTNESSDOWN },
1514 [ 0x1e ] = KEY_SEARCH, /* search + */ 1628 { 0x1e, KEY_SEARCH }, /* search + */
1515 [ 0x20 ] = KEY_CHANNELUP, /* channel / program + */ 1629 { 0x20, KEY_CHANNELUP }, /* channel / program + */
1516 [ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */ 1630 { 0x21, KEY_CHANNELDOWN }, /* channel / program - */
1517 [ 0x22 ] = KEY_CHANNEL, /* alt / channel */ 1631 { 0x22, KEY_CHANNEL }, /* alt / channel */
1518 [ 0x23 ] = KEY_LANGUAGE, /* 1st / 2nd language */ 1632 { 0x23, KEY_LANGUAGE }, /* 1st / 2nd language */
1519 [ 0x26 ] = KEY_SLEEP, /* sleeptimer */ 1633 { 0x26, KEY_SLEEP }, /* sleeptimer */
1520 [ 0x2e ] = KEY_MENU, /* 2nd controls (USA: menu) */ 1634 { 0x2e, KEY_MENU }, /* 2nd controls (USA: menu) */
1521 [ 0x30 ] = KEY_PAUSE, 1635 { 0x30, KEY_PAUSE },
1522 [ 0x32 ] = KEY_REWIND, 1636 { 0x32, KEY_REWIND },
1523 [ 0x33 ] = KEY_GOTO, 1637 { 0x33, KEY_GOTO },
1524 [ 0x35 ] = KEY_PLAY, 1638 { 0x35, KEY_PLAY },
1525 [ 0x36 ] = KEY_STOP, 1639 { 0x36, KEY_STOP },
1526 [ 0x37 ] = KEY_RECORD, /* recording */ 1640 { 0x37, KEY_RECORD }, /* recording */
1527 [ 0x3c ] = KEY_TEXT, /* teletext submode (Japan: 12) */ 1641 { 0x3c, KEY_TEXT }, /* teletext submode (Japan: 12) */
1528 [ 0x3d ] = KEY_SUSPEND, /* system standby */ 1642 { 0x3d, KEY_SUSPEND }, /* system standby */
1529 1643
1530}; 1644};
1531 1645
1532EXPORT_SYMBOL_GPL(ir_codes_rc5_tv); 1646struct ir_scancode_table ir_codes_rc5_tv_table = {
1647 .scan = ir_codes_rc5_tv,
1648 .size = ARRAY_SIZE(ir_codes_rc5_tv),
1649};
1650EXPORT_SYMBOL_GPL(ir_codes_rc5_tv_table);
1533 1651
1534/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */ 1652/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */
1535IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = { 1653static struct ir_scancode ir_codes_winfast[] = {
1536 /* Keys 0 to 9 */ 1654 /* Keys 0 to 9 */
1537 [ 0x12 ] = KEY_0, 1655 { 0x12, KEY_0 },
1538 [ 0x05 ] = KEY_1, 1656 { 0x05, KEY_1 },
1539 [ 0x06 ] = KEY_2, 1657 { 0x06, KEY_2 },
1540 [ 0x07 ] = KEY_3, 1658 { 0x07, KEY_3 },
1541 [ 0x09 ] = KEY_4, 1659 { 0x09, KEY_4 },
1542 [ 0x0a ] = KEY_5, 1660 { 0x0a, KEY_5 },
1543 [ 0x0b ] = KEY_6, 1661 { 0x0b, KEY_6 },
1544 [ 0x0d ] = KEY_7, 1662 { 0x0d, KEY_7 },
1545 [ 0x0e ] = KEY_8, 1663 { 0x0e, KEY_8 },
1546 [ 0x0f ] = KEY_9, 1664 { 0x0f, KEY_9 },
1547 1665
1548 [ 0x00 ] = KEY_POWER, 1666 { 0x00, KEY_POWER },
1549 [ 0x1b ] = KEY_AUDIO, /* Audio Source */ 1667 { 0x1b, KEY_AUDIO }, /* Audio Source */
1550 [ 0x02 ] = KEY_TUNER, /* TV/FM, not on Y0400052 */ 1668 { 0x02, KEY_TUNER }, /* TV/FM, not on Y0400052 */
1551 [ 0x1e ] = KEY_VIDEO, /* Video Source */ 1669 { 0x1e, KEY_VIDEO }, /* Video Source */
1552 [ 0x16 ] = KEY_INFO, /* Display information */ 1670 { 0x16, KEY_INFO }, /* Display information */
1553 [ 0x04 ] = KEY_VOLUMEUP, 1671 { 0x04, KEY_VOLUMEUP },
1554 [ 0x08 ] = KEY_VOLUMEDOWN, 1672 { 0x08, KEY_VOLUMEDOWN },
1555 [ 0x0c ] = KEY_CHANNELUP, 1673 { 0x0c, KEY_CHANNELUP },
1556 [ 0x10 ] = KEY_CHANNELDOWN, 1674 { 0x10, KEY_CHANNELDOWN },
1557 [ 0x03 ] = KEY_ZOOM, /* fullscreen */ 1675 { 0x03, KEY_ZOOM }, /* fullscreen */
1558 [ 0x1f ] = KEY_TEXT, /* closed caption/teletext */ 1676 { 0x1f, KEY_TEXT }, /* closed caption/teletext */
1559 [ 0x20 ] = KEY_SLEEP, 1677 { 0x20, KEY_SLEEP },
1560 [ 0x29 ] = KEY_CLEAR, /* boss key */ 1678 { 0x29, KEY_CLEAR }, /* boss key */
1561 [ 0x14 ] = KEY_MUTE, 1679 { 0x14, KEY_MUTE },
1562 [ 0x2b ] = KEY_RED, 1680 { 0x2b, KEY_RED },
1563 [ 0x2c ] = KEY_GREEN, 1681 { 0x2c, KEY_GREEN },
1564 [ 0x2d ] = KEY_YELLOW, 1682 { 0x2d, KEY_YELLOW },
1565 [ 0x2e ] = KEY_BLUE, 1683 { 0x2e, KEY_BLUE },
1566 [ 0x18 ] = KEY_KPPLUS, /* fine tune + , not on Y040052 */ 1684 { 0x18, KEY_KPPLUS }, /* fine tune + , not on Y040052 */
1567 [ 0x19 ] = KEY_KPMINUS, /* fine tune - , not on Y040052 */ 1685 { 0x19, KEY_KPMINUS }, /* fine tune - , not on Y040052 */
1568 [ 0x2a ] = KEY_MEDIA, /* PIP (Picture in picture */ 1686 { 0x2a, KEY_MEDIA }, /* PIP (Picture in picture */
1569 [ 0x21 ] = KEY_DOT, 1687 { 0x21, KEY_DOT },
1570 [ 0x13 ] = KEY_ENTER, 1688 { 0x13, KEY_ENTER },
1571 [ 0x11 ] = KEY_LAST, /* Recall (last channel */ 1689 { 0x11, KEY_LAST }, /* Recall (last channel */
1572 [ 0x22 ] = KEY_PREVIOUS, 1690 { 0x22, KEY_PREVIOUS },
1573 [ 0x23 ] = KEY_PLAYPAUSE, 1691 { 0x23, KEY_PLAYPAUSE },
1574 [ 0x24 ] = KEY_NEXT, 1692 { 0x24, KEY_NEXT },
1575 [ 0x25 ] = KEY_ARCHIVE, /* Time Shifting */ 1693 { 0x25, KEY_TIME }, /* Time Shifting */
1576 [ 0x26 ] = KEY_STOP, 1694 { 0x26, KEY_STOP },
1577 [ 0x27 ] = KEY_RECORD, 1695 { 0x27, KEY_RECORD },
1578 [ 0x28 ] = KEY_SAVE, /* Screenshot */ 1696 { 0x28, KEY_SAVE }, /* Screenshot */
1579 [ 0x2f ] = KEY_MENU, 1697 { 0x2f, KEY_MENU },
1580 [ 0x30 ] = KEY_CANCEL, 1698 { 0x30, KEY_CANCEL },
1581 [ 0x31 ] = KEY_CHANNEL, /* Channel Surf */ 1699 { 0x31, KEY_CHANNEL }, /* Channel Surf */
1582 [ 0x32 ] = KEY_SUBTITLE, 1700 { 0x32, KEY_SUBTITLE },
1583 [ 0x33 ] = KEY_LANGUAGE, 1701 { 0x33, KEY_LANGUAGE },
1584 [ 0x34 ] = KEY_REWIND, 1702 { 0x34, KEY_REWIND },
1585 [ 0x35 ] = KEY_FASTFORWARD, 1703 { 0x35, KEY_FASTFORWARD },
1586 [ 0x36 ] = KEY_TV, 1704 { 0x36, KEY_TV },
1587 [ 0x37 ] = KEY_RADIO, /* FM */ 1705 { 0x37, KEY_RADIO }, /* FM */
1588 [ 0x38 ] = KEY_DVD, 1706 { 0x38, KEY_DVD },
1589 1707
1590 [ 0x3e ] = KEY_F21, /* MCE +VOL, on Y04G0033 */ 1708 { 0x3e, KEY_F21 }, /* MCE +VOL, on Y04G0033 */
1591 [ 0x3a ] = KEY_F22, /* MCE -VOL, on Y04G0033 */ 1709 { 0x3a, KEY_F22 }, /* MCE -VOL, on Y04G0033 */
1592 [ 0x3b ] = KEY_F23, /* MCE +CH, on Y04G0033 */ 1710 { 0x3b, KEY_F23 }, /* MCE +CH, on Y04G0033 */
1593 [ 0x3f ] = KEY_F24 /* MCE -CH, on Y04G0033 */ 1711 { 0x3f, KEY_F24 } /* MCE -CH, on Y04G0033 */
1594}; 1712};
1595 1713
1596EXPORT_SYMBOL_GPL(ir_codes_winfast); 1714struct ir_scancode_table ir_codes_winfast_table = {
1597 1715 .scan = ir_codes_winfast,
1598IR_KEYTAB_TYPE ir_codes_pinnacle_color[IR_KEYTAB_SIZE] = { 1716 .size = ARRAY_SIZE(ir_codes_winfast),
1599 [ 0x59 ] = KEY_MUTE, 1717};
1600 [ 0x4a ] = KEY_POWER, 1718EXPORT_SYMBOL_GPL(ir_codes_winfast_table);
1601 1719
1602 [ 0x18 ] = KEY_TEXT, 1720static struct ir_scancode ir_codes_pinnacle_color[] = {
1603 [ 0x26 ] = KEY_TV, 1721 { 0x59, KEY_MUTE },
1604 [ 0x3d ] = KEY_PRINT, 1722 { 0x4a, KEY_POWER },
1605 1723
1606 [ 0x48 ] = KEY_RED, 1724 { 0x18, KEY_TEXT },
1607 [ 0x04 ] = KEY_GREEN, 1725 { 0x26, KEY_TV },
1608 [ 0x11 ] = KEY_YELLOW, 1726 { 0x3d, KEY_PRINT },
1609 [ 0x00 ] = KEY_BLUE, 1727
1610 1728 { 0x48, KEY_RED },
1611 [ 0x2d ] = KEY_VOLUMEUP, 1729 { 0x04, KEY_GREEN },
1612 [ 0x1e ] = KEY_VOLUMEDOWN, 1730 { 0x11, KEY_YELLOW },
1613 1731 { 0x00, KEY_BLUE },
1614 [ 0x49 ] = KEY_MENU, 1732
1615 1733 { 0x2d, KEY_VOLUMEUP },
1616 [ 0x16 ] = KEY_CHANNELUP, 1734 { 0x1e, KEY_VOLUMEDOWN },
1617 [ 0x17 ] = KEY_CHANNELDOWN, 1735
1618 1736 { 0x49, KEY_MENU },
1619 [ 0x20 ] = KEY_UP, 1737
1620 [ 0x21 ] = KEY_DOWN, 1738 { 0x16, KEY_CHANNELUP },
1621 [ 0x22 ] = KEY_LEFT, 1739 { 0x17, KEY_CHANNELDOWN },
1622 [ 0x23 ] = KEY_RIGHT, 1740
1623 [ 0x0d ] = KEY_SELECT, 1741 { 0x20, KEY_UP },
1624 1742 { 0x21, KEY_DOWN },
1625 1743 { 0x22, KEY_LEFT },
1626 1744 { 0x23, KEY_RIGHT },
1627 [ 0x08 ] = KEY_BACK, 1745 { 0x0d, KEY_SELECT },
1628 [ 0x07 ] = KEY_REFRESH, 1746
1629 1747 { 0x08, KEY_BACK },
1630 [ 0x2f ] = KEY_ZOOM, 1748 { 0x07, KEY_REFRESH },
1631 [ 0x29 ] = KEY_RECORD, 1749
1632 1750 { 0x2f, KEY_ZOOM },
1633 [ 0x4b ] = KEY_PAUSE, 1751 { 0x29, KEY_RECORD },
1634 [ 0x4d ] = KEY_REWIND, 1752
1635 [ 0x2e ] = KEY_PLAY, 1753 { 0x4b, KEY_PAUSE },
1636 [ 0x4e ] = KEY_FORWARD, 1754 { 0x4d, KEY_REWIND },
1637 [ 0x53 ] = KEY_PREVIOUS, 1755 { 0x2e, KEY_PLAY },
1638 [ 0x4c ] = KEY_STOP, 1756 { 0x4e, KEY_FORWARD },
1639 [ 0x54 ] = KEY_NEXT, 1757 { 0x53, KEY_PREVIOUS },
1640 1758 { 0x4c, KEY_STOP },
1641 [ 0x69 ] = KEY_0, 1759 { 0x54, KEY_NEXT },
1642 [ 0x6a ] = KEY_1, 1760
1643 [ 0x6b ] = KEY_2, 1761 { 0x69, KEY_0 },
1644 [ 0x6c ] = KEY_3, 1762 { 0x6a, KEY_1 },
1645 [ 0x6d ] = KEY_4, 1763 { 0x6b, KEY_2 },
1646 [ 0x6e ] = KEY_5, 1764 { 0x6c, KEY_3 },
1647 [ 0x6f ] = KEY_6, 1765 { 0x6d, KEY_4 },
1648 [ 0x70 ] = KEY_7, 1766 { 0x6e, KEY_5 },
1649 [ 0x71 ] = KEY_8, 1767 { 0x6f, KEY_6 },
1650 [ 0x72 ] = KEY_9, 1768 { 0x70, KEY_7 },
1651 1769 { 0x71, KEY_8 },
1652 [ 0x74 ] = KEY_CHANNEL, 1770 { 0x72, KEY_9 },
1653 [ 0x0a ] = KEY_BACKSPACE, 1771
1654}; 1772 { 0x74, KEY_CHANNEL },
1655 1773 { 0x0a, KEY_BACKSPACE },
1656EXPORT_SYMBOL_GPL(ir_codes_pinnacle_color); 1774};
1775
1776struct ir_scancode_table ir_codes_pinnacle_color_table = {
1777 .scan = ir_codes_pinnacle_color,
1778 .size = ARRAY_SIZE(ir_codes_pinnacle_color),
1779};
1780EXPORT_SYMBOL_GPL(ir_codes_pinnacle_color_table);
1657 1781
1658/* Hauppauge: the newer, gray remotes (seems there are multiple 1782/* Hauppauge: the newer, gray remotes (seems there are multiple
1659 * slightly different versions), shipped with cx88+ivtv cards. 1783 * slightly different versions), shipped with cx88+ivtv cards.
1660 * almost rc5 coding, but some non-standard keys */ 1784 * almost rc5 coding, but some non-standard keys */
1661IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = { 1785static struct ir_scancode ir_codes_hauppauge_new[] = {
1662 /* Keys 0 to 9 */ 1786 /* Keys 0 to 9 */
1663 [ 0x00 ] = KEY_0, 1787 { 0x00, KEY_0 },
1664 [ 0x01 ] = KEY_1, 1788 { 0x01, KEY_1 },
1665 [ 0x02 ] = KEY_2, 1789 { 0x02, KEY_2 },
1666 [ 0x03 ] = KEY_3, 1790 { 0x03, KEY_3 },
1667 [ 0x04 ] = KEY_4, 1791 { 0x04, KEY_4 },
1668 [ 0x05 ] = KEY_5, 1792 { 0x05, KEY_5 },
1669 [ 0x06 ] = KEY_6, 1793 { 0x06, KEY_6 },
1670 [ 0x07 ] = KEY_7, 1794 { 0x07, KEY_7 },
1671 [ 0x08 ] = KEY_8, 1795 { 0x08, KEY_8 },
1672 [ 0x09 ] = KEY_9, 1796 { 0x09, KEY_9 },
1673 1797
1674 [ 0x0a ] = KEY_TEXT, /* keypad asterisk as well */ 1798 { 0x0a, KEY_TEXT }, /* keypad asterisk as well */
1675 [ 0x0b ] = KEY_RED, /* red button */ 1799 { 0x0b, KEY_RED }, /* red button */
1676 [ 0x0c ] = KEY_RADIO, 1800 { 0x0c, KEY_RADIO },
1677 [ 0x0d ] = KEY_MENU, 1801 { 0x0d, KEY_MENU },
1678 [ 0x0e ] = KEY_SUBTITLE, /* also the # key */ 1802 { 0x0e, KEY_SUBTITLE }, /* also the # key */
1679 [ 0x0f ] = KEY_MUTE, 1803 { 0x0f, KEY_MUTE },
1680 [ 0x10 ] = KEY_VOLUMEUP, 1804 { 0x10, KEY_VOLUMEUP },
1681 [ 0x11 ] = KEY_VOLUMEDOWN, 1805 { 0x11, KEY_VOLUMEDOWN },
1682 [ 0x12 ] = KEY_PREVIOUS, /* previous channel */ 1806 { 0x12, KEY_PREVIOUS }, /* previous channel */
1683 [ 0x14 ] = KEY_UP, 1807 { 0x14, KEY_UP },
1684 [ 0x15 ] = KEY_DOWN, 1808 { 0x15, KEY_DOWN },
1685 [ 0x16 ] = KEY_LEFT, 1809 { 0x16, KEY_LEFT },
1686 [ 0x17 ] = KEY_RIGHT, 1810 { 0x17, KEY_RIGHT },
1687 [ 0x18 ] = KEY_VIDEO, /* Videos */ 1811 { 0x18, KEY_VIDEO }, /* Videos */
1688 [ 0x19 ] = KEY_AUDIO, /* Music */ 1812 { 0x19, KEY_AUDIO }, /* Music */
1689 /* 0x1a: Pictures - presume this means 1813 /* 0x1a: Pictures - presume this means
1690 "Multimedia Home Platform" - 1814 "Multimedia Home Platform" -
1691 no "PICTURES" key in input.h 1815 no "PICTURES" key in input.h
1692 */ 1816 */
1693 [ 0x1a ] = KEY_MHP, 1817 { 0x1a, KEY_MHP },
1694 1818
1695 [ 0x1b ] = KEY_EPG, /* Guide */ 1819 { 0x1b, KEY_EPG }, /* Guide */
1696 [ 0x1c ] = KEY_TV, 1820 { 0x1c, KEY_TV },
1697 [ 0x1e ] = KEY_NEXTSONG, /* skip >| */ 1821 { 0x1e, KEY_NEXTSONG }, /* skip >| */
1698 [ 0x1f ] = KEY_EXIT, /* back/exit */ 1822 { 0x1f, KEY_EXIT }, /* back/exit */
1699 [ 0x20 ] = KEY_CHANNELUP, /* channel / program + */ 1823 { 0x20, KEY_CHANNELUP }, /* channel / program + */
1700 [ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */ 1824 { 0x21, KEY_CHANNELDOWN }, /* channel / program - */
1701 [ 0x22 ] = KEY_CHANNEL, /* source (old black remote) */ 1825 { 0x22, KEY_CHANNEL }, /* source (old black remote) */
1702 [ 0x24 ] = KEY_PREVIOUSSONG, /* replay |< */ 1826 { 0x24, KEY_PREVIOUSSONG }, /* replay |< */
1703 [ 0x25 ] = KEY_ENTER, /* OK */ 1827 { 0x25, KEY_ENTER }, /* OK */
1704 [ 0x26 ] = KEY_SLEEP, /* minimize (old black remote) */ 1828 { 0x26, KEY_SLEEP }, /* minimize (old black remote) */
1705 [ 0x29 ] = KEY_BLUE, /* blue key */ 1829 { 0x29, KEY_BLUE }, /* blue key */
1706 [ 0x2e ] = KEY_GREEN, /* green button */ 1830 { 0x2e, KEY_GREEN }, /* green button */
1707 [ 0x30 ] = KEY_PAUSE, /* pause */ 1831 { 0x30, KEY_PAUSE }, /* pause */
1708 [ 0x32 ] = KEY_REWIND, /* backward << */ 1832 { 0x32, KEY_REWIND }, /* backward << */
1709 [ 0x34 ] = KEY_FASTFORWARD, /* forward >> */ 1833 { 0x34, KEY_FASTFORWARD }, /* forward >> */
1710 [ 0x35 ] = KEY_PLAY, 1834 { 0x35, KEY_PLAY },
1711 [ 0x36 ] = KEY_STOP, 1835 { 0x36, KEY_STOP },
1712 [ 0x37 ] = KEY_RECORD, /* recording */ 1836 { 0x37, KEY_RECORD }, /* recording */
1713 [ 0x38 ] = KEY_YELLOW, /* yellow key */ 1837 { 0x38, KEY_YELLOW }, /* yellow key */
1714 [ 0x3b ] = KEY_SELECT, /* top right button */ 1838 { 0x3b, KEY_SELECT }, /* top right button */
1715 [ 0x3c ] = KEY_ZOOM, /* full */ 1839 { 0x3c, KEY_ZOOM }, /* full */
1716 [ 0x3d ] = KEY_POWER, /* system power (green button) */ 1840 { 0x3d, KEY_POWER }, /* system power (green button) */
1717}; 1841};
1718 1842
1719EXPORT_SYMBOL_GPL(ir_codes_hauppauge_new); 1843struct ir_scancode_table ir_codes_hauppauge_new_table = {
1720 1844 .scan = ir_codes_hauppauge_new,
1721IR_KEYTAB_TYPE ir_codes_npgtech[IR_KEYTAB_SIZE] = { 1845 .size = ARRAY_SIZE(ir_codes_hauppauge_new),
1722 [ 0x1d ] = KEY_SWITCHVIDEOMODE, /* switch inputs */ 1846};
1723 [ 0x2a ] = KEY_FRONT, 1847EXPORT_SYMBOL_GPL(ir_codes_hauppauge_new_table);
1724 1848
1725 [ 0x3e ] = KEY_1, 1849static struct ir_scancode ir_codes_npgtech[] = {
1726 [ 0x02 ] = KEY_2, 1850 { 0x1d, KEY_SWITCHVIDEOMODE }, /* switch inputs */
1727 [ 0x06 ] = KEY_3, 1851 { 0x2a, KEY_FRONT },
1728 [ 0x0a ] = KEY_4, 1852
1729 [ 0x0e ] = KEY_5, 1853 { 0x3e, KEY_1 },
1730 [ 0x12 ] = KEY_6, 1854 { 0x02, KEY_2 },
1731 [ 0x16 ] = KEY_7, 1855 { 0x06, KEY_3 },
1732 [ 0x1a ] = KEY_8, 1856 { 0x0a, KEY_4 },
1733 [ 0x1e ] = KEY_9, 1857 { 0x0e, KEY_5 },
1734 [ 0x3a ] = KEY_0, 1858 { 0x12, KEY_6 },
1735 [ 0x22 ] = KEY_NUMLOCK, /* -/-- */ 1859 { 0x16, KEY_7 },
1736 [ 0x20 ] = KEY_REFRESH, 1860 { 0x1a, KEY_8 },
1737 1861 { 0x1e, KEY_9 },
1738 [ 0x03 ] = KEY_BRIGHTNESSDOWN, 1862 { 0x3a, KEY_0 },
1739 [ 0x28 ] = KEY_AUDIO, 1863 { 0x22, KEY_NUMLOCK }, /* -/-- */
1740 [ 0x3c ] = KEY_UP, 1864 { 0x20, KEY_REFRESH },
1741 [ 0x3f ] = KEY_LEFT, 1865
1742 [ 0x2e ] = KEY_MUTE, 1866 { 0x03, KEY_BRIGHTNESSDOWN },
1743 [ 0x3b ] = KEY_RIGHT, 1867 { 0x28, KEY_AUDIO },
1744 [ 0x00 ] = KEY_DOWN, 1868 { 0x3c, KEY_CHANNELUP },
1745 [ 0x07 ] = KEY_BRIGHTNESSUP, 1869 { 0x3f, KEY_VOLUMEDOWN },
1746 [ 0x2c ] = KEY_TEXT, 1870 { 0x2e, KEY_MUTE },
1747 1871 { 0x3b, KEY_VOLUMEUP },
1748 [ 0x37 ] = KEY_RECORD, 1872 { 0x00, KEY_CHANNELDOWN },
1749 [ 0x17 ] = KEY_PLAY, 1873 { 0x07, KEY_BRIGHTNESSUP },
1750 [ 0x13 ] = KEY_PAUSE, 1874 { 0x2c, KEY_TEXT },
1751 [ 0x26 ] = KEY_STOP, 1875
1752 [ 0x18 ] = KEY_FASTFORWARD, 1876 { 0x37, KEY_RECORD },
1753 [ 0x14 ] = KEY_REWIND, 1877 { 0x17, KEY_PLAY },
1754 [ 0x33 ] = KEY_ZOOM, 1878 { 0x13, KEY_PAUSE },
1755 [ 0x32 ] = KEY_KEYBOARD, 1879 { 0x26, KEY_STOP },
1756 [ 0x30 ] = KEY_GOTO, /* Pointing arrow */ 1880 { 0x18, KEY_FASTFORWARD },
1757 [ 0x36 ] = KEY_MACRO, /* Maximize/Minimize (yellow) */ 1881 { 0x14, KEY_REWIND },
1758 [ 0x0b ] = KEY_RADIO, 1882 { 0x33, KEY_ZOOM },
1759 [ 0x10 ] = KEY_POWER, 1883 { 0x32, KEY_KEYBOARD },
1760 1884 { 0x30, KEY_GOTO }, /* Pointing arrow */
1761}; 1885 { 0x36, KEY_MACRO }, /* Maximize/Minimize (yellow) */
1762 1886 { 0x0b, KEY_RADIO },
1763EXPORT_SYMBOL_GPL(ir_codes_npgtech); 1887 { 0x10, KEY_POWER },
1888
1889};
1890
1891struct ir_scancode_table ir_codes_npgtech_table = {
1892 .scan = ir_codes_npgtech,
1893 .size = ARRAY_SIZE(ir_codes_npgtech),
1894};
1895EXPORT_SYMBOL_GPL(ir_codes_npgtech_table);
1764 1896
1765/* Norwood Micro (non-Pro) TV Tuner 1897/* Norwood Micro (non-Pro) TV Tuner
1766 By Peter Naulls <peter@chocky.org> 1898 By Peter Naulls <peter@chocky.org>
1767 Key comments are the functions given in the manual */ 1899 Key comments are the functions given in the manual */
1768IR_KEYTAB_TYPE ir_codes_norwood[IR_KEYTAB_SIZE] = { 1900static struct ir_scancode ir_codes_norwood[] = {
1769 /* Keys 0 to 9 */ 1901 /* Keys 0 to 9 */
1770 [ 0x20 ] = KEY_0, 1902 { 0x20, KEY_0 },
1771 [ 0x21 ] = KEY_1, 1903 { 0x21, KEY_1 },
1772 [ 0x22 ] = KEY_2, 1904 { 0x22, KEY_2 },
1773 [ 0x23 ] = KEY_3, 1905 { 0x23, KEY_3 },
1774 [ 0x24 ] = KEY_4, 1906 { 0x24, KEY_4 },
1775 [ 0x25 ] = KEY_5, 1907 { 0x25, KEY_5 },
1776 [ 0x26 ] = KEY_6, 1908 { 0x26, KEY_6 },
1777 [ 0x27 ] = KEY_7, 1909 { 0x27, KEY_7 },
1778 [ 0x28 ] = KEY_8, 1910 { 0x28, KEY_8 },
1779 [ 0x29 ] = KEY_9, 1911 { 0x29, KEY_9 },
1780 1912
1781 [ 0x78 ] = KEY_TUNER, /* Video Source */ 1913 { 0x78, KEY_TUNER }, /* Video Source */
1782 [ 0x2c ] = KEY_EXIT, /* Open/Close software */ 1914 { 0x2c, KEY_EXIT }, /* Open/Close software */
1783 [ 0x2a ] = KEY_SELECT, /* 2 Digit Select */ 1915 { 0x2a, KEY_SELECT }, /* 2 Digit Select */
1784 [ 0x69 ] = KEY_AGAIN, /* Recall */ 1916 { 0x69, KEY_AGAIN }, /* Recall */
1785 1917
1786 [ 0x32 ] = KEY_BRIGHTNESSUP, /* Brightness increase */ 1918 { 0x32, KEY_BRIGHTNESSUP }, /* Brightness increase */
1787 [ 0x33 ] = KEY_BRIGHTNESSDOWN, /* Brightness decrease */ 1919 { 0x33, KEY_BRIGHTNESSDOWN }, /* Brightness decrease */
1788 [ 0x6b ] = KEY_KPPLUS, /* (not named >>>>>) */ 1920 { 0x6b, KEY_KPPLUS }, /* (not named >>>>>) */
1789 [ 0x6c ] = KEY_KPMINUS, /* (not named <<<<<) */ 1921 { 0x6c, KEY_KPMINUS }, /* (not named <<<<<) */
1790 1922
1791 [ 0x2d ] = KEY_MUTE, /* Mute */ 1923 { 0x2d, KEY_MUTE }, /* Mute */
1792 [ 0x30 ] = KEY_VOLUMEUP, /* Volume up */ 1924 { 0x30, KEY_VOLUMEUP }, /* Volume up */
1793 [ 0x31 ] = KEY_VOLUMEDOWN, /* Volume down */ 1925 { 0x31, KEY_VOLUMEDOWN }, /* Volume down */
1794 [ 0x60 ] = KEY_CHANNELUP, /* Channel up */ 1926 { 0x60, KEY_CHANNELUP }, /* Channel up */
1795 [ 0x61 ] = KEY_CHANNELDOWN, /* Channel down */ 1927 { 0x61, KEY_CHANNELDOWN }, /* Channel down */
1796 1928
1797 [ 0x3f ] = KEY_RECORD, /* Record */ 1929 { 0x3f, KEY_RECORD }, /* Record */
1798 [ 0x37 ] = KEY_PLAY, /* Play */ 1930 { 0x37, KEY_PLAY }, /* Play */
1799 [ 0x36 ] = KEY_PAUSE, /* Pause */ 1931 { 0x36, KEY_PAUSE }, /* Pause */
1800 [ 0x2b ] = KEY_STOP, /* Stop */ 1932 { 0x2b, KEY_STOP }, /* Stop */
1801 [ 0x67 ] = KEY_FASTFORWARD, /* Foward */ 1933 { 0x67, KEY_FASTFORWARD }, /* Foward */
1802 [ 0x66 ] = KEY_REWIND, /* Rewind */ 1934 { 0x66, KEY_REWIND }, /* Rewind */
1803 [ 0x3e ] = KEY_SEARCH, /* Auto Scan */ 1935 { 0x3e, KEY_SEARCH }, /* Auto Scan */
1804 [ 0x2e ] = KEY_CAMERA, /* Capture Video */ 1936 { 0x2e, KEY_CAMERA }, /* Capture Video */
1805 [ 0x6d ] = KEY_MENU, /* Show/Hide Control */ 1937 { 0x6d, KEY_MENU }, /* Show/Hide Control */
1806 [ 0x2f ] = KEY_ZOOM, /* Full Screen */ 1938 { 0x2f, KEY_ZOOM }, /* Full Screen */
1807 [ 0x34 ] = KEY_RADIO, /* FM */ 1939 { 0x34, KEY_RADIO }, /* FM */
1808 [ 0x65 ] = KEY_POWER, /* Computer power */ 1940 { 0x65, KEY_POWER }, /* Computer power */
1809}; 1941};
1810 1942
1811EXPORT_SYMBOL_GPL(ir_codes_norwood); 1943struct ir_scancode_table ir_codes_norwood_table = {
1944 .scan = ir_codes_norwood,
1945 .size = ARRAY_SIZE(ir_codes_norwood),
1946};
1947EXPORT_SYMBOL_GPL(ir_codes_norwood_table);
1812 1948
1813/* From reading the following remotes: 1949/* From reading the following remotes:
1814 * Zenith Universal 7 / TV Mode 807 / VCR Mode 837 1950 * Zenith Universal 7 / TV Mode 807 / VCR Mode 837
1815 * Hauppauge (from NOVA-CI-s box product) 1951 * Hauppauge (from NOVA-CI-s box product)
1816 * This is a "middle of the road" approach, differences are noted 1952 * This is a "middle of the road" approach, differences are noted
1817 */ 1953 */
1818IR_KEYTAB_TYPE ir_codes_budget_ci_old[IR_KEYTAB_SIZE] = { 1954static struct ir_scancode ir_codes_budget_ci_old[] = {
1819 [ 0x00 ] = KEY_0, 1955 { 0x00, KEY_0 },
1820 [ 0x01 ] = KEY_1, 1956 { 0x01, KEY_1 },
1821 [ 0x02 ] = KEY_2, 1957 { 0x02, KEY_2 },
1822 [ 0x03 ] = KEY_3, 1958 { 0x03, KEY_3 },
1823 [ 0x04 ] = KEY_4, 1959 { 0x04, KEY_4 },
1824 [ 0x05 ] = KEY_5, 1960 { 0x05, KEY_5 },
1825 [ 0x06 ] = KEY_6, 1961 { 0x06, KEY_6 },
1826 [ 0x07 ] = KEY_7, 1962 { 0x07, KEY_7 },
1827 [ 0x08 ] = KEY_8, 1963 { 0x08, KEY_8 },
1828 [ 0x09 ] = KEY_9, 1964 { 0x09, KEY_9 },
1829 [ 0x0a ] = KEY_ENTER, 1965 { 0x0a, KEY_ENTER },
1830 [ 0x0b ] = KEY_RED, 1966 { 0x0b, KEY_RED },
1831 [ 0x0c ] = KEY_POWER, /* RADIO on Hauppauge */ 1967 { 0x0c, KEY_POWER }, /* RADIO on Hauppauge */
1832 [ 0x0d ] = KEY_MUTE, 1968 { 0x0d, KEY_MUTE },
1833 [ 0x0f ] = KEY_A, /* TV on Hauppauge */ 1969 { 0x0f, KEY_A }, /* TV on Hauppauge */
1834 [ 0x10 ] = KEY_VOLUMEUP, 1970 { 0x10, KEY_VOLUMEUP },
1835 [ 0x11 ] = KEY_VOLUMEDOWN, 1971 { 0x11, KEY_VOLUMEDOWN },
1836 [ 0x14 ] = KEY_B, 1972 { 0x14, KEY_B },
1837 [ 0x1c ] = KEY_UP, 1973 { 0x1c, KEY_UP },
1838 [ 0x1d ] = KEY_DOWN, 1974 { 0x1d, KEY_DOWN },
1839 [ 0x1e ] = KEY_OPTION, /* RESERVED on Hauppauge */ 1975 { 0x1e, KEY_OPTION }, /* RESERVED on Hauppauge */
1840 [ 0x1f ] = KEY_BREAK, 1976 { 0x1f, KEY_BREAK },
1841 [ 0x20 ] = KEY_CHANNELUP, 1977 { 0x20, KEY_CHANNELUP },
1842 [ 0x21 ] = KEY_CHANNELDOWN, 1978 { 0x21, KEY_CHANNELDOWN },
1843 [ 0x22 ] = KEY_PREVIOUS, /* Prev. Ch on Zenith, SOURCE on Hauppauge */ 1979 { 0x22, KEY_PREVIOUS }, /* Prev Ch on Zenith, SOURCE on Hauppauge */
1844 [ 0x24 ] = KEY_RESTART, 1980 { 0x24, KEY_RESTART },
1845 [ 0x25 ] = KEY_OK, 1981 { 0x25, KEY_OK },
1846 [ 0x26 ] = KEY_CYCLEWINDOWS, /* MINIMIZE on Hauppauge */ 1982 { 0x26, KEY_CYCLEWINDOWS }, /* MINIMIZE on Hauppauge */
1847 [ 0x28 ] = KEY_ENTER, /* VCR mode on Zenith */ 1983 { 0x28, KEY_ENTER }, /* VCR mode on Zenith */
1848 [ 0x29 ] = KEY_PAUSE, 1984 { 0x29, KEY_PAUSE },
1849 [ 0x2b ] = KEY_RIGHT, 1985 { 0x2b, KEY_RIGHT },
1850 [ 0x2c ] = KEY_LEFT, 1986 { 0x2c, KEY_LEFT },
1851 [ 0x2e ] = KEY_MENU, /* FULL SCREEN on Hauppauge */ 1987 { 0x2e, KEY_MENU }, /* FULL SCREEN on Hauppauge */
1852 [ 0x30 ] = KEY_SLOW, 1988 { 0x30, KEY_SLOW },
1853 [ 0x31 ] = KEY_PREVIOUS, /* VCR mode on Zenith */ 1989 { 0x31, KEY_PREVIOUS }, /* VCR mode on Zenith */
1854 [ 0x32 ] = KEY_REWIND, 1990 { 0x32, KEY_REWIND },
1855 [ 0x34 ] = KEY_FASTFORWARD, 1991 { 0x34, KEY_FASTFORWARD },
1856 [ 0x35 ] = KEY_PLAY, 1992 { 0x35, KEY_PLAY },
1857 [ 0x36 ] = KEY_STOP, 1993 { 0x36, KEY_STOP },
1858 [ 0x37 ] = KEY_RECORD, 1994 { 0x37, KEY_RECORD },
1859 [ 0x38 ] = KEY_TUNER, /* TV/VCR on Zenith */ 1995 { 0x38, KEY_TUNER }, /* TV/VCR on Zenith */
1860 [ 0x3a ] = KEY_C, 1996 { 0x3a, KEY_C },
1861 [ 0x3c ] = KEY_EXIT, 1997 { 0x3c, KEY_EXIT },
1862 [ 0x3d ] = KEY_POWER2, 1998 { 0x3d, KEY_POWER2 },
1863 [ 0x3e ] = KEY_TUNER, 1999 { 0x3e, KEY_TUNER },
1864}; 2000};
1865 2001
1866EXPORT_SYMBOL_GPL(ir_codes_budget_ci_old); 2002struct ir_scancode_table ir_codes_budget_ci_old_table = {
2003 .scan = ir_codes_budget_ci_old,
2004 .size = ARRAY_SIZE(ir_codes_budget_ci_old),
2005};
2006EXPORT_SYMBOL_GPL(ir_codes_budget_ci_old_table);
1867 2007
1868/* 2008/*
1869 * Marc Fargas <telenieko@telenieko.com> 2009 * Marc Fargas <telenieko@telenieko.com>
1870 * this is the remote control that comes with the asus p7131 2010 * this is the remote control that comes with the asus p7131
1871 * which has a label saying is "Model PC-39" 2011 * which has a label saying is "Model PC-39"
1872 */ 2012 */
1873IR_KEYTAB_TYPE ir_codes_asus_pc39[IR_KEYTAB_SIZE] = { 2013static struct ir_scancode ir_codes_asus_pc39[] = {
1874 /* Keys 0 to 9 */ 2014 /* Keys 0 to 9 */
1875 [ 0x15 ] = KEY_0, 2015 { 0x15, KEY_0 },
1876 [ 0x29 ] = KEY_1, 2016 { 0x29, KEY_1 },
1877 [ 0x2d ] = KEY_2, 2017 { 0x2d, KEY_2 },
1878 [ 0x2b ] = KEY_3, 2018 { 0x2b, KEY_3 },
1879 [ 0x09 ] = KEY_4, 2019 { 0x09, KEY_4 },
1880 [ 0x0d ] = KEY_5, 2020 { 0x0d, KEY_5 },
1881 [ 0x0b ] = KEY_6, 2021 { 0x0b, KEY_6 },
1882 [ 0x31 ] = KEY_7, 2022 { 0x31, KEY_7 },
1883 [ 0x35 ] = KEY_8, 2023 { 0x35, KEY_8 },
1884 [ 0x33 ] = KEY_9, 2024 { 0x33, KEY_9 },
1885 2025
1886 [ 0x3e ] = KEY_RADIO, /* radio */ 2026 { 0x3e, KEY_RADIO }, /* radio */
1887 [ 0x03 ] = KEY_MENU, /* dvd/menu */ 2027 { 0x03, KEY_MENU }, /* dvd/menu */
1888 [ 0x2a ] = KEY_VOLUMEUP, 2028 { 0x2a, KEY_VOLUMEUP },
1889 [ 0x19 ] = KEY_VOLUMEDOWN, 2029 { 0x19, KEY_VOLUMEDOWN },
1890 [ 0x37 ] = KEY_UP, 2030 { 0x37, KEY_UP },
1891 [ 0x3b ] = KEY_DOWN, 2031 { 0x3b, KEY_DOWN },
1892 [ 0x27 ] = KEY_LEFT, 2032 { 0x27, KEY_LEFT },
1893 [ 0x2f ] = KEY_RIGHT, 2033 { 0x2f, KEY_RIGHT },
1894 [ 0x25 ] = KEY_VIDEO, /* video */ 2034 { 0x25, KEY_VIDEO }, /* video */
1895 [ 0x39 ] = KEY_AUDIO, /* music */ 2035 { 0x39, KEY_AUDIO }, /* music */
1896 2036
1897 [ 0x21 ] = KEY_TV, /* tv */ 2037 { 0x21, KEY_TV }, /* tv */
1898 [ 0x1d ] = KEY_EXIT, /* back */ 2038 { 0x1d, KEY_EXIT }, /* back */
1899 [ 0x0a ] = KEY_CHANNELUP, /* channel / program + */ 2039 { 0x0a, KEY_CHANNELUP }, /* channel / program + */
1900 [ 0x1b ] = KEY_CHANNELDOWN, /* channel / program - */ 2040 { 0x1b, KEY_CHANNELDOWN }, /* channel / program - */
1901 [ 0x1a ] = KEY_ENTER, /* enter */ 2041 { 0x1a, KEY_ENTER }, /* enter */
1902 2042
1903 [ 0x06 ] = KEY_PAUSE, /* play/pause */ 2043 { 0x06, KEY_PAUSE }, /* play/pause */
1904 [ 0x1e ] = KEY_PREVIOUS, /* rew */ 2044 { 0x1e, KEY_PREVIOUS }, /* rew */
1905 [ 0x26 ] = KEY_NEXT, /* forward */ 2045 { 0x26, KEY_NEXT }, /* forward */
1906 [ 0x0e ] = KEY_REWIND, /* backward << */ 2046 { 0x0e, KEY_REWIND }, /* backward << */
1907 [ 0x3a ] = KEY_FASTFORWARD, /* forward >> */ 2047 { 0x3a, KEY_FASTFORWARD }, /* forward >> */
1908 [ 0x36 ] = KEY_STOP, 2048 { 0x36, KEY_STOP },
1909 [ 0x2e ] = KEY_RECORD, /* recording */ 2049 { 0x2e, KEY_RECORD }, /* recording */
1910 [ 0x16 ] = KEY_POWER, /* the button that reads "close" */ 2050 { 0x16, KEY_POWER }, /* the button that reads "close" */
1911 2051
1912 [ 0x11 ] = KEY_ZOOM, /* full screen */ 2052 { 0x11, KEY_ZOOM }, /* full screen */
1913 [ 0x13 ] = KEY_MACRO, /* recall */ 2053 { 0x13, KEY_MACRO }, /* recall */
1914 [ 0x23 ] = KEY_HOME, /* home */ 2054 { 0x23, KEY_HOME }, /* home */
1915 [ 0x05 ] = KEY_PVR, /* picture */ 2055 { 0x05, KEY_PVR }, /* picture */
1916 [ 0x3d ] = KEY_MUTE, /* mute */ 2056 { 0x3d, KEY_MUTE }, /* mute */
1917 [ 0x01 ] = KEY_DVD, /* dvd */ 2057 { 0x01, KEY_DVD }, /* dvd */
1918}; 2058};
1919 2059
1920EXPORT_SYMBOL_GPL(ir_codes_asus_pc39); 2060struct ir_scancode_table ir_codes_asus_pc39_table = {
2061 .scan = ir_codes_asus_pc39,
2062 .size = ARRAY_SIZE(ir_codes_asus_pc39),
2063};
2064EXPORT_SYMBOL_GPL(ir_codes_asus_pc39_table);
1921 2065
1922 2066
1923/* Encore ENLTV-FM - black plastic, white front cover with white glowing buttons 2067/* Encore ENLTV-FM - black plastic, white front cover with white glowing buttons
1924 Juan Pablo Sormani <sorman@gmail.com> */ 2068 Juan Pablo Sormani <sorman@gmail.com> */
1925IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE] = { 2069static struct ir_scancode ir_codes_encore_enltv[] = {
1926 2070
1927 /* Power button does nothing, neither in Windows app, 2071 /* Power button does nothing, neither in Windows app,
1928 although it sends data (used for BIOS wakeup?) */ 2072 although it sends data (used for BIOS wakeup?) */
1929 [ 0x0d ] = KEY_MUTE, 2073 { 0x0d, KEY_MUTE },
1930 2074
1931 [ 0x1e ] = KEY_TV, 2075 { 0x1e, KEY_TV },
1932 [ 0x00 ] = KEY_VIDEO, 2076 { 0x00, KEY_VIDEO },
1933 [ 0x01 ] = KEY_AUDIO, /* music */ 2077 { 0x01, KEY_AUDIO }, /* music */
1934 [ 0x02 ] = KEY_MHP, /* picture */ 2078 { 0x02, KEY_MHP }, /* picture */
1935 2079
1936 [ 0x1f ] = KEY_1, 2080 { 0x1f, KEY_1 },
1937 [ 0x03 ] = KEY_2, 2081 { 0x03, KEY_2 },
1938 [ 0x04 ] = KEY_3, 2082 { 0x04, KEY_3 },
1939 [ 0x05 ] = KEY_4, 2083 { 0x05, KEY_4 },
1940 [ 0x1c ] = KEY_5, 2084 { 0x1c, KEY_5 },
1941 [ 0x06 ] = KEY_6, 2085 { 0x06, KEY_6 },
1942 [ 0x07 ] = KEY_7, 2086 { 0x07, KEY_7 },
1943 [ 0x08 ] = KEY_8, 2087 { 0x08, KEY_8 },
1944 [ 0x1d ] = KEY_9, 2088 { 0x1d, KEY_9 },
1945 [ 0x0a ] = KEY_0, 2089 { 0x0a, KEY_0 },
1946 2090
1947 [ 0x09 ] = KEY_LIST, /* -/-- */ 2091 { 0x09, KEY_LIST }, /* -/-- */
1948 [ 0x0b ] = KEY_LAST, /* recall */ 2092 { 0x0b, KEY_LAST }, /* recall */
1949 2093
1950 [ 0x14 ] = KEY_HOME, /* win start menu */ 2094 { 0x14, KEY_HOME }, /* win start menu */
1951 [ 0x15 ] = KEY_EXIT, /* exit */ 2095 { 0x15, KEY_EXIT }, /* exit */
1952 [ 0x16 ] = KEY_UP, 2096 { 0x16, KEY_CHANNELUP }, /* UP */
1953 [ 0x12 ] = KEY_DOWN, 2097 { 0x12, KEY_CHANNELDOWN }, /* DOWN */
1954 [ 0x0c ] = KEY_RIGHT, 2098 { 0x0c, KEY_VOLUMEUP }, /* RIGHT */
1955 [ 0x17 ] = KEY_LEFT, 2099 { 0x17, KEY_VOLUMEDOWN }, /* LEFT */
1956 2100
1957 [ 0x18 ] = KEY_ENTER, /* OK */ 2101 { 0x18, KEY_ENTER }, /* OK */
1958 2102
1959 [ 0x0e ] = KEY_ESC, 2103 { 0x0e, KEY_ESC },
1960 [ 0x13 ] = KEY_D, /* desktop */ 2104 { 0x13, KEY_CYCLEWINDOWS }, /* desktop */
1961 [ 0x11 ] = KEY_TAB, 2105 { 0x11, KEY_TAB },
1962 [ 0x19 ] = KEY_SWITCHVIDEOMODE, /* switch */ 2106 { 0x19, KEY_SWITCHVIDEOMODE }, /* switch */
1963 2107
1964 [ 0x1a ] = KEY_MENU, 2108 { 0x1a, KEY_MENU },
1965 [ 0x1b ] = KEY_ZOOM, /* fullscreen */ 2109 { 0x1b, KEY_ZOOM }, /* fullscreen */
1966 [ 0x44 ] = KEY_TIME, /* time shift */ 2110 { 0x44, KEY_TIME }, /* time shift */
1967 [ 0x40 ] = KEY_MODE, /* source */ 2111 { 0x40, KEY_MODE }, /* source */
1968 2112
1969 [ 0x5a ] = KEY_RECORD, 2113 { 0x5a, KEY_RECORD },
1970 [ 0x42 ] = KEY_PLAY, /* play/pause */ 2114 { 0x42, KEY_PLAY }, /* play/pause */
1971 [ 0x45 ] = KEY_STOP, 2115 { 0x45, KEY_STOP },
1972 [ 0x43 ] = KEY_CAMERA, /* camera icon */ 2116 { 0x43, KEY_CAMERA }, /* camera icon */
1973 2117
1974 [ 0x48 ] = KEY_REWIND, 2118 { 0x48, KEY_REWIND },
1975 [ 0x4a ] = KEY_FASTFORWARD, 2119 { 0x4a, KEY_FASTFORWARD },
1976 [ 0x49 ] = KEY_PREVIOUS, 2120 { 0x49, KEY_PREVIOUS },
1977 [ 0x4b ] = KEY_NEXT, 2121 { 0x4b, KEY_NEXT },
1978 2122
1979 [ 0x4c ] = KEY_FAVORITES, /* tv wall */ 2123 { 0x4c, KEY_FAVORITES }, /* tv wall */
1980 [ 0x4d ] = KEY_SOUND, /* DVD sound */ 2124 { 0x4d, KEY_SOUND }, /* DVD sound */
1981 [ 0x4e ] = KEY_LANGUAGE, /* DVD lang */ 2125 { 0x4e, KEY_LANGUAGE }, /* DVD lang */
1982 [ 0x4f ] = KEY_TEXT, /* DVD text */ 2126 { 0x4f, KEY_TEXT }, /* DVD text */
1983 2127
1984 [ 0x50 ] = KEY_SLEEP, /* shutdown */ 2128 { 0x50, KEY_SLEEP }, /* shutdown */
1985 [ 0x51 ] = KEY_MODE, /* stereo > main */ 2129 { 0x51, KEY_MODE }, /* stereo > main */
1986 [ 0x52 ] = KEY_SELECT, /* stereo > sap */ 2130 { 0x52, KEY_SELECT }, /* stereo > sap */
1987 [ 0x53 ] = KEY_PROG1, /* teletext */ 2131 { 0x53, KEY_PROG1 }, /* teletext */
1988 2132
1989 2133
1990 [ 0x59 ] = KEY_RED, /* AP1 */ 2134 { 0x59, KEY_RED }, /* AP1 */
1991 [ 0x41 ] = KEY_GREEN, /* AP2 */ 2135 { 0x41, KEY_GREEN }, /* AP2 */
1992 [ 0x47 ] = KEY_YELLOW, /* AP3 */ 2136 { 0x47, KEY_YELLOW }, /* AP3 */
1993 [ 0x57 ] = KEY_BLUE, /* AP4 */ 2137 { 0x57, KEY_BLUE }, /* AP4 */
1994}; 2138};
1995EXPORT_SYMBOL_GPL(ir_codes_encore_enltv); 2139
2140struct ir_scancode_table ir_codes_encore_enltv_table = {
2141 .scan = ir_codes_encore_enltv,
2142 .size = ARRAY_SIZE(ir_codes_encore_enltv),
2143};
2144EXPORT_SYMBOL_GPL(ir_codes_encore_enltv_table);
1996 2145
1997/* Encore ENLTV2-FM - silver plastic - "Wand Media" written at the botton 2146/* Encore ENLTV2-FM - silver plastic - "Wand Media" written at the botton
1998 Mauro Carvalho Chehab <mchehab@infradead.org> */ 2147 Mauro Carvalho Chehab <mchehab@infradead.org> */
1999IR_KEYTAB_TYPE ir_codes_encore_enltv2[IR_KEYTAB_SIZE] = { 2148static struct ir_scancode ir_codes_encore_enltv2[] = {
2000 [0x4c] = KEY_POWER2, 2149 { 0x4c, KEY_POWER2 },
2001 [0x4a] = KEY_TUNER, 2150 { 0x4a, KEY_TUNER },
2002 [0x40] = KEY_1, 2151 { 0x40, KEY_1 },
2003 [0x60] = KEY_2, 2152 { 0x60, KEY_2 },
2004 [0x50] = KEY_3, 2153 { 0x50, KEY_3 },
2005 [0x70] = KEY_4, 2154 { 0x70, KEY_4 },
2006 [0x48] = KEY_5, 2155 { 0x48, KEY_5 },
2007 [0x68] = KEY_6, 2156 { 0x68, KEY_6 },
2008 [0x58] = KEY_7, 2157 { 0x58, KEY_7 },
2009 [0x78] = KEY_8, 2158 { 0x78, KEY_8 },
2010 [0x44] = KEY_9, 2159 { 0x44, KEY_9 },
2011 [0x54] = KEY_0, 2160 { 0x54, KEY_0 },
2012 2161
2013 [0x64] = KEY_LAST, /* +100 */ 2162 { 0x64, KEY_LAST }, /* +100 */
2014 [0x4e] = KEY_AGAIN, /* Recall */ 2163 { 0x4e, KEY_AGAIN }, /* Recall */
2015 2164
2016 [0x6c] = KEY_SWITCHVIDEOMODE, /* Video Source */ 2165 { 0x6c, KEY_SWITCHVIDEOMODE }, /* Video Source */
2017 [0x5e] = KEY_MENU, 2166 { 0x5e, KEY_MENU },
2018 [0x56] = KEY_SCREEN, 2167 { 0x56, KEY_SCREEN },
2019 [0x7a] = KEY_SETUP, 2168 { 0x7a, KEY_SETUP },
2020 2169
2021 [0x46] = KEY_MUTE, 2170 { 0x46, KEY_MUTE },
2022 [0x5c] = KEY_MODE, /* Stereo */ 2171 { 0x5c, KEY_MODE }, /* Stereo */
2023 [0x74] = KEY_INFO, 2172 { 0x74, KEY_INFO },
2024 [0x7c] = KEY_CLEAR, 2173 { 0x7c, KEY_CLEAR },
2025 2174
2026 [0x55] = KEY_UP, 2175 { 0x55, KEY_UP },
2027 [0x49] = KEY_DOWN, 2176 { 0x49, KEY_DOWN },
2028 [0x7e] = KEY_LEFT, 2177 { 0x7e, KEY_LEFT },
2029 [0x59] = KEY_RIGHT, 2178 { 0x59, KEY_RIGHT },
2030 [0x6a] = KEY_ENTER, 2179 { 0x6a, KEY_ENTER },
2031 2180
2032 [0x42] = KEY_VOLUMEUP, 2181 { 0x42, KEY_VOLUMEUP },
2033 [0x62] = KEY_VOLUMEDOWN, 2182 { 0x62, KEY_VOLUMEDOWN },
2034 [0x52] = KEY_CHANNELUP, 2183 { 0x52, KEY_CHANNELUP },
2035 [0x72] = KEY_CHANNELDOWN, 2184 { 0x72, KEY_CHANNELDOWN },
2036 2185
2037 [0x41] = KEY_RECORD, 2186 { 0x41, KEY_RECORD },
2038 [0x51] = KEY_SHUFFLE, /* Snapshot */ 2187 { 0x51, KEY_CAMERA }, /* Snapshot */
2039 [0x75] = KEY_TIME, /* Timeshift */ 2188 { 0x75, KEY_TIME }, /* Timeshift */
2040 [0x71] = KEY_TV2, /* PIP */ 2189 { 0x71, KEY_TV2 }, /* PIP */
2041 2190
2042 [0x45] = KEY_REWIND, 2191 { 0x45, KEY_REWIND },
2043 [0x6f] = KEY_PAUSE, 2192 { 0x6f, KEY_PAUSE },
2044 [0x7d] = KEY_FORWARD, 2193 { 0x7d, KEY_FORWARD },
2045 [0x79] = KEY_STOP, 2194 { 0x79, KEY_STOP },
2046}; 2195};
2047EXPORT_SYMBOL_GPL(ir_codes_encore_enltv2); 2196
2197struct ir_scancode_table ir_codes_encore_enltv2_table = {
2198 .scan = ir_codes_encore_enltv2,
2199 .size = ARRAY_SIZE(ir_codes_encore_enltv2),
2200};
2201EXPORT_SYMBOL_GPL(ir_codes_encore_enltv2_table);
2048 2202
2049/* for the Technotrend 1500 bundled remotes (grey and black): */ 2203/* for the Technotrend 1500 bundled remotes (grey and black): */
2050IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE] = { 2204static struct ir_scancode ir_codes_tt_1500[] = {
2051 [ 0x01 ] = KEY_POWER, 2205 { 0x01, KEY_POWER },
2052 [ 0x02 ] = KEY_SHUFFLE, /* ? double-arrow key */ 2206 { 0x02, KEY_SHUFFLE }, /* ? double-arrow key */
2053 [ 0x03 ] = KEY_1, 2207 { 0x03, KEY_1 },
2054 [ 0x04 ] = KEY_2, 2208 { 0x04, KEY_2 },
2055 [ 0x05 ] = KEY_3, 2209 { 0x05, KEY_3 },
2056 [ 0x06 ] = KEY_4, 2210 { 0x06, KEY_4 },
2057 [ 0x07 ] = KEY_5, 2211 { 0x07, KEY_5 },
2058 [ 0x08 ] = KEY_6, 2212 { 0x08, KEY_6 },
2059 [ 0x09 ] = KEY_7, 2213 { 0x09, KEY_7 },
2060 [ 0x0a ] = KEY_8, 2214 { 0x0a, KEY_8 },
2061 [ 0x0b ] = KEY_9, 2215 { 0x0b, KEY_9 },
2062 [ 0x0c ] = KEY_0, 2216 { 0x0c, KEY_0 },
2063 [ 0x0d ] = KEY_UP, 2217 { 0x0d, KEY_UP },
2064 [ 0x0e ] = KEY_LEFT, 2218 { 0x0e, KEY_LEFT },
2065 [ 0x0f ] = KEY_OK, 2219 { 0x0f, KEY_OK },
2066 [ 0x10 ] = KEY_RIGHT, 2220 { 0x10, KEY_RIGHT },
2067 [ 0x11 ] = KEY_DOWN, 2221 { 0x11, KEY_DOWN },
2068 [ 0x12 ] = KEY_INFO, 2222 { 0x12, KEY_INFO },
2069 [ 0x13 ] = KEY_EXIT, 2223 { 0x13, KEY_EXIT },
2070 [ 0x14 ] = KEY_RED, 2224 { 0x14, KEY_RED },
2071 [ 0x15 ] = KEY_GREEN, 2225 { 0x15, KEY_GREEN },
2072 [ 0x16 ] = KEY_YELLOW, 2226 { 0x16, KEY_YELLOW },
2073 [ 0x17 ] = KEY_BLUE, 2227 { 0x17, KEY_BLUE },
2074 [ 0x18 ] = KEY_MUTE, 2228 { 0x18, KEY_MUTE },
2075 [ 0x19 ] = KEY_TEXT, 2229 { 0x19, KEY_TEXT },
2076 [ 0x1a ] = KEY_MODE, /* ? TV/Radio */ 2230 { 0x1a, KEY_MODE }, /* ? TV/Radio */
2077 [ 0x21 ] = KEY_OPTION, 2231 { 0x21, KEY_OPTION },
2078 [ 0x22 ] = KEY_EPG, 2232 { 0x22, KEY_EPG },
2079 [ 0x23 ] = KEY_CHANNELUP, 2233 { 0x23, KEY_CHANNELUP },
2080 [ 0x24 ] = KEY_CHANNELDOWN, 2234 { 0x24, KEY_CHANNELDOWN },
2081 [ 0x25 ] = KEY_VOLUMEUP, 2235 { 0x25, KEY_VOLUMEUP },
2082 [ 0x26 ] = KEY_VOLUMEDOWN, 2236 { 0x26, KEY_VOLUMEDOWN },
2083 [ 0x27 ] = KEY_SETUP, 2237 { 0x27, KEY_SETUP },
2084 [ 0x3a ] = KEY_RECORD, /* these keys are only in the black remote */ 2238 { 0x3a, KEY_RECORD }, /* these keys are only in the black remote */
2085 [ 0x3b ] = KEY_PLAY, 2239 { 0x3b, KEY_PLAY },
2086 [ 0x3c ] = KEY_STOP, 2240 { 0x3c, KEY_STOP },
2087 [ 0x3d ] = KEY_REWIND, 2241 { 0x3d, KEY_REWIND },
2088 [ 0x3e ] = KEY_PAUSE, 2242 { 0x3e, KEY_PAUSE },
2089 [ 0x3f ] = KEY_FORWARD, 2243 { 0x3f, KEY_FORWARD },
2090}; 2244};
2091 2245
2092EXPORT_SYMBOL_GPL(ir_codes_tt_1500); 2246struct ir_scancode_table ir_codes_tt_1500_table = {
2247 .scan = ir_codes_tt_1500,
2248 .size = ARRAY_SIZE(ir_codes_tt_1500),
2249};
2250EXPORT_SYMBOL_GPL(ir_codes_tt_1500_table);
2093 2251
2094/* DViCO FUSION HDTV MCE remote */ 2252/* DViCO FUSION HDTV MCE remote */
2095IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE] = { 2253static struct ir_scancode ir_codes_fusionhdtv_mce[] = {
2096 2254
2097 [ 0x0b ] = KEY_1, 2255 { 0x0b, KEY_1 },
2098 [ 0x17 ] = KEY_2, 2256 { 0x17, KEY_2 },
2099 [ 0x1b ] = KEY_3, 2257 { 0x1b, KEY_3 },
2100 [ 0x07 ] = KEY_4, 2258 { 0x07, KEY_4 },
2101 [ 0x50 ] = KEY_5, 2259 { 0x50, KEY_5 },
2102 [ 0x54 ] = KEY_6, 2260 { 0x54, KEY_6 },
2103 [ 0x48 ] = KEY_7, 2261 { 0x48, KEY_7 },
2104 [ 0x4c ] = KEY_8, 2262 { 0x4c, KEY_8 },
2105 [ 0x58 ] = KEY_9, 2263 { 0x58, KEY_9 },
2106 [ 0x03 ] = KEY_0, 2264 { 0x03, KEY_0 },
2107 2265
2108 [ 0x5e ] = KEY_OK, 2266 { 0x5e, KEY_OK },
2109 [ 0x51 ] = KEY_UP, 2267 { 0x51, KEY_UP },
2110 [ 0x53 ] = KEY_DOWN, 2268 { 0x53, KEY_DOWN },
2111 [ 0x5b ] = KEY_LEFT, 2269 { 0x5b, KEY_LEFT },
2112 [ 0x5f ] = KEY_RIGHT, 2270 { 0x5f, KEY_RIGHT },
2113 2271
2114 [ 0x02 ] = KEY_TV, /* Labeled DTV on remote */ 2272 { 0x02, KEY_TV }, /* Labeled DTV on remote */
2115 [ 0x0e ] = KEY_MP3, 2273 { 0x0e, KEY_MP3 },
2116 [ 0x1a ] = KEY_DVD, 2274 { 0x1a, KEY_DVD },
2117 [ 0x1e ] = KEY_FAVORITES, /* Labeled CPF on remote */ 2275 { 0x1e, KEY_FAVORITES }, /* Labeled CPF on remote */
2118 [ 0x16 ] = KEY_SETUP, 2276 { 0x16, KEY_SETUP },
2119 [ 0x46 ] = KEY_POWER2, /* TV On/Off button on remote */ 2277 { 0x46, KEY_POWER2 }, /* TV On/Off button on remote */
2120 [ 0x0a ] = KEY_EPG, /* Labeled Guide on remote */ 2278 { 0x0a, KEY_EPG }, /* Labeled Guide on remote */
2121 2279
2122 [ 0x49 ] = KEY_BACK, 2280 { 0x49, KEY_BACK },
2123 [ 0x59 ] = KEY_INFO, /* Labeled MORE on remote */ 2281 { 0x59, KEY_INFO }, /* Labeled MORE on remote */
2124 [ 0x4d ] = KEY_MENU, /* Labeled DVDMENU on remote */ 2282 { 0x4d, KEY_MENU }, /* Labeled DVDMENU on remote */
2125 [ 0x55 ] = KEY_CYCLEWINDOWS, /* Labeled ALT-TAB on remote */ 2283 { 0x55, KEY_CYCLEWINDOWS }, /* Labeled ALT-TAB on remote */
2126 2284
2127 [ 0x0f ] = KEY_PREVIOUSSONG, /* Labeled |<< REPLAY on remote */ 2285 { 0x0f, KEY_PREVIOUSSONG }, /* Labeled |<< REPLAY on remote */
2128 [ 0x12 ] = KEY_NEXTSONG, /* Labeled >>| SKIP on remote */ 2286 { 0x12, KEY_NEXTSONG }, /* Labeled >>| SKIP on remote */
2129 [ 0x42 ] = KEY_ENTER, /* Labeled START with a green 2287 { 0x42, KEY_ENTER }, /* Labeled START with a green
2130 * MS windows logo on remote */ 2288 MS windows logo on remote */
2131 2289
2132 [ 0x15 ] = KEY_VOLUMEUP, 2290 { 0x15, KEY_VOLUMEUP },
2133 [ 0x05 ] = KEY_VOLUMEDOWN, 2291 { 0x05, KEY_VOLUMEDOWN },
2134 [ 0x11 ] = KEY_CHANNELUP, 2292 { 0x11, KEY_CHANNELUP },
2135 [ 0x09 ] = KEY_CHANNELDOWN, 2293 { 0x09, KEY_CHANNELDOWN },
2136 2294
2137 [ 0x52 ] = KEY_CAMERA, 2295 { 0x52, KEY_CAMERA },
2138 [ 0x5a ] = KEY_TUNER, 2296 { 0x5a, KEY_TUNER },
2139 [ 0x19 ] = KEY_OPEN, 2297 { 0x19, KEY_OPEN },
2140 2298
2141 [ 0x13 ] = KEY_MODE, /* 4:3 16:9 select */ 2299 { 0x13, KEY_MODE }, /* 4:3 16:9 select */
2142 [ 0x1f ] = KEY_ZOOM, 2300 { 0x1f, KEY_ZOOM },
2143 2301
2144 [ 0x43 ] = KEY_REWIND, 2302 { 0x43, KEY_REWIND },
2145 [ 0x47 ] = KEY_PLAYPAUSE, 2303 { 0x47, KEY_PLAYPAUSE },
2146 [ 0x4f ] = KEY_FASTFORWARD, 2304 { 0x4f, KEY_FASTFORWARD },
2147 [ 0x57 ] = KEY_MUTE, 2305 { 0x57, KEY_MUTE },
2148 [ 0x0d ] = KEY_STOP, 2306 { 0x0d, KEY_STOP },
2149 [ 0x01 ] = KEY_RECORD, 2307 { 0x01, KEY_RECORD },
2150 [ 0x4e ] = KEY_POWER, 2308 { 0x4e, KEY_POWER },
2151}; 2309};
2152 2310
2153EXPORT_SYMBOL_GPL(ir_codes_fusionhdtv_mce); 2311struct ir_scancode_table ir_codes_fusionhdtv_mce_table = {
2312 .scan = ir_codes_fusionhdtv_mce,
2313 .size = ARRAY_SIZE(ir_codes_fusionhdtv_mce),
2314};
2315EXPORT_SYMBOL_GPL(ir_codes_fusionhdtv_mce_table);
2154 2316
2155/* Pinnacle PCTV HD 800i mini remote */ 2317/* Pinnacle PCTV HD 800i mini remote */
2156IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE] = { 2318static struct ir_scancode ir_codes_pinnacle_pctv_hd[] = {
2157 2319
2158 [0x0f] = KEY_1, 2320 { 0x0f, KEY_1 },
2159 [0x15] = KEY_2, 2321 { 0x15, KEY_2 },
2160 [0x10] = KEY_3, 2322 { 0x10, KEY_3 },
2161 [0x18] = KEY_4, 2323 { 0x18, KEY_4 },
2162 [0x1b] = KEY_5, 2324 { 0x1b, KEY_5 },
2163 [0x1e] = KEY_6, 2325 { 0x1e, KEY_6 },
2164 [0x11] = KEY_7, 2326 { 0x11, KEY_7 },
2165 [0x21] = KEY_8, 2327 { 0x21, KEY_8 },
2166 [0x12] = KEY_9, 2328 { 0x12, KEY_9 },
2167 [0x27] = KEY_0, 2329 { 0x27, KEY_0 },
2168 2330
2169 [0x24] = KEY_ZOOM, 2331 { 0x24, KEY_ZOOM },
2170 [0x2a] = KEY_SUBTITLE, 2332 { 0x2a, KEY_SUBTITLE },
2171 2333
2172 [0x00] = KEY_MUTE, 2334 { 0x00, KEY_MUTE },
2173 [0x01] = KEY_ENTER, /* Pinnacle Logo */ 2335 { 0x01, KEY_ENTER }, /* Pinnacle Logo */
2174 [0x39] = KEY_POWER, 2336 { 0x39, KEY_POWER },
2175 2337
2176 [0x03] = KEY_VOLUMEUP, 2338 { 0x03, KEY_VOLUMEUP },
2177 [0x09] = KEY_VOLUMEDOWN, 2339 { 0x09, KEY_VOLUMEDOWN },
2178 [0x06] = KEY_CHANNELUP, 2340 { 0x06, KEY_CHANNELUP },
2179 [0x0c] = KEY_CHANNELDOWN, 2341 { 0x0c, KEY_CHANNELDOWN },
2180 2342
2181 [0x2d] = KEY_REWIND, 2343 { 0x2d, KEY_REWIND },
2182 [0x30] = KEY_PLAYPAUSE, 2344 { 0x30, KEY_PLAYPAUSE },
2183 [0x33] = KEY_FASTFORWARD, 2345 { 0x33, KEY_FASTFORWARD },
2184 [0x3c] = KEY_STOP, 2346 { 0x3c, KEY_STOP },
2185 [0x36] = KEY_RECORD, 2347 { 0x36, KEY_RECORD },
2186 [0x3f] = KEY_EPG, /* Labeled "?" */ 2348 { 0x3f, KEY_EPG }, /* Labeled "?" */
2187}; 2349};
2188EXPORT_SYMBOL_GPL(ir_codes_pinnacle_pctv_hd); 2350
2351struct ir_scancode_table ir_codes_pinnacle_pctv_hd_table = {
2352 .scan = ir_codes_pinnacle_pctv_hd,
2353 .size = ARRAY_SIZE(ir_codes_pinnacle_pctv_hd),
2354};
2355EXPORT_SYMBOL_GPL(ir_codes_pinnacle_pctv_hd_table);
2189 2356
2190/* 2357/*
2191 * Igor Kuznetsov <igk72@ya.ru> 2358 * Igor Kuznetsov <igk72@ya.ru>
@@ -2198,13 +2365,13 @@ EXPORT_SYMBOL_GPL(ir_codes_pinnacle_pctv_hd);
2198 * the button labels (several variants when appropriate) 2365 * the button labels (several variants when appropriate)
2199 * helps to descide which keycodes to assign to the buttons. 2366 * helps to descide which keycodes to assign to the buttons.
2200 */ 2367 */
2201IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE] = { 2368static struct ir_scancode ir_codes_behold[] = {
2202 2369
2203 /* 0x1c 0x12 * 2370 /* 0x1c 0x12 *
2204 * TV/FM POWER * 2371 * TV/FM POWER *
2205 * */ 2372 * */
2206 [ 0x1c ] = KEY_TUNER, /*XXX KEY_TV KEY_RADIO */ 2373 { 0x1c, KEY_TUNER }, /* XXX KEY_TV / KEY_RADIO */
2207 [ 0x12 ] = KEY_POWER, 2374 { 0x12, KEY_POWER },
2208 2375
2209 /* 0x01 0x02 0x03 * 2376 /* 0x01 0x02 0x03 *
2210 * 1 2 3 * 2377 * 1 2 3 *
@@ -2215,28 +2382,28 @@ IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE] = {
2215 * 0x07 0x08 0x09 * 2382 * 0x07 0x08 0x09 *
2216 * 7 8 9 * 2383 * 7 8 9 *
2217 * */ 2384 * */
2218 [ 0x01 ] = KEY_1, 2385 { 0x01, KEY_1 },
2219 [ 0x02 ] = KEY_2, 2386 { 0x02, KEY_2 },
2220 [ 0x03 ] = KEY_3, 2387 { 0x03, KEY_3 },
2221 [ 0x04 ] = KEY_4, 2388 { 0x04, KEY_4 },
2222 [ 0x05 ] = KEY_5, 2389 { 0x05, KEY_5 },
2223 [ 0x06 ] = KEY_6, 2390 { 0x06, KEY_6 },
2224 [ 0x07 ] = KEY_7, 2391 { 0x07, KEY_7 },
2225 [ 0x08 ] = KEY_8, 2392 { 0x08, KEY_8 },
2226 [ 0x09 ] = KEY_9, 2393 { 0x09, KEY_9 },
2227 2394
2228 /* 0x0a 0x00 0x17 * 2395 /* 0x0a 0x00 0x17 *
2229 * RECALL 0 MODE * 2396 * RECALL 0 MODE *
2230 * */ 2397 * */
2231 [ 0x0a ] = KEY_AGAIN, 2398 { 0x0a, KEY_AGAIN },
2232 [ 0x00 ] = KEY_0, 2399 { 0x00, KEY_0 },
2233 [ 0x17 ] = KEY_MODE, 2400 { 0x17, KEY_MODE },
2234 2401
2235 /* 0x14 0x10 * 2402 /* 0x14 0x10 *
2236 * ASPECT FULLSCREEN * 2403 * ASPECT FULLSCREEN *
2237 * */ 2404 * */
2238 [ 0x14 ] = KEY_SCREEN, 2405 { 0x14, KEY_SCREEN },
2239 [ 0x10 ] = KEY_ZOOM, 2406 { 0x10, KEY_ZOOM },
2240 2407
2241 /* 0x0b * 2408 /* 0x0b *
2242 * Up * 2409 * Up *
@@ -2247,17 +2414,17 @@ IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE] = {
2247 * 0x015 * 2414 * 0x015 *
2248 * Down * 2415 * Down *
2249 * */ 2416 * */
2250 [ 0x0b ] = KEY_CHANNELUP, /*XXX KEY_UP */ 2417 { 0x0b, KEY_CHANNELUP },
2251 [ 0x18 ] = KEY_VOLUMEDOWN, /*XXX KEY_LEFT */ 2418 { 0x18, KEY_VOLUMEDOWN },
2252 [ 0x16 ] = KEY_OK, /*XXX KEY_ENTER */ 2419 { 0x16, KEY_OK }, /* XXX KEY_ENTER */
2253 [ 0x0c ] = KEY_VOLUMEUP, /*XXX KEY_RIGHT */ 2420 { 0x0c, KEY_VOLUMEUP },
2254 [ 0x15 ] = KEY_CHANNELDOWN, /*XXX KEY_DOWN */ 2421 { 0x15, KEY_CHANNELDOWN },
2255 2422
2256 /* 0x11 0x0d * 2423 /* 0x11 0x0d *
2257 * MUTE INFO * 2424 * MUTE INFO *
2258 * */ 2425 * */
2259 [ 0x11 ] = KEY_MUTE, 2426 { 0x11, KEY_MUTE },
2260 [ 0x0d ] = KEY_INFO, 2427 { 0x0d, KEY_INFO },
2261 2428
2262 /* 0x0f 0x1b 0x1a * 2429 /* 0x0f 0x1b 0x1a *
2263 * RECORD PLAY/PAUSE STOP * 2430 * RECORD PLAY/PAUSE STOP *
@@ -2266,30 +2433,34 @@ IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE] = {
2266 *TELETEXT AUDIO SOURCE * 2433 *TELETEXT AUDIO SOURCE *
2267 * RED YELLOW * 2434 * RED YELLOW *
2268 * */ 2435 * */
2269 [ 0x0f ] = KEY_RECORD, 2436 { 0x0f, KEY_RECORD },
2270 [ 0x1b ] = KEY_PLAYPAUSE, 2437 { 0x1b, KEY_PLAYPAUSE },
2271 [ 0x1a ] = KEY_STOP, 2438 { 0x1a, KEY_STOP },
2272 [ 0x0e ] = KEY_TEXT, 2439 { 0x0e, KEY_TEXT },
2273 [ 0x1f ] = KEY_RED, /*XXX KEY_AUDIO */ 2440 { 0x1f, KEY_RED }, /*XXX KEY_AUDIO */
2274 [ 0x1e ] = KEY_YELLOW, /*XXX KEY_SOURCE */ 2441 { 0x1e, KEY_YELLOW }, /*XXX KEY_SOURCE */
2275 2442
2276 /* 0x1d 0x13 0x19 * 2443 /* 0x1d 0x13 0x19 *
2277 * SLEEP PREVIEW DVB * 2444 * SLEEP PREVIEW DVB *
2278 * GREEN BLUE * 2445 * GREEN BLUE *
2279 * */ 2446 * */
2280 [ 0x1d ] = KEY_SLEEP, 2447 { 0x1d, KEY_SLEEP },
2281 [ 0x13 ] = KEY_GREEN, 2448 { 0x13, KEY_GREEN },
2282 [ 0x19 ] = KEY_BLUE, /*XXX KEY_SAT */ 2449 { 0x19, KEY_BLUE }, /* XXX KEY_SAT */
2283 2450
2284 /* 0x58 0x5c * 2451 /* 0x58 0x5c *
2285 * FREEZE SNAPSHOT * 2452 * FREEZE SNAPSHOT *
2286 * */ 2453 * */
2287 [ 0x58 ] = KEY_SLOW, 2454 { 0x58, KEY_SLOW },
2288 [ 0x5c ] = KEY_SAVE, 2455 { 0x5c, KEY_CAMERA },
2289 2456
2290}; 2457};
2291 2458
2292EXPORT_SYMBOL_GPL(ir_codes_behold); 2459struct ir_scancode_table ir_codes_behold_table = {
2460 .scan = ir_codes_behold,
2461 .size = ARRAY_SIZE(ir_codes_behold),
2462};
2463EXPORT_SYMBOL_GPL(ir_codes_behold_table);
2293 2464
2294/* Beholder Intl. Ltd. 2008 2465/* Beholder Intl. Ltd. 2008
2295 * Dmitry Belimov d.belimov@google.com 2466 * Dmitry Belimov d.belimov@google.com
@@ -2299,16 +2470,16 @@ EXPORT_SYMBOL_GPL(ir_codes_behold);
2299 * the button labels (several variants when appropriate) 2470 * the button labels (several variants when appropriate)
2300 * helps to descide which keycodes to assign to the buttons. 2471 * helps to descide which keycodes to assign to the buttons.
2301 */ 2472 */
2302IR_KEYTAB_TYPE ir_codes_behold_columbus[IR_KEYTAB_SIZE] = { 2473static struct ir_scancode ir_codes_behold_columbus[] = {
2303 2474
2304 /* 0x13 0x11 0x1C 0x12 * 2475 /* 0x13 0x11 0x1C 0x12 *
2305 * Mute Source TV/FM Power * 2476 * Mute Source TV/FM Power *
2306 * */ 2477 * */
2307 2478
2308 [0x13] = KEY_MUTE, 2479 { 0x13, KEY_MUTE },
2309 [0x11] = KEY_PROPS, 2480 { 0x11, KEY_PROPS },
2310 [0x1C] = KEY_TUNER, /* KEY_TV/KEY_RADIO */ 2481 { 0x1C, KEY_TUNER }, /* KEY_TV/KEY_RADIO */
2311 [0x12] = KEY_POWER, 2482 { 0x12, KEY_POWER },
2312 2483
2313 /* 0x01 0x02 0x03 0x0D * 2484 /* 0x01 0x02 0x03 0x0D *
2314 * 1 2 3 Stereo * 2485 * 1 2 3 Stereo *
@@ -2319,173 +2490,188 @@ IR_KEYTAB_TYPE ir_codes_behold_columbus[IR_KEYTAB_SIZE] = {
2319 * 0x07 0x08 0x09 0x10 * 2490 * 0x07 0x08 0x09 0x10 *
2320 * 7 8 9 Zoom * 2491 * 7 8 9 Zoom *
2321 * */ 2492 * */
2322 [0x01] = KEY_1, 2493 { 0x01, KEY_1 },
2323 [0x02] = KEY_2, 2494 { 0x02, KEY_2 },
2324 [0x03] = KEY_3, 2495 { 0x03, KEY_3 },
2325 [0x0D] = KEY_SETUP, /* Setup key */ 2496 { 0x0D, KEY_SETUP }, /* Setup key */
2326 [0x04] = KEY_4, 2497 { 0x04, KEY_4 },
2327 [0x05] = KEY_5, 2498 { 0x05, KEY_5 },
2328 [0x06] = KEY_6, 2499 { 0x06, KEY_6 },
2329 [0x19] = KEY_BOOKMARKS, /* Snapshot key */ 2500 { 0x19, KEY_CAMERA }, /* Snapshot key */
2330 [0x07] = KEY_7, 2501 { 0x07, KEY_7 },
2331 [0x08] = KEY_8, 2502 { 0x08, KEY_8 },
2332 [0x09] = KEY_9, 2503 { 0x09, KEY_9 },
2333 [0x10] = KEY_ZOOM, 2504 { 0x10, KEY_ZOOM },
2334 2505
2335 /* 0x0A 0x00 0x0B 0x0C * 2506 /* 0x0A 0x00 0x0B 0x0C *
2336 * RECALL 0 ChannelUp VolumeUp * 2507 * RECALL 0 ChannelUp VolumeUp *
2337 * */ 2508 * */
2338 [0x0A] = KEY_AGAIN, 2509 { 0x0A, KEY_AGAIN },
2339 [0x00] = KEY_0, 2510 { 0x00, KEY_0 },
2340 [0x0B] = KEY_CHANNELUP, 2511 { 0x0B, KEY_CHANNELUP },
2341 [0x0C] = KEY_VOLUMEUP, 2512 { 0x0C, KEY_VOLUMEUP },
2342 2513
2343 /* 0x1B 0x1D 0x15 0x18 * 2514 /* 0x1B 0x1D 0x15 0x18 *
2344 * Timeshift Record ChannelDown VolumeDown * 2515 * Timeshift Record ChannelDown VolumeDown *
2345 * */ 2516 * */
2346 2517
2347 [0x1B] = KEY_REWIND, 2518 { 0x1B, KEY_TIME },
2348 [0x1D] = KEY_RECORD, 2519 { 0x1D, KEY_RECORD },
2349 [0x15] = KEY_CHANNELDOWN, 2520 { 0x15, KEY_CHANNELDOWN },
2350 [0x18] = KEY_VOLUMEDOWN, 2521 { 0x18, KEY_VOLUMEDOWN },
2351 2522
2352 /* 0x0E 0x1E 0x0F 0x1A * 2523 /* 0x0E 0x1E 0x0F 0x1A *
2353 * Stop Pause Previouse Next * 2524 * Stop Pause Previouse Next *
2354 * */ 2525 * */
2355 2526
2356 [0x0E] = KEY_STOP, 2527 { 0x0E, KEY_STOP },
2357 [0x1E] = KEY_PAUSE, 2528 { 0x1E, KEY_PAUSE },
2358 [0x0F] = KEY_PREVIOUS, 2529 { 0x0F, KEY_PREVIOUS },
2359 [0x1A] = KEY_NEXT, 2530 { 0x1A, KEY_NEXT },
2531
2532};
2360 2533
2534struct ir_scancode_table ir_codes_behold_columbus_table = {
2535 .scan = ir_codes_behold_columbus,
2536 .size = ARRAY_SIZE(ir_codes_behold_columbus),
2361}; 2537};
2362EXPORT_SYMBOL_GPL(ir_codes_behold_columbus); 2538EXPORT_SYMBOL_GPL(ir_codes_behold_columbus_table);
2363 2539
2364/* 2540/*
2365 * Remote control for the Genius TVGO A11MCE 2541 * Remote control for the Genius TVGO A11MCE
2366 * Adrian Pardini <pardo.bsso@gmail.com> 2542 * Adrian Pardini <pardo.bsso@gmail.com>
2367 */ 2543 */
2368IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE] = { 2544static struct ir_scancode ir_codes_genius_tvgo_a11mce[] = {
2369 /* Keys 0 to 9 */ 2545 /* Keys 0 to 9 */
2370 [0x48] = KEY_0, 2546 { 0x48, KEY_0 },
2371 [0x09] = KEY_1, 2547 { 0x09, KEY_1 },
2372 [0x1d] = KEY_2, 2548 { 0x1d, KEY_2 },
2373 [0x1f] = KEY_3, 2549 { 0x1f, KEY_3 },
2374 [0x19] = KEY_4, 2550 { 0x19, KEY_4 },
2375 [0x1b] = KEY_5, 2551 { 0x1b, KEY_5 },
2376 [0x11] = KEY_6, 2552 { 0x11, KEY_6 },
2377 [0x17] = KEY_7, 2553 { 0x17, KEY_7 },
2378 [0x12] = KEY_8, 2554 { 0x12, KEY_8 },
2379 [0x16] = KEY_9, 2555 { 0x16, KEY_9 },
2380 2556
2381 [0x54] = KEY_RECORD, /* recording */ 2557 { 0x54, KEY_RECORD }, /* recording */
2382 [0x06] = KEY_MUTE, /* mute */ 2558 { 0x06, KEY_MUTE }, /* mute */
2383 [0x10] = KEY_POWER, 2559 { 0x10, KEY_POWER },
2384 [0x40] = KEY_LAST, /* recall */ 2560 { 0x40, KEY_LAST }, /* recall */
2385 [0x4c] = KEY_CHANNELUP, /* channel / program + */ 2561 { 0x4c, KEY_CHANNELUP }, /* channel / program + */
2386 [0x00] = KEY_CHANNELDOWN, /* channel / program - */ 2562 { 0x00, KEY_CHANNELDOWN }, /* channel / program - */
2387 [0x0d] = KEY_VOLUMEUP, 2563 { 0x0d, KEY_VOLUMEUP },
2388 [0x15] = KEY_VOLUMEDOWN, 2564 { 0x15, KEY_VOLUMEDOWN },
2389 [0x4d] = KEY_OK, /* also labeled as Pause */ 2565 { 0x4d, KEY_OK }, /* also labeled as Pause */
2390 [0x1c] = KEY_ZOOM, /* full screen and Stop*/ 2566 { 0x1c, KEY_ZOOM }, /* full screen and Stop*/
2391 [0x02] = KEY_MODE, /* AV Source or Rewind*/ 2567 { 0x02, KEY_MODE }, /* AV Source or Rewind*/
2392 [0x04] = KEY_LIST, /* -/-- */ 2568 { 0x04, KEY_LIST }, /* -/-- */
2393 /* small arrows above numbers */ 2569 /* small arrows above numbers */
2394 [0x1a] = KEY_NEXT, /* also Fast Forward */ 2570 { 0x1a, KEY_NEXT }, /* also Fast Forward */
2395 [0x0e] = KEY_PREVIOUS, /* also Rewind */ 2571 { 0x0e, KEY_PREVIOUS }, /* also Rewind */
2396 /* these are in a rather non standard layout and have 2572 /* these are in a rather non standard layout and have
2397 an alternate name written */ 2573 an alternate name written */
2398 [0x1e] = KEY_UP, /* Video Setting */ 2574 { 0x1e, KEY_UP }, /* Video Setting */
2399 [0x0a] = KEY_DOWN, /* Video Default */ 2575 { 0x0a, KEY_DOWN }, /* Video Default */
2400 [0x05] = KEY_LEFT, /* Snapshot */ 2576 { 0x05, KEY_CAMERA }, /* Snapshot */
2401 [0x0c] = KEY_RIGHT, /* Hide Panel */ 2577 { 0x0c, KEY_RIGHT }, /* Hide Panel */
2402 /* Four buttons without label */ 2578 /* Four buttons without label */
2403 [0x49] = KEY_RED, 2579 { 0x49, KEY_RED },
2404 [0x0b] = KEY_GREEN, 2580 { 0x0b, KEY_GREEN },
2405 [0x13] = KEY_YELLOW, 2581 { 0x13, KEY_YELLOW },
2406 [0x50] = KEY_BLUE, 2582 { 0x50, KEY_BLUE },
2583};
2584
2585struct ir_scancode_table ir_codes_genius_tvgo_a11mce_table = {
2586 .scan = ir_codes_genius_tvgo_a11mce,
2587 .size = ARRAY_SIZE(ir_codes_genius_tvgo_a11mce),
2407}; 2588};
2408EXPORT_SYMBOL_GPL(ir_codes_genius_tvgo_a11mce); 2589EXPORT_SYMBOL_GPL(ir_codes_genius_tvgo_a11mce_table);
2409 2590
2410/* 2591/*
2411 * Remote control for Powercolor Real Angel 330 2592 * Remote control for Powercolor Real Angel 330
2412 * Daniel Fraga <fragabr@gmail.com> 2593 * Daniel Fraga <fragabr@gmail.com>
2413 */ 2594 */
2414IR_KEYTAB_TYPE ir_codes_powercolor_real_angel[IR_KEYTAB_SIZE] = { 2595static struct ir_scancode ir_codes_powercolor_real_angel[] = {
2415 [0x38] = KEY_SWITCHVIDEOMODE, /* switch inputs */ 2596 { 0x38, KEY_SWITCHVIDEOMODE }, /* switch inputs */
2416 [0x0c] = KEY_MEDIA, /* Turn ON/OFF App */ 2597 { 0x0c, KEY_MEDIA }, /* Turn ON/OFF App */
2417 [0x00] = KEY_0, 2598 { 0x00, KEY_0 },
2418 [0x01] = KEY_1, 2599 { 0x01, KEY_1 },
2419 [0x02] = KEY_2, 2600 { 0x02, KEY_2 },
2420 [0x03] = KEY_3, 2601 { 0x03, KEY_3 },
2421 [0x04] = KEY_4, 2602 { 0x04, KEY_4 },
2422 [0x05] = KEY_5, 2603 { 0x05, KEY_5 },
2423 [0x06] = KEY_6, 2604 { 0x06, KEY_6 },
2424 [0x07] = KEY_7, 2605 { 0x07, KEY_7 },
2425 [0x08] = KEY_8, 2606 { 0x08, KEY_8 },
2426 [0x09] = KEY_9, 2607 { 0x09, KEY_9 },
2427 [0x0a] = KEY_DIGITS, /* single, double, tripple digit */ 2608 { 0x0a, KEY_DIGITS }, /* single, double, tripple digit */
2428 [0x29] = KEY_PREVIOUS, /* previous channel */ 2609 { 0x29, KEY_PREVIOUS }, /* previous channel */
2429 [0x12] = KEY_BRIGHTNESSUP, 2610 { 0x12, KEY_BRIGHTNESSUP },
2430 [0x13] = KEY_BRIGHTNESSDOWN, 2611 { 0x13, KEY_BRIGHTNESSDOWN },
2431 [0x2b] = KEY_MODE, /* stereo/mono */ 2612 { 0x2b, KEY_MODE }, /* stereo/mono */
2432 [0x2c] = KEY_TEXT, /* teletext */ 2613 { 0x2c, KEY_TEXT }, /* teletext */
2433 [0x20] = KEY_UP, /* channel up */ 2614 { 0x20, KEY_CHANNELUP }, /* channel up */
2434 [0x21] = KEY_DOWN, /* channel down */ 2615 { 0x21, KEY_CHANNELDOWN }, /* channel down */
2435 [0x10] = KEY_RIGHT, /* volume up */ 2616 { 0x10, KEY_VOLUMEUP }, /* volume up */
2436 [0x11] = KEY_LEFT, /* volume down */ 2617 { 0x11, KEY_VOLUMEDOWN }, /* volume down */
2437 [0x0d] = KEY_MUTE, 2618 { 0x0d, KEY_MUTE },
2438 [0x1f] = KEY_RECORD, 2619 { 0x1f, KEY_RECORD },
2439 [0x17] = KEY_PLAY, 2620 { 0x17, KEY_PLAY },
2440 [0x16] = KEY_PAUSE, 2621 { 0x16, KEY_PAUSE },
2441 [0x0b] = KEY_STOP, 2622 { 0x0b, KEY_STOP },
2442 [0x27] = KEY_FASTFORWARD, 2623 { 0x27, KEY_FASTFORWARD },
2443 [0x26] = KEY_REWIND, 2624 { 0x26, KEY_REWIND },
2444 [0x1e] = KEY_SEARCH, /* autoscan */ 2625 { 0x1e, KEY_SEARCH }, /* autoscan */
2445 [0x0e] = KEY_SHUFFLE, /* snapshot */ 2626 { 0x0e, KEY_CAMERA }, /* snapshot */
2446 [0x2d] = KEY_SETUP, 2627 { 0x2d, KEY_SETUP },
2447 [0x0f] = KEY_SCREEN, /* full screen */ 2628 { 0x0f, KEY_SCREEN }, /* full screen */
2448 [0x14] = KEY_RADIO, /* FM radio */ 2629 { 0x14, KEY_RADIO }, /* FM radio */
2449 [0x25] = KEY_POWER, /* power */ 2630 { 0x25, KEY_POWER }, /* power */
2450}; 2631};
2451EXPORT_SYMBOL_GPL(ir_codes_powercolor_real_angel); 2632
2633struct ir_scancode_table ir_codes_powercolor_real_angel_table = {
2634 .scan = ir_codes_powercolor_real_angel,
2635 .size = ARRAY_SIZE(ir_codes_powercolor_real_angel),
2636};
2637EXPORT_SYMBOL_GPL(ir_codes_powercolor_real_angel_table);
2452 2638
2453/* Kworld Plus TV Analog Lite PCI IR 2639/* Kworld Plus TV Analog Lite PCI IR
2454 Mauro Carvalho Chehab <mchehab@infradead.org> 2640 Mauro Carvalho Chehab <mchehab@infradead.org>
2455 */ 2641 */
2456IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE] = { 2642static struct ir_scancode ir_codes_kworld_plus_tv_analog[] = {
2457 [0x0c] = KEY_PROG1, /* Kworld key */ 2643 { 0x0c, KEY_PROG1 }, /* Kworld key */
2458 [0x16] = KEY_CLOSECD, /* -> ) */ 2644 { 0x16, KEY_CLOSECD }, /* -> ) */
2459 [0x1d] = KEY_POWER2, 2645 { 0x1d, KEY_POWER2 },
2460 2646
2461 [0x00] = KEY_1, 2647 { 0x00, KEY_1 },
2462 [0x01] = KEY_2, 2648 { 0x01, KEY_2 },
2463 [0x02] = KEY_3, /* Two keys have the same code: 3 and left */ 2649 { 0x02, KEY_3 }, /* Two keys have the same code: 3 and left */
2464 [0x03] = KEY_4, /* Two keys have the same code: 3 and right */ 2650 { 0x03, KEY_4 }, /* Two keys have the same code: 3 and right */
2465 [0x04] = KEY_5, 2651 { 0x04, KEY_5 },
2466 [0x05] = KEY_6, 2652 { 0x05, KEY_6 },
2467 [0x06] = KEY_7, 2653 { 0x06, KEY_7 },
2468 [0x07] = KEY_8, 2654 { 0x07, KEY_8 },
2469 [0x08] = KEY_9, 2655 { 0x08, KEY_9 },
2470 [0x0a] = KEY_0, 2656 { 0x0a, KEY_0 },
2471 2657
2472 [0x09] = KEY_AGAIN, 2658 { 0x09, KEY_AGAIN },
2473 [0x14] = KEY_MUTE, 2659 { 0x14, KEY_MUTE },
2474 2660
2475 [0x20] = KEY_UP, 2661 { 0x20, KEY_UP },
2476 [0x21] = KEY_DOWN, 2662 { 0x21, KEY_DOWN },
2477 [0x0b] = KEY_ENTER, 2663 { 0x0b, KEY_ENTER },
2478 2664
2479 [0x10] = KEY_CHANNELUP, 2665 { 0x10, KEY_CHANNELUP },
2480 [0x11] = KEY_CHANNELDOWN, 2666 { 0x11, KEY_CHANNELDOWN },
2481 2667
2482 /* Couldn't map key left/key right since those 2668 /* Couldn't map key left/key right since those
2483 conflict with '3' and '4' scancodes 2669 conflict with '3' and '4' scancodes
2484 I dunno what the original driver does 2670 I dunno what the original driver does
2485 */ 2671 */
2486 2672
2487 [0x13] = KEY_VOLUMEUP, 2673 { 0x13, KEY_VOLUMEUP },
2488 [0x12] = KEY_VOLUMEDOWN, 2674 { 0x12, KEY_VOLUMEDOWN },
2489 2675
2490 /* The lower part of the IR 2676 /* The lower part of the IR
2491 There are several duplicated keycodes there. 2677 There are several duplicated keycodes there.
@@ -2496,280 +2682,468 @@ IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE] = {
2496 Also, it is not related to the time between keyup 2682 Also, it is not related to the time between keyup
2497 and keydown. 2683 and keydown.
2498 */ 2684 */
2499 [0x19] = KEY_PAUSE, /* Timeshift */ 2685 { 0x19, KEY_TIME}, /* Timeshift */
2500 [0x1a] = KEY_STOP, 2686 { 0x1a, KEY_STOP},
2501 [0x1b] = KEY_RECORD, 2687 { 0x1b, KEY_RECORD},
2502 2688
2503 [0x22] = KEY_TEXT, 2689 { 0x22, KEY_TEXT},
2504 2690
2505 [0x15] = KEY_AUDIO, /* ((*)) */ 2691 { 0x15, KEY_AUDIO}, /* ((*)) */
2506 [0x0f] = KEY_ZOOM, 2692 { 0x0f, KEY_ZOOM},
2507 [0x1c] = KEY_SHUFFLE, /* snapshot */ 2693 { 0x1c, KEY_CAMERA}, /* snapshot */
2508 2694
2509 [0x18] = KEY_RED, /* B */ 2695 { 0x18, KEY_RED}, /* B */
2510 [0x23] = KEY_GREEN, /* C */ 2696 { 0x23, KEY_GREEN}, /* C */
2511}; 2697};
2512EXPORT_SYMBOL_GPL(ir_codes_kworld_plus_tv_analog); 2698struct ir_scancode_table ir_codes_kworld_plus_tv_analog_table = {
2699 .scan = ir_codes_kworld_plus_tv_analog,
2700 .size = ARRAY_SIZE(ir_codes_kworld_plus_tv_analog),
2701};
2702EXPORT_SYMBOL_GPL(ir_codes_kworld_plus_tv_analog_table);
2513 2703
2514/* Kaiomy TVnPC U2 2704/* Kaiomy TVnPC U2
2515 Mauro Carvalho Chehab <mchehab@infradead.org> 2705 Mauro Carvalho Chehab <mchehab@infradead.org>
2516 */ 2706 */
2517IR_KEYTAB_TYPE ir_codes_kaiomy[IR_KEYTAB_SIZE] = { 2707static struct ir_scancode ir_codes_kaiomy[] = {
2518 [0x43] = KEY_POWER2, 2708 { 0x43, KEY_POWER2},
2519 [0x01] = KEY_LIST, 2709 { 0x01, KEY_LIST},
2520 [0x0b] = KEY_ZOOM, 2710 { 0x0b, KEY_ZOOM},
2521 [0x03] = KEY_POWER, 2711 { 0x03, KEY_POWER},
2522
2523 [0x04] = KEY_1,
2524 [0x08] = KEY_2,
2525 [0x02] = KEY_3,
2526
2527 [0x0f] = KEY_4,
2528 [0x05] = KEY_5,
2529 [0x06] = KEY_6,
2530
2531 [0x0c] = KEY_7,
2532 [0x0d] = KEY_8,
2533 [0x0a] = KEY_9,
2534
2535 [0x11] = KEY_0,
2536
2537 [0x09] = KEY_CHANNELUP,
2538 [0x07] = KEY_CHANNELDOWN,
2539
2540 [0x0e] = KEY_VOLUMEUP,
2541 [0x13] = KEY_VOLUMEDOWN,
2542
2543 [0x10] = KEY_HOME,
2544 [0x12] = KEY_ENTER,
2545
2546 [0x14] = KEY_RECORD,
2547 [0x15] = KEY_STOP,
2548 [0x16] = KEY_PLAY,
2549 [0x17] = KEY_MUTE,
2550
2551 [0x18] = KEY_UP,
2552 [0x19] = KEY_DOWN,
2553 [0x1a] = KEY_LEFT,
2554 [0x1b] = KEY_RIGHT,
2555
2556 [0x1c] = KEY_RED,
2557 [0x1d] = KEY_GREEN,
2558 [0x1e] = KEY_YELLOW,
2559 [0x1f] = KEY_BLUE,
2560};
2561EXPORT_SYMBOL_GPL(ir_codes_kaiomy);
2562
2563IR_KEYTAB_TYPE ir_codes_avermedia_a16d[IR_KEYTAB_SIZE] = {
2564 [0x20] = KEY_LIST,
2565 [0x00] = KEY_POWER,
2566 [0x28] = KEY_1,
2567 [0x18] = KEY_2,
2568 [0x38] = KEY_3,
2569 [0x24] = KEY_4,
2570 [0x14] = KEY_5,
2571 [0x34] = KEY_6,
2572 [0x2c] = KEY_7,
2573 [0x1c] = KEY_8,
2574 [0x3c] = KEY_9,
2575 [0x12] = KEY_SUBTITLE,
2576 [0x22] = KEY_0,
2577 [0x32] = KEY_REWIND,
2578 [0x3a] = KEY_SHUFFLE,
2579 [0x02] = KEY_PRINT,
2580 [0x11] = KEY_CHANNELDOWN,
2581 [0x31] = KEY_CHANNELUP,
2582 [0x0c] = KEY_ZOOM,
2583 [0x1e] = KEY_VOLUMEDOWN,
2584 [0x3e] = KEY_VOLUMEUP,
2585 [0x0a] = KEY_MUTE,
2586 [0x04] = KEY_AUDIO,
2587 [0x26] = KEY_RECORD,
2588 [0x06] = KEY_PLAY,
2589 [0x36] = KEY_STOP,
2590 [0x16] = KEY_PAUSE,
2591 [0x2e] = KEY_REWIND,
2592 [0x0e] = KEY_FASTFORWARD,
2593 [0x30] = KEY_TEXT,
2594 [0x21] = KEY_GREEN,
2595 [0x01] = KEY_BLUE,
2596 [0x08] = KEY_EPG,
2597 [0x2a] = KEY_MENU,
2598};
2599EXPORT_SYMBOL_GPL(ir_codes_avermedia_a16d);
2600 2712
2601/* Encore ENLTV-FM v5.3 2713 { 0x04, KEY_1},
2602 Mauro Carvalho Chehab <mchehab@infradead.org> 2714 { 0x08, KEY_2},
2603 */ 2715 { 0x02, KEY_3},
2604IR_KEYTAB_TYPE ir_codes_encore_enltv_fm53[IR_KEYTAB_SIZE] = {
2605 [0x10] = KEY_POWER2,
2606 [0x06] = KEY_MUTE,
2607
2608 [0x09] = KEY_1,
2609 [0x1d] = KEY_2,
2610 [0x1f] = KEY_3,
2611 [0x19] = KEY_4,
2612 [0x1b] = KEY_5,
2613 [0x11] = KEY_6,
2614 [0x17] = KEY_7,
2615 [0x12] = KEY_8,
2616 [0x16] = KEY_9,
2617 [0x48] = KEY_0,
2618
2619 [0x04] = KEY_LIST, /* -/-- */
2620 [0x40] = KEY_LAST, /* recall */
2621
2622 [0x02] = KEY_MODE, /* TV/AV */
2623 [0x05] = KEY_SHUFFLE, /* SNAPSHOT */
2624
2625 [0x4c] = KEY_CHANNELUP, /* UP */
2626 [0x00] = KEY_CHANNELDOWN, /* DOWN */
2627 [0x0d] = KEY_VOLUMEUP, /* RIGHT */
2628 [0x15] = KEY_VOLUMEDOWN, /* LEFT */
2629 [0x49] = KEY_ENTER, /* OK */
2630
2631 [0x54] = KEY_RECORD,
2632 [0x4d] = KEY_PLAY, /* pause */
2633
2634 [0x1e] = KEY_UP, /* video setting */
2635 [0x0e] = KEY_RIGHT, /* <- */
2636 [0x1a] = KEY_LEFT, /* -> */
2637
2638 [0x0a] = KEY_DOWN, /* video default */
2639 [0x0c] = KEY_ZOOM, /* hide pannel */
2640 [0x47] = KEY_SLEEP, /* shutdown */
2641};
2642EXPORT_SYMBOL_GPL(ir_codes_encore_enltv_fm53);
2643 2716
2644/* Zogis Real Audio 220 - 32 keys IR */ 2717 { 0x0f, KEY_4},
2645IR_KEYTAB_TYPE ir_codes_real_audio_220_32_keys[IR_KEYTAB_SIZE] = { 2718 { 0x05, KEY_5},
2646 [0x1c] = KEY_RADIO, 2719 { 0x06, KEY_6},
2647 [0x12] = KEY_POWER2, 2720
2721 { 0x0c, KEY_7},
2722 { 0x0d, KEY_8},
2723 { 0x0a, KEY_9},
2648 2724
2649 [0x01] = KEY_1, 2725 { 0x11, KEY_0},
2650 [0x02] = KEY_2,
2651 [0x03] = KEY_3,
2652 [0x04] = KEY_4,
2653 [0x05] = KEY_5,
2654 [0x06] = KEY_6,
2655 [0x07] = KEY_7,
2656 [0x08] = KEY_8,
2657 [0x09] = KEY_9,
2658 [0x00] = KEY_0,
2659 2726
2660 [0x0c] = KEY_VOLUMEUP, 2727 { 0x09, KEY_CHANNELUP},
2661 [0x18] = KEY_VOLUMEDOWN, 2728 { 0x07, KEY_CHANNELDOWN},
2662 [0x0b] = KEY_CHANNELUP,
2663 [0x15] = KEY_CHANNELDOWN,
2664 [0x16] = KEY_ENTER,
2665 2729
2666 [0x11] = KEY_LIST, /* Source */ 2730 { 0x0e, KEY_VOLUMEUP},
2667 [0x0d] = KEY_AUDIO, /* stereo */ 2731 { 0x13, KEY_VOLUMEDOWN},
2668 2732
2669 [0x0f] = KEY_PREVIOUS, /* Prev */ 2733 { 0x10, KEY_HOME},
2670 [0x1b] = KEY_PAUSE, /* Timeshift */ 2734 { 0x12, KEY_ENTER},
2671 [0x1a] = KEY_NEXT, /* Next */
2672 2735
2673 [0x0e] = KEY_STOP, 2736 { 0x14, KEY_RECORD},
2674 [0x1f] = KEY_PLAY, 2737 { 0x15, KEY_STOP},
2675 [0x1e] = KEY_PLAYPAUSE, /* Pause */ 2738 { 0x16, KEY_PLAY},
2739 { 0x17, KEY_MUTE},
2676 2740
2677 [0x1d] = KEY_RECORD, 2741 { 0x18, KEY_UP},
2678 [0x13] = KEY_MUTE, 2742 { 0x19, KEY_DOWN},
2679 [0x19] = KEY_SHUFFLE, /* Snapshot */ 2743 { 0x1a, KEY_LEFT},
2744 { 0x1b, KEY_RIGHT},
2680 2745
2746 { 0x1c, KEY_RED},
2747 { 0x1d, KEY_GREEN},
2748 { 0x1e, KEY_YELLOW},
2749 { 0x1f, KEY_BLUE},
2750};
2751struct ir_scancode_table ir_codes_kaiomy_table = {
2752 .scan = ir_codes_kaiomy,
2753 .size = ARRAY_SIZE(ir_codes_kaiomy),
2754};
2755EXPORT_SYMBOL_GPL(ir_codes_kaiomy_table);
2756
2757static struct ir_scancode ir_codes_avermedia_a16d[] = {
2758 { 0x20, KEY_LIST},
2759 { 0x00, KEY_POWER},
2760 { 0x28, KEY_1},
2761 { 0x18, KEY_2},
2762 { 0x38, KEY_3},
2763 { 0x24, KEY_4},
2764 { 0x14, KEY_5},
2765 { 0x34, KEY_6},
2766 { 0x2c, KEY_7},
2767 { 0x1c, KEY_8},
2768 { 0x3c, KEY_9},
2769 { 0x12, KEY_SUBTITLE},
2770 { 0x22, KEY_0},
2771 { 0x32, KEY_REWIND},
2772 { 0x3a, KEY_SHUFFLE},
2773 { 0x02, KEY_PRINT},
2774 { 0x11, KEY_CHANNELDOWN},
2775 { 0x31, KEY_CHANNELUP},
2776 { 0x0c, KEY_ZOOM},
2777 { 0x1e, KEY_VOLUMEDOWN},
2778 { 0x3e, KEY_VOLUMEUP},
2779 { 0x0a, KEY_MUTE},
2780 { 0x04, KEY_AUDIO},
2781 { 0x26, KEY_RECORD},
2782 { 0x06, KEY_PLAY},
2783 { 0x36, KEY_STOP},
2784 { 0x16, KEY_PAUSE},
2785 { 0x2e, KEY_REWIND},
2786 { 0x0e, KEY_FASTFORWARD},
2787 { 0x30, KEY_TEXT},
2788 { 0x21, KEY_GREEN},
2789 { 0x01, KEY_BLUE},
2790 { 0x08, KEY_EPG},
2791 { 0x2a, KEY_MENU},
2792};
2793struct ir_scancode_table ir_codes_avermedia_a16d_table = {
2794 .scan = ir_codes_avermedia_a16d,
2795 .size = ARRAY_SIZE(ir_codes_avermedia_a16d),
2681}; 2796};
2682EXPORT_SYMBOL_GPL(ir_codes_real_audio_220_32_keys); 2797EXPORT_SYMBOL_GPL(ir_codes_avermedia_a16d_table);
2798
2799/* Encore ENLTV-FM v5.3
2800 Mauro Carvalho Chehab <mchehab@infradead.org>
2801 */
2802static struct ir_scancode ir_codes_encore_enltv_fm53[] = {
2803 { 0x10, KEY_POWER2},
2804 { 0x06, KEY_MUTE},
2805
2806 { 0x09, KEY_1},
2807 { 0x1d, KEY_2},
2808 { 0x1f, KEY_3},
2809 { 0x19, KEY_4},
2810 { 0x1b, KEY_5},
2811 { 0x11, KEY_6},
2812 { 0x17, KEY_7},
2813 { 0x12, KEY_8},
2814 { 0x16, KEY_9},
2815 { 0x48, KEY_0},
2816
2817 { 0x04, KEY_LIST}, /* -/-- */
2818 { 0x40, KEY_LAST}, /* recall */
2819
2820 { 0x02, KEY_MODE}, /* TV/AV */
2821 { 0x05, KEY_CAMERA}, /* SNAPSHOT */
2822
2823 { 0x4c, KEY_CHANNELUP}, /* UP */
2824 { 0x00, KEY_CHANNELDOWN}, /* DOWN */
2825 { 0x0d, KEY_VOLUMEUP}, /* RIGHT */
2826 { 0x15, KEY_VOLUMEDOWN}, /* LEFT */
2827 { 0x49, KEY_ENTER}, /* OK */
2828
2829 { 0x54, KEY_RECORD},
2830 { 0x4d, KEY_PLAY}, /* pause */
2831
2832 { 0x1e, KEY_MENU}, /* video setting */
2833 { 0x0e, KEY_RIGHT}, /* <- */
2834 { 0x1a, KEY_LEFT}, /* -> */
2835
2836 { 0x0a, KEY_CLEAR}, /* video default */
2837 { 0x0c, KEY_ZOOM}, /* hide pannel */
2838 { 0x47, KEY_SLEEP}, /* shutdown */
2839};
2840struct ir_scancode_table ir_codes_encore_enltv_fm53_table = {
2841 .scan = ir_codes_encore_enltv_fm53,
2842 .size = ARRAY_SIZE(ir_codes_encore_enltv_fm53),
2843};
2844EXPORT_SYMBOL_GPL(ir_codes_encore_enltv_fm53_table);
2845
2846/* Zogis Real Audio 220 - 32 keys IR */
2847static struct ir_scancode ir_codes_real_audio_220_32_keys[] = {
2848 { 0x1c, KEY_RADIO},
2849 { 0x12, KEY_POWER2},
2850
2851 { 0x01, KEY_1},
2852 { 0x02, KEY_2},
2853 { 0x03, KEY_3},
2854 { 0x04, KEY_4},
2855 { 0x05, KEY_5},
2856 { 0x06, KEY_6},
2857 { 0x07, KEY_7},
2858 { 0x08, KEY_8},
2859 { 0x09, KEY_9},
2860 { 0x00, KEY_0},
2861
2862 { 0x0c, KEY_VOLUMEUP},
2863 { 0x18, KEY_VOLUMEDOWN},
2864 { 0x0b, KEY_CHANNELUP},
2865 { 0x15, KEY_CHANNELDOWN},
2866 { 0x16, KEY_ENTER},
2867
2868 { 0x11, KEY_LIST}, /* Source */
2869 { 0x0d, KEY_AUDIO}, /* stereo */
2870
2871 { 0x0f, KEY_PREVIOUS}, /* Prev */
2872 { 0x1b, KEY_TIME}, /* Timeshift */
2873 { 0x1a, KEY_NEXT}, /* Next */
2874
2875 { 0x0e, KEY_STOP},
2876 { 0x1f, KEY_PLAY},
2877 { 0x1e, KEY_PLAYPAUSE}, /* Pause */
2878
2879 { 0x1d, KEY_RECORD},
2880 { 0x13, KEY_MUTE},
2881 { 0x19, KEY_CAMERA}, /* Snapshot */
2882
2883};
2884struct ir_scancode_table ir_codes_real_audio_220_32_keys_table = {
2885 .scan = ir_codes_real_audio_220_32_keys,
2886 .size = ARRAY_SIZE(ir_codes_real_audio_220_32_keys),
2887};
2888EXPORT_SYMBOL_GPL(ir_codes_real_audio_220_32_keys_table);
2683 2889
2684/* ATI TV Wonder HD 600 USB 2890/* ATI TV Wonder HD 600 USB
2685 Devin Heitmueller <devin.heitmueller@gmail.com> 2891 Devin Heitmueller <devin.heitmueller@gmail.com>
2686 */ 2892 */
2687IR_KEYTAB_TYPE ir_codes_ati_tv_wonder_hd_600[IR_KEYTAB_SIZE] = { 2893static struct ir_scancode ir_codes_ati_tv_wonder_hd_600[] = {
2688 [0x00] = KEY_RECORD, /* Row 1 */ 2894 { 0x00, KEY_RECORD}, /* Row 1 */
2689 [0x01] = KEY_PLAYPAUSE, 2895 { 0x01, KEY_PLAYPAUSE},
2690 [0x02] = KEY_STOP, 2896 { 0x02, KEY_STOP},
2691 [0x03] = KEY_POWER, 2897 { 0x03, KEY_POWER},
2692 [0x04] = KEY_PREVIOUS, /* Row 2 */ 2898 { 0x04, KEY_PREVIOUS}, /* Row 2 */
2693 [0x05] = KEY_REWIND, 2899 { 0x05, KEY_REWIND},
2694 [0x06] = KEY_FORWARD, 2900 { 0x06, KEY_FORWARD},
2695 [0x07] = KEY_NEXT, 2901 { 0x07, KEY_NEXT},
2696 [0x08] = KEY_EPG, /* Row 3 */ 2902 { 0x08, KEY_EPG}, /* Row 3 */
2697 [0x09] = KEY_HOME, 2903 { 0x09, KEY_HOME},
2698 [0x0a] = KEY_MENU, 2904 { 0x0a, KEY_MENU},
2699 [0x0b] = KEY_CHANNELUP, 2905 { 0x0b, KEY_CHANNELUP},
2700 [0x0c] = KEY_BACK, /* Row 4 */ 2906 { 0x0c, KEY_BACK}, /* Row 4 */
2701 [0x0d] = KEY_UP, 2907 { 0x0d, KEY_UP},
2702 [0x0e] = KEY_INFO, 2908 { 0x0e, KEY_INFO},
2703 [0x0f] = KEY_CHANNELDOWN, 2909 { 0x0f, KEY_CHANNELDOWN},
2704 [0x10] = KEY_LEFT, /* Row 5 */ 2910 { 0x10, KEY_LEFT}, /* Row 5 */
2705 [0x11] = KEY_SELECT, 2911 { 0x11, KEY_SELECT},
2706 [0x12] = KEY_RIGHT, 2912 { 0x12, KEY_RIGHT},
2707 [0x13] = KEY_VOLUMEUP, 2913 { 0x13, KEY_VOLUMEUP},
2708 [0x14] = KEY_LAST, /* Row 6 */ 2914 { 0x14, KEY_LAST}, /* Row 6 */
2709 [0x15] = KEY_DOWN, 2915 { 0x15, KEY_DOWN},
2710 [0x16] = KEY_MUTE, 2916 { 0x16, KEY_MUTE},
2711 [0x17] = KEY_VOLUMEDOWN, 2917 { 0x17, KEY_VOLUMEDOWN},
2712}; 2918};
2713 2919struct ir_scancode_table ir_codes_ati_tv_wonder_hd_600_table = {
2714EXPORT_SYMBOL_GPL(ir_codes_ati_tv_wonder_hd_600); 2920 .scan = ir_codes_ati_tv_wonder_hd_600,
2921 .size = ARRAY_SIZE(ir_codes_ati_tv_wonder_hd_600),
2922};
2923EXPORT_SYMBOL_GPL(ir_codes_ati_tv_wonder_hd_600_table);
2715 2924
2716/* DVBWorld remotes 2925/* DVBWorld remotes
2717 Igor M. Liplianin <liplianin@me.by> 2926 Igor M. Liplianin <liplianin@me.by>
2718 */ 2927 */
2719IR_KEYTAB_TYPE ir_codes_dm1105_nec[IR_KEYTAB_SIZE] = { 2928static struct ir_scancode ir_codes_dm1105_nec[] = {
2720 [0x0a] = KEY_Q, /*power*/ 2929 { 0x0a, KEY_POWER2}, /* power */
2721 [0x0c] = KEY_M, /*mute*/ 2930 { 0x0c, KEY_MUTE}, /* mute */
2722 [0x11] = KEY_1, 2931 { 0x11, KEY_1},
2723 [0x12] = KEY_2, 2932 { 0x12, KEY_2},
2724 [0x13] = KEY_3, 2933 { 0x13, KEY_3},
2725 [0x14] = KEY_4, 2934 { 0x14, KEY_4},
2726 [0x15] = KEY_5, 2935 { 0x15, KEY_5},
2727 [0x16] = KEY_6, 2936 { 0x16, KEY_6},
2728 [0x17] = KEY_7, 2937 { 0x17, KEY_7},
2729 [0x18] = KEY_8, 2938 { 0x18, KEY_8},
2730 [0x19] = KEY_9, 2939 { 0x19, KEY_9},
2731 [0x10] = KEY_0, 2940 { 0x10, KEY_0},
2732 [0x1c] = KEY_PAGEUP, /*ch+*/ 2941 { 0x1c, KEY_CHANNELUP}, /* ch+ */
2733 [0x0f] = KEY_PAGEDOWN, /*ch-*/ 2942 { 0x0f, KEY_CHANNELDOWN}, /* ch- */
2734 [0x1a] = KEY_O, /*vol+*/ 2943 { 0x1a, KEY_VOLUMEUP}, /* vol+ */
2735 [0x0e] = KEY_Z, /*vol-*/ 2944 { 0x0e, KEY_VOLUMEDOWN}, /* vol- */
2736 [0x04] = KEY_R, /*rec*/ 2945 { 0x04, KEY_RECORD}, /* rec */
2737 [0x09] = KEY_D, /*fav*/ 2946 { 0x09, KEY_CHANNEL}, /* fav */
2738 [0x08] = KEY_BACKSPACE, /*rewind*/ 2947 { 0x08, KEY_BACKSPACE}, /* rewind */
2739 [0x07] = KEY_A, /*fast*/ 2948 { 0x07, KEY_FASTFORWARD}, /* fast */
2740 [0x0b] = KEY_P, /*pause*/ 2949 { 0x0b, KEY_PAUSE}, /* pause */
2741 [0x02] = KEY_ESC, /*cancel*/ 2950 { 0x02, KEY_ESC}, /* cancel */
2742 [0x03] = KEY_G, /*tab*/ 2951 { 0x03, KEY_TAB}, /* tab */
2743 [0x00] = KEY_UP, /*up*/ 2952 { 0x00, KEY_UP}, /* up */
2744 [0x1f] = KEY_ENTER, /*ok*/ 2953 { 0x1f, KEY_ENTER}, /* ok */
2745 [0x01] = KEY_DOWN, /*down*/ 2954 { 0x01, KEY_DOWN}, /* down */
2746 [0x05] = KEY_C, /*cap*/ 2955 { 0x05, KEY_RECORD}, /* cap */
2747 [0x06] = KEY_S, /*stop*/ 2956 { 0x06, KEY_STOP}, /* stop */
2748 [0x40] = KEY_F, /*full*/ 2957 { 0x40, KEY_ZOOM}, /* full */
2749 [0x1e] = KEY_W, /*tvmode*/ 2958 { 0x1e, KEY_TV}, /* tvmode */
2750 [0x1b] = KEY_B, /*recall*/ 2959 { 0x1b, KEY_B}, /* recall */
2751}; 2960};
2752EXPORT_SYMBOL_GPL(ir_codes_dm1105_nec); 2961struct ir_scancode_table ir_codes_dm1105_nec_table = {
2962 .scan = ir_codes_dm1105_nec,
2963 .size = ARRAY_SIZE(ir_codes_dm1105_nec),
2964};
2965EXPORT_SYMBOL_GPL(ir_codes_dm1105_nec_table);
2966
2967/* Terratec Cinergy Hybrid T USB XS
2968 Devin Heitmueller <dheitmueller@linuxtv.org>
2969 */
2970static struct ir_scancode ir_codes_terratec_cinergy_xs[] = {
2971 { 0x41, KEY_HOME},
2972 { 0x01, KEY_POWER},
2973 { 0x42, KEY_MENU},
2974 { 0x02, KEY_1},
2975 { 0x03, KEY_2},
2976 { 0x04, KEY_3},
2977 { 0x43, KEY_SUBTITLE},
2978 { 0x05, KEY_4},
2979 { 0x06, KEY_5},
2980 { 0x07, KEY_6},
2981 { 0x44, KEY_TEXT},
2982 { 0x08, KEY_7},
2983 { 0x09, KEY_8},
2984 { 0x0a, KEY_9},
2985 { 0x45, KEY_DELETE},
2986 { 0x0b, KEY_TUNER},
2987 { 0x0c, KEY_0},
2988 { 0x0d, KEY_MODE},
2989 { 0x46, KEY_TV},
2990 { 0x47, KEY_DVD},
2991 { 0x49, KEY_VIDEO},
2992 { 0x4b, KEY_AUX},
2993 { 0x10, KEY_UP},
2994 { 0x11, KEY_LEFT},
2995 { 0x12, KEY_OK},
2996 { 0x13, KEY_RIGHT},
2997 { 0x14, KEY_DOWN},
2998 { 0x0f, KEY_EPG},
2999 { 0x16, KEY_INFO},
3000 { 0x4d, KEY_BACKSPACE},
3001 { 0x1c, KEY_VOLUMEUP},
3002 { 0x4c, KEY_PLAY},
3003 { 0x1b, KEY_CHANNELUP},
3004 { 0x1e, KEY_VOLUMEDOWN},
3005 { 0x1d, KEY_MUTE},
3006 { 0x1f, KEY_CHANNELDOWN},
3007 { 0x17, KEY_RED},
3008 { 0x18, KEY_GREEN},
3009 { 0x19, KEY_YELLOW},
3010 { 0x1a, KEY_BLUE},
3011 { 0x58, KEY_RECORD},
3012 { 0x48, KEY_STOP},
3013 { 0x40, KEY_PAUSE},
3014 { 0x54, KEY_LAST},
3015 { 0x4e, KEY_REWIND},
3016 { 0x4f, KEY_FASTFORWARD},
3017 { 0x5c, KEY_NEXT},
3018};
3019struct ir_scancode_table ir_codes_terratec_cinergy_xs_table = {
3020 .scan = ir_codes_terratec_cinergy_xs,
3021 .size = ARRAY_SIZE(ir_codes_terratec_cinergy_xs),
3022};
3023EXPORT_SYMBOL_GPL(ir_codes_terratec_cinergy_xs_table);
2753 3024
2754/* EVGA inDtube 3025/* EVGA inDtube
2755 Devin Heitmueller <devin.heitmueller@gmail.com> 3026 Devin Heitmueller <devin.heitmueller@gmail.com>
2756 */ 3027 */
2757IR_KEYTAB_TYPE ir_codes_evga_indtube[IR_KEYTAB_SIZE] = { 3028static struct ir_scancode ir_codes_evga_indtube[] = {
2758 [0x12] = KEY_POWER, 3029 { 0x12, KEY_POWER},
2759 [0x02] = KEY_MODE, /* TV */ 3030 { 0x02, KEY_MODE}, /* TV */
2760 [0x14] = KEY_MUTE, 3031 { 0x14, KEY_MUTE},
2761 [0x1a] = KEY_CHANNELUP, 3032 { 0x1a, KEY_CHANNELUP},
2762 [0x16] = KEY_TV2, /* PIP */ 3033 { 0x16, KEY_TV2}, /* PIP */
2763 [0x1d] = KEY_VOLUMEUP, 3034 { 0x1d, KEY_VOLUMEUP},
2764 [0x05] = KEY_CHANNELDOWN, 3035 { 0x05, KEY_CHANNELDOWN},
2765 [0x0f] = KEY_PLAYPAUSE, 3036 { 0x0f, KEY_PLAYPAUSE},
2766 [0x19] = KEY_VOLUMEDOWN, 3037 { 0x19, KEY_VOLUMEDOWN},
2767 [0x1c] = KEY_REWIND, 3038 { 0x1c, KEY_REWIND},
2768 [0x0d] = KEY_RECORD, 3039 { 0x0d, KEY_RECORD},
2769 [0x18] = KEY_FORWARD, 3040 { 0x18, KEY_FORWARD},
2770 [0x1e] = KEY_PREVIOUS, 3041 { 0x1e, KEY_PREVIOUS},
2771 [0x1b] = KEY_STOP, 3042 { 0x1b, KEY_STOP},
2772 [0x1f] = KEY_NEXT, 3043 { 0x1f, KEY_NEXT},
2773 [0x13] = KEY_CAMERA, 3044 { 0x13, KEY_CAMERA},
2774}; 3045};
2775EXPORT_SYMBOL_GPL(ir_codes_evga_indtube); 3046struct ir_scancode_table ir_codes_evga_indtube_table = {
3047 .scan = ir_codes_evga_indtube,
3048 .size = ARRAY_SIZE(ir_codes_evga_indtube),
3049};
3050EXPORT_SYMBOL_GPL(ir_codes_evga_indtube_table);
3051
3052static struct ir_scancode ir_codes_videomate_s350[] = {
3053 { 0x00, KEY_TV},
3054 { 0x01, KEY_DVD},
3055 { 0x04, KEY_RECORD},
3056 { 0x05, KEY_VIDEO}, /* TV/Video */
3057 { 0x07, KEY_STOP},
3058 { 0x08, KEY_PLAYPAUSE},
3059 { 0x0a, KEY_REWIND},
3060 { 0x0f, KEY_FASTFORWARD},
3061 { 0x10, KEY_CHANNELUP},
3062 { 0x12, KEY_VOLUMEUP},
3063 { 0x13, KEY_CHANNELDOWN},
3064 { 0x14, KEY_MUTE},
3065 { 0x15, KEY_VOLUMEDOWN},
3066 { 0x16, KEY_1},
3067 { 0x17, KEY_2},
3068 { 0x18, KEY_3},
3069 { 0x19, KEY_4},
3070 { 0x1a, KEY_5},
3071 { 0x1b, KEY_6},
3072 { 0x1c, KEY_7},
3073 { 0x1d, KEY_8},
3074 { 0x1e, KEY_9},
3075 { 0x1f, KEY_0},
3076 { 0x21, KEY_SLEEP},
3077 { 0x24, KEY_ZOOM},
3078 { 0x25, KEY_LAST}, /* Recall */
3079 { 0x26, KEY_SUBTITLE}, /* CC */
3080 { 0x27, KEY_LANGUAGE}, /* MTS */
3081 { 0x29, KEY_CHANNEL}, /* SURF */
3082 { 0x2b, KEY_A},
3083 { 0x2c, KEY_B},
3084 { 0x2f, KEY_CAMERA}, /* Snapshot */
3085 { 0x23, KEY_RADIO},
3086 { 0x02, KEY_PREVIOUSSONG},
3087 { 0x06, KEY_NEXTSONG},
3088 { 0x03, KEY_EPG},
3089 { 0x09, KEY_SETUP},
3090 { 0x22, KEY_BACKSPACE},
3091 { 0x0c, KEY_UP},
3092 { 0x0e, KEY_DOWN},
3093 { 0x0b, KEY_LEFT},
3094 { 0x0d, KEY_RIGHT},
3095 { 0x11, KEY_ENTER},
3096 { 0x20, KEY_TEXT},
3097};
3098struct ir_scancode_table ir_codes_videomate_s350_table = {
3099 .scan = ir_codes_videomate_s350,
3100 .size = ARRAY_SIZE(ir_codes_videomate_s350),
3101};
3102EXPORT_SYMBOL_GPL(ir_codes_videomate_s350_table);
3103
3104/* GADMEI UTV330+ RM008Z remote
3105 Shine Liu <shinel@foxmail.com>
3106 */
3107static struct ir_scancode ir_codes_gadmei_rm008z[] = {
3108 { 0x14, KEY_POWER2}, /* POWER OFF */
3109 { 0x0c, KEY_MUTE}, /* MUTE */
3110
3111 { 0x18, KEY_TV}, /* TV */
3112 { 0x0e, KEY_VIDEO}, /* AV */
3113 { 0x0b, KEY_AUDIO}, /* SV */
3114 { 0x0f, KEY_RADIO}, /* FM */
3115
3116 { 0x00, KEY_1},
3117 { 0x01, KEY_2},
3118 { 0x02, KEY_3},
3119 { 0x03, KEY_4},
3120 { 0x04, KEY_5},
3121 { 0x05, KEY_6},
3122 { 0x06, KEY_7},
3123 { 0x07, KEY_8},
3124 { 0x08, KEY_9},
3125 { 0x09, KEY_0},
3126 { 0x0a, KEY_INFO}, /* OSD */
3127 { 0x1c, KEY_BACKSPACE}, /* LAST */
3128
3129 { 0x0d, KEY_PLAY}, /* PLAY */
3130 { 0x1e, KEY_CAMERA}, /* SNAPSHOT */
3131 { 0x1a, KEY_RECORD}, /* RECORD */
3132 { 0x17, KEY_STOP}, /* STOP */
3133
3134 { 0x1f, KEY_UP}, /* UP */
3135 { 0x44, KEY_DOWN}, /* DOWN */
3136 { 0x46, KEY_TAB}, /* BACK */
3137 { 0x4a, KEY_ZOOM}, /* FULLSECREEN */
3138
3139 { 0x10, KEY_VOLUMEUP}, /* VOLUMEUP */
3140 { 0x11, KEY_VOLUMEDOWN}, /* VOLUMEDOWN */
3141 { 0x12, KEY_CHANNELUP}, /* CHANNELUP */
3142 { 0x13, KEY_CHANNELDOWN}, /* CHANNELDOWN */
3143 { 0x15, KEY_ENTER}, /* OK */
3144};
3145struct ir_scancode_table ir_codes_gadmei_rm008z_table = {
3146 .scan = ir_codes_gadmei_rm008z,
3147 .size = ARRAY_SIZE(ir_codes_gadmei_rm008z),
3148};
3149EXPORT_SYMBOL_GPL(ir_codes_gadmei_rm008z_table);
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index b10935630154..bc4b004ba7db 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -27,7 +27,7 @@ module_param_named(debug, tda18271_debug, int, 0644);
27MODULE_PARM_DESC(debug, "set debug level " 27MODULE_PARM_DESC(debug, "set debug level "
28 "(info=1, map=2, reg=4, adv=8, cal=16 (or-able))"); 28 "(info=1, map=2, reg=4, adv=8, cal=16 (or-able))");
29 29
30static int tda18271_cal_on_startup; 30static int tda18271_cal_on_startup = -1;
31module_param_named(cal, tda18271_cal_on_startup, int, 0644); 31module_param_named(cal, tda18271_cal_on_startup, int, 0644);
32MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup"); 32MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup");
33 33
@@ -1192,10 +1192,25 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
1192 case 0: 1192 case 0:
1193 goto fail; 1193 goto fail;
1194 case 1: 1194 case 1:
1195 {
1195 /* new tuner instance */ 1196 /* new tuner instance */
1197 int rf_cal_on_startup;
1198
1196 priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; 1199 priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO;
1197 priv->role = (cfg) ? cfg->role : TDA18271_MASTER; 1200 priv->role = (cfg) ? cfg->role : TDA18271_MASTER;
1198 priv->config = (cfg) ? cfg->config : 0; 1201 priv->config = (cfg) ? cfg->config : 0;
1202
1203 /* tda18271_cal_on_startup == -1 when cal
1204 * module option is unset */
1205 if (tda18271_cal_on_startup == -1) {
1206 /* honor attach-time configuration */
1207 rf_cal_on_startup =
1208 ((cfg) && (cfg->rf_cal_on_startup)) ? 1 : 0;
1209 } else {
1210 /* module option overrides attach configuration */
1211 rf_cal_on_startup = tda18271_cal_on_startup;
1212 }
1213
1199 priv->cal_initialized = false; 1214 priv->cal_initialized = false;
1200 mutex_init(&priv->lock); 1215 mutex_init(&priv->lock);
1201 1216
@@ -1213,11 +1228,12 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
1213 mutex_lock(&priv->lock); 1228 mutex_lock(&priv->lock);
1214 tda18271_init_regs(fe); 1229 tda18271_init_regs(fe);
1215 1230
1216 if ((tda18271_cal_on_startup) && (priv->id == TDA18271HDC2)) 1231 if ((rf_cal_on_startup) && (priv->id == TDA18271HDC2))
1217 tda18271c2_rf_cal_init(fe); 1232 tda18271c2_rf_cal_init(fe);
1218 1233
1219 mutex_unlock(&priv->lock); 1234 mutex_unlock(&priv->lock);
1220 break; 1235 break;
1236 }
1221 default: 1237 default:
1222 /* existing tuner instance */ 1238 /* existing tuner instance */
1223 fe->tuner_priv = priv; 1239 fe->tuner_priv = priv;
diff --git a/drivers/media/common/tuners/tda18271-priv.h b/drivers/media/common/tuners/tda18271-priv.h
index 74beb28806f8..e6a80ad09356 100644
--- a/drivers/media/common/tuners/tda18271-priv.h
+++ b/drivers/media/common/tuners/tda18271-priv.h
@@ -137,17 +137,17 @@ extern int tda18271_debug;
137#define tda_printk(kern, fmt, arg...) \ 137#define tda_printk(kern, fmt, arg...) \
138 printk(kern "%s: " fmt, __func__, ##arg) 138 printk(kern "%s: " fmt, __func__, ##arg)
139 139
140#define dprintk(kern, lvl, fmt, arg...) do {\ 140#define tda_dprintk(lvl, fmt, arg...) do {\
141 if (tda18271_debug & lvl) \ 141 if (tda18271_debug & lvl) \
142 tda_printk(kern, fmt, ##arg); } while (0) 142 tda_printk(KERN_DEBUG, fmt, ##arg); } while (0)
143 143
144#define tda_info(fmt, arg...) printk(KERN_INFO fmt, ##arg) 144#define tda_info(fmt, arg...) printk(KERN_INFO fmt, ##arg)
145#define tda_warn(fmt, arg...) tda_printk(KERN_WARNING, fmt, ##arg) 145#define tda_warn(fmt, arg...) tda_printk(KERN_WARNING, fmt, ##arg)
146#define tda_err(fmt, arg...) tda_printk(KERN_ERR, fmt, ##arg) 146#define tda_err(fmt, arg...) tda_printk(KERN_ERR, fmt, ##arg)
147#define tda_dbg(fmt, arg...) dprintk(KERN_DEBUG, DBG_INFO, fmt, ##arg) 147#define tda_dbg(fmt, arg...) tda_dprintk(DBG_INFO, fmt, ##arg)
148#define tda_map(fmt, arg...) dprintk(KERN_DEBUG, DBG_MAP, fmt, ##arg) 148#define tda_map(fmt, arg...) tda_dprintk(DBG_MAP, fmt, ##arg)
149#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) 149#define tda_reg(fmt, arg...) tda_dprintk(DBG_REG, fmt, ##arg)
150#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg) 150#define tda_cal(fmt, arg...) tda_dprintk(DBG_CAL, fmt, ##arg)
151 151
152#define tda_fail(ret) \ 152#define tda_fail(ret) \
153({ \ 153({ \
diff --git a/drivers/media/common/tuners/tda18271.h b/drivers/media/common/tuners/tda18271.h
index 53a9892a18d0..71bac9593f1e 100644
--- a/drivers/media/common/tuners/tda18271.h
+++ b/drivers/media/common/tuners/tda18271.h
@@ -77,6 +77,9 @@ struct tda18271_config {
77 /* use i2c gate provided by analog or digital demod */ 77 /* use i2c gate provided by analog or digital demod */
78 enum tda18271_i2c_gate gate; 78 enum tda18271_i2c_gate gate;
79 79
80 /* force rf tracking filter calibration on startup */
81 unsigned int rf_cal_on_startup:1;
82
80 /* some i2c providers cant write all 39 registers at once */ 83 /* some i2c providers cant write all 39 registers at once */
81 unsigned int small_i2c:1; 84 unsigned int small_i2c:1;
82 85
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c
index 149d54cdf7b9..8abbcc5fcf95 100644
--- a/drivers/media/common/tuners/tuner-simple.c
+++ b/drivers/media/common/tuners/tuner-simple.c
@@ -144,6 +144,8 @@ static inline int tuner_stereo(const int type, const int status)
144 case TUNER_LG_NTSC_TAPE: 144 case TUNER_LG_NTSC_TAPE:
145 case TUNER_TCL_MF02GIP_5N: 145 case TUNER_TCL_MF02GIP_5N:
146 return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); 146 return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
147 case TUNER_PHILIPS_FM1216MK5:
148 return status | TUNER_STEREO;
147 default: 149 default:
148 return status & TUNER_STEREO; 150 return status & TUNER_STEREO;
149 } 151 }
@@ -508,6 +510,10 @@ static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer)
508 case TUNER_TCL_MF02GIP_5N: 510 case TUNER_TCL_MF02GIP_5N:
509 buffer[3] = 0x19; 511 buffer[3] = 0x19;
510 break; 512 break;
513 case TUNER_PHILIPS_FM1216MK5:
514 buffer[2] = 0x88;
515 buffer[3] = 0x09;
516 break;
511 case TUNER_TNF_5335MF: 517 case TUNER_TNF_5335MF:
512 buffer[3] = 0x11; 518 buffer[3] = 0x11;
513 break; 519 break;
diff --git a/drivers/media/common/tuners/tuner-types.c b/drivers/media/common/tuners/tuner-types.c
index 6a7f1a417c27..5c6ef1e23c94 100644
--- a/drivers/media/common/tuners/tuner-types.c
+++ b/drivers/media/common/tuners/tuner-types.c
@@ -1301,6 +1301,25 @@ static struct tuner_params tuner_fq1216lme_mk3_params[] = {
1301 }, 1301 },
1302}; 1302};
1303 1303
1304/* ----- TUNER_PARTSNIC_PTI_5NF05 - Partsnic (Daewoo) PTI-5NF05 NTSC ----- */
1305
1306static struct tuner_range tuner_partsnic_pti_5nf05_ranges[] = {
1307 /* The datasheet specified channel ranges and the bandswitch byte */
1308 /* The control byte value of 0x8e is just a guess */
1309 { 16 * 133.25 /*MHz*/, 0x8e, 0x01, }, /* Channels 2 - B */
1310 { 16 * 367.25 /*MHz*/, 0x8e, 0x02, }, /* Channels C - W+11 */
1311 { 16 * 999.99 , 0x8e, 0x08, }, /* Channels W+12 - 69 */
1312};
1313
1314static struct tuner_params tuner_partsnic_pti_5nf05_params[] = {
1315 {
1316 .type = TUNER_PARAM_TYPE_NTSC,
1317 .ranges = tuner_partsnic_pti_5nf05_ranges,
1318 .count = ARRAY_SIZE(tuner_partsnic_pti_5nf05_ranges),
1319 .cb_first_if_lower_freq = 1, /* not specified but safe to do */
1320 },
1321};
1322
1304/* --------------------------------------------------------------------- */ 1323/* --------------------------------------------------------------------- */
1305 1324
1306struct tunertype tuners[] = { 1325struct tunertype tuners[] = {
@@ -1753,6 +1772,12 @@ struct tunertype tuners[] = {
1753 .params = tuner_fq1216lme_mk3_params, 1772 .params = tuner_fq1216lme_mk3_params,
1754 .count = ARRAY_SIZE(tuner_fq1216lme_mk3_params), 1773 .count = ARRAY_SIZE(tuner_fq1216lme_mk3_params),
1755 }, 1774 },
1775
1776 [TUNER_PARTSNIC_PTI_5NF05] = {
1777 .name = "Partsnic (Daewoo) PTI-5NF05",
1778 .params = tuner_partsnic_pti_5nf05_params,
1779 .count = ARRAY_SIZE(tuner_partsnic_pti_5nf05_params),
1780 },
1756}; 1781};
1757EXPORT_SYMBOL(tuners); 1782EXPORT_SYMBOL(tuners);
1758 1783
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
index b0198691892a..1d0e4b1ef10c 100644
--- a/drivers/media/dvb/Kconfig
+++ b/drivers/media/dvb/Kconfig
@@ -2,6 +2,19 @@
2# DVB device configuration 2# DVB device configuration
3# 3#
4 4
5config DVB_MAX_ADAPTERS
6 int "maximum number of DVB/ATSC adapters"
7 depends on DVB_CORE
8 default 8
9 range 1 255
10 help
11 Maximum number of DVB/ATSC adapters. Increasing this number
12 increases the memory consumption of the DVB subsystem even
13 if a much lower number of DVB/ATSC adapters is present.
14 Only values in the range 4-32 are tested.
15
16 If you are unsure about this, use the default value 8
17
5config DVB_DYNAMIC_MINORS 18config DVB_DYNAMIC_MINORS
6 bool "Dynamic DVB minor allocation" 19 bool "Dynamic DVB minor allocation"
7 depends on DVB_CORE 20 depends on DVB_CORE
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 9a6307a347b2..850a6c606750 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -66,7 +66,7 @@ static int flexcop_sleep(struct dvb_frontend* fe)
66#endif 66#endif
67 67
68/* SkyStar2 DVB-S rev 2.3 */ 68/* SkyStar2 DVB-S rev 2.3 */
69#if FE_SUPPORTED(MT312) 69#if FE_SUPPORTED(MT312) && FE_SUPPORTED(PLL)
70static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) 70static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
71{ 71{
72/* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */ 72/* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */
@@ -155,55 +155,34 @@ static struct mt312_config skystar23_samsung_tbdu18132_config = {
155 .demod_address = 0x0e, 155 .demod_address = 0x0e,
156}; 156};
157 157
158static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend *fe,
159 struct dvb_frontend_parameters *params)
160{
161 u8 buf[4];
162 u32 div;
163 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf,
164 .len = sizeof(buf) };
165 struct flexcop_device *fc = fe->dvb->priv;
166 div = (params->frequency + (125/2)) / 125;
167
168 buf[0] = (div >> 8) & 0x7f;
169 buf[1] = (div >> 0) & 0xff;
170 buf[2] = 0x84 | ((div >> 10) & 0x60);
171 buf[3] = 0x80;
172
173 if (params->frequency < 1550000)
174 buf[3] |= 0x02;
175
176 if (fe->ops.i2c_gate_ctrl)
177 fe->ops.i2c_gate_ctrl(fe, 1);
178 if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1)
179 return -EIO;
180 return 0;
181}
182
183static int skystar2_rev23_attach(struct flexcop_device *fc, 158static int skystar2_rev23_attach(struct flexcop_device *fc,
184 struct i2c_adapter *i2c) 159 struct i2c_adapter *i2c)
185{ 160{
161 struct dvb_frontend_ops *ops;
162
186 fc->fe = dvb_attach(mt312_attach, &skystar23_samsung_tbdu18132_config, i2c); 163 fc->fe = dvb_attach(mt312_attach, &skystar23_samsung_tbdu18132_config, i2c);
187 if (fc->fe != NULL) { 164 if (!fc->fe)
188 struct dvb_frontend_ops *ops = &fc->fe->ops; 165 return 0;
189 ops->tuner_ops.set_params = 166
190 skystar23_samsung_tbdu18132_tuner_set_params; 167 if (!dvb_attach(dvb_pll_attach, fc->fe, 0x61, i2c,
191 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; 168 DVB_PLL_SAMSUNG_TBDU18132))
192 ops->diseqc_send_burst = flexcop_diseqc_send_burst; 169 return 0;
193 ops->set_tone = flexcop_set_tone; 170
194 ops->set_voltage = flexcop_set_voltage; 171 ops = &fc->fe->ops;
195 fc->fe_sleep = ops->sleep; 172 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
196 ops->sleep = flexcop_sleep; 173 ops->diseqc_send_burst = flexcop_diseqc_send_burst;
197 return 1; 174 ops->set_tone = flexcop_set_tone;
198 } 175 ops->set_voltage = flexcop_set_voltage;
199 return 0; 176 fc->fe_sleep = ops->sleep;
177 ops->sleep = flexcop_sleep;
178 return 1;
200} 179}
201#else 180#else
202#define skystar2_rev23_attach NULL 181#define skystar2_rev23_attach NULL
203#endif 182#endif
204 183
205/* SkyStar2 DVB-S rev 2.6 */ 184/* SkyStar2 DVB-S rev 2.6 */
206#if FE_SUPPORTED(STV0299) 185#if FE_SUPPORTED(STV0299) && FE_SUPPORTED(PLL)
207static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe, 186static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe,
208 u32 srate, u32 ratio) 187 u32 srate, u32 ratio)
209{ 188{
@@ -232,31 +211,6 @@ static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend *fe,
232 return 0; 211 return 0;
233} 212}
234 213
235static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend *fe,
236 struct dvb_frontend_parameters *params)
237{
238 u8 buf[4];
239 u32 div;
240 struct i2c_msg msg = {
241 .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
242 struct flexcop_device *fc = fe->dvb->priv;
243 div = params->frequency / 125;
244
245 buf[0] = (div >> 8) & 0x7f;
246 buf[1] = div & 0xff;
247 buf[2] = 0x84; /* 0xC4 */
248 buf[3] = 0x08;
249
250 if (params->frequency < 1500000)
251 buf[3] |= 0x10;
252
253 if (fe->ops.i2c_gate_ctrl)
254 fe->ops.i2c_gate_ctrl(fe, 1);
255 if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1)
256 return -EIO;
257 return 0;
258}
259
260static u8 samsung_tbmu24112_inittab[] = { 214static u8 samsung_tbmu24112_inittab[] = {
261 0x01, 0x15, 215 0x01, 0x15,
262 0x02, 0x30, 216 0x02, 0x30,
@@ -318,15 +272,18 @@ static int skystar2_rev26_attach(struct flexcop_device *fc,
318 struct i2c_adapter *i2c) 272 struct i2c_adapter *i2c)
319{ 273{
320 fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c); 274 fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c);
321 if (fc->fe != NULL) { 275 if (!fc->fe)
322 struct dvb_frontend_ops *ops = &fc->fe->ops; 276 return 0;
323 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; 277
324 ops->set_voltage = flexcop_set_voltage; 278 if (!dvb_attach(dvb_pll_attach, fc->fe, 0x61, i2c,
325 fc->fe_sleep = ops->sleep; 279 DVB_PLL_SAMSUNG_TBMU24112))
326 ops->sleep = flexcop_sleep; 280 return 0;
327 return 1; 281
328 } 282 fc->fe->ops.set_voltage = flexcop_set_voltage;
329 return 0; 283 fc->fe_sleep = fc->fe->ops.sleep;
284 fc->fe->ops.sleep = flexcop_sleep;
285 return 1;
286
330} 287}
331#else 288#else
332#define skystar2_rev26_attach NULL 289#define skystar2_rev26_attach NULL
@@ -421,7 +378,7 @@ static int skystar2_rev28_attach(struct flexcop_device *fc,
421 if (!fc->fe) 378 if (!fc->fe)
422 return 0; 379 return 0;
423 380
424 i2c_tuner = cx24123_get_tuner_i2c_adapter(fc->fe);; 381 i2c_tuner = cx24123_get_tuner_i2c_adapter(fc->fe);
425 if (!i2c_tuner) 382 if (!i2c_tuner)
426 return 0; 383 return 0;
427 384
@@ -449,7 +406,7 @@ static int skystar2_rev28_attach(struct flexcop_device *fc,
449#endif 406#endif
450 407
451/* AirStar DVB-T */ 408/* AirStar DVB-T */
452#if FE_SUPPORTED(MT352) 409#if FE_SUPPORTED(MT352) && FE_SUPPORTED(PLL)
453static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend *fe) 410static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend *fe)
454{ 411{
455 static u8 mt352_clock_config[] = { 0x89, 0x18, 0x2d }; 412 static u8 mt352_clock_config[] = { 0x89, 0x18, 0x2d };
@@ -467,32 +424,6 @@ static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend *fe)
467 return 0; 424 return 0;
468} 425}
469 426
470static int samsung_tdtc9251dh0_calc_regs(struct dvb_frontend *fe,
471 struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
472{
473 u32 div;
474 unsigned char bs = 0;
475
476 if (buf_len < 5)
477 return -EINVAL;
478
479#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
480 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
481 if (params->frequency >= 48000000 && params->frequency <= 154000000) \
482 bs = 0x09;
483 if (params->frequency >= 161000000 && params->frequency <= 439000000) \
484 bs = 0x0a;
485 if (params->frequency >= 447000000 && params->frequency <= 863000000) \
486 bs = 0x08;
487
488 pllbuf[0] = 0x61;
489 pllbuf[1] = div >> 8;
490 pllbuf[2] = div & 0xff;
491 pllbuf[3] = 0xcc;
492 pllbuf[4] = bs;
493 return 5;
494}
495
496static struct mt352_config samsung_tdtc9251dh0_config = { 427static struct mt352_config samsung_tdtc9251dh0_config = {
497 .demod_address = 0x0f, 428 .demod_address = 0x0f,
498 .demod_init = samsung_tdtc9251dh0_demod_init, 429 .demod_init = samsung_tdtc9251dh0_demod_init,
@@ -502,11 +433,11 @@ static int airstar_dvbt_attach(struct flexcop_device *fc,
502 struct i2c_adapter *i2c) 433 struct i2c_adapter *i2c)
503{ 434{
504 fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c); 435 fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c);
505 if (fc->fe != NULL) { 436 if (!fc->fe)
506 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; 437 return 0;
507 return 1; 438
508 } 439 return !!dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL,
509 return 0; 440 DVB_PLL_SAMSUNG_TDTC9251DH0);
510} 441}
511#else 442#else
512#define airstar_dvbt_attach NULL 443#define airstar_dvbt_attach NULL
@@ -580,54 +511,7 @@ static int airstar_atsc3_attach(struct flexcop_device *fc,
580#endif 511#endif
581 512
582/* CableStar2 DVB-C */ 513/* CableStar2 DVB-C */
583#if FE_SUPPORTED(STV0297) 514#if FE_SUPPORTED(STV0297) && FE_SUPPORTED(PLL)
584static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe,
585 struct dvb_frontend_parameters *fep)
586{
587 struct flexcop_device *fc = fe->dvb->priv;
588 u8 buf[4];
589 u16 div;
590 int ret;
591
592/* 62.5 kHz * 10 */
593#define REF_FREQ 625
594#define FREQ_OFFSET 36125
595
596 div = ((fep->frequency/1000 + FREQ_OFFSET) * 10) / REF_FREQ;
597/* 4 MHz = 4000 KHz */
598
599 buf[0] = (u8)( div >> 8) & 0x7f;
600 buf[1] = (u8) div & 0xff;
601
602/* F(osc) = N * Reference Freq. (62.5 kHz)
603 * byte 2 : 0 N14 N13 N12 N11 N10 N9 N8
604 * byte 3 : N7 N6 N5 N4 N3 N2 N1 N0
605 * byte 4 : 1 * * AGD R3 R2 R1 R0
606 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
607 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 */
608 buf[2] = 0x95;
609
610/* Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
611 * 47 - 153 0 * 0 0 0 0 0 1 0x01
612 * 153 - 430 0 * 0 0 0 0 1 0 0x02
613 * 430 - 822 0 * 0 0 1 0 0 0 0x08
614 * 822 - 862 1 * 0 0 1 0 0 0 0x88 */
615
616 if (fep->frequency <= 153000000) buf[3] = 0x01;
617 else if (fep->frequency <= 430000000) buf[3] = 0x02;
618 else if (fep->frequency <= 822000000) buf[3] = 0x08;
619 else buf[3] = 0x88;
620
621 if (fe->ops.i2c_gate_ctrl)
622 fe->ops.i2c_gate_ctrl(fe, 0);
623 deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n", fep->frequency,
624 buf[0], buf[1], buf[2], buf[3]);
625 ret = fc->i2c_request(&fc->fc_i2c_adap[2],
626 FC_WRITE, 0x61, buf[0], &buf[1], 3);
627 deb_tuner("tuner write returned: %d\n",ret);
628 return ret;
629}
630
631static u8 alps_tdee4_stv0297_inittab[] = { 515static u8 alps_tdee4_stv0297_inittab[] = {
632 0x80, 0x01, 516 0x80, 0x01,
633 0x80, 0x00, 517 0x80, 0x00,
@@ -711,13 +595,25 @@ static int cablestar2_attach(struct flexcop_device *fc,
711{ 595{
712 fc->fc_i2c_adap[0].no_base_addr = 1; 596 fc->fc_i2c_adap[0].no_base_addr = 1;
713 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c); 597 fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c);
714 if (!fc->fe) { 598 if (!fc->fe)
715 /* Reset for next frontend to try */ 599 goto fail;
716 fc->fc_i2c_adap[0].no_base_addr = 0; 600
717 return 0; 601 /* This tuner doesn't use the stv0297's I2C gate, but instead the
718 } 602 * tuner is connected to a different flexcop I2C adapter. */
719 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; 603 if (fc->fe->ops.i2c_gate_ctrl)
604 fc->fe->ops.i2c_gate_ctrl(fc->fe, 0);
605 fc->fe->ops.i2c_gate_ctrl = NULL;
606
607 if (!dvb_attach(dvb_pll_attach, fc->fe, 0x61,
608 &fc->fc_i2c_adap[2].i2c_adap, DVB_PLL_TDEE4))
609 goto fail;
610
720 return 1; 611 return 1;
612
613fail:
614 /* Reset for next frontend to try */
615 fc->fc_i2c_adap[0].no_base_addr = 0;
616 return 0;
721} 617}
722#else 618#else
723#define cablestar2_attach NULL 619#define cablestar2_attach NULL
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index fec1d77fa855..91353a6faf1d 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1059,7 +1059,7 @@ static int dst_get_tuner_info(struct dst_state *state)
1059 dprintk(verbose, DST_ERROR, 1, "DST type has TS=188"); 1059 dprintk(verbose, DST_ERROR, 1, "DST type has TS=188");
1060 } 1060 }
1061 if (state->board_info[0] == 0xbc) { 1061 if (state->board_info[0] == 0xbc) {
1062 if (state->type_flags != DST_TYPE_IS_ATSC) 1062 if (state->dst_type != DST_TYPE_IS_ATSC)
1063 state->type_flags |= DST_TYPE_HAS_TS188; 1063 state->type_flags |= DST_TYPE_HAS_TS188;
1064 else 1064 else
1065 state->type_flags |= DST_TYPE_HAS_NEWTUNE_2; 1065 state->type_flags |= DST_TYPE_HAS_NEWTUNE_2;
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index 4dbd7d4185af..2d099e271751 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -44,6 +44,14 @@
44#include "cx24116.h" 44#include "cx24116.h"
45#include "z0194a.h" 45#include "z0194a.h"
46 46
47#define UNSET (-1U)
48
49#define DM1105_BOARD_NOAUTO UNSET
50#define DM1105_BOARD_UNKNOWN 0
51#define DM1105_BOARD_DVBWORLD_2002 1
52#define DM1105_BOARD_DVBWORLD_2004 2
53#define DM1105_BOARD_AXESS_DM05 3
54
47/* ----------------------------------------------- */ 55/* ----------------------------------------------- */
48/* 56/*
49 * PCI ID's 57 * PCI ID's
@@ -153,20 +161,105 @@
153 161
154/* GPIO's for LNB power control */ 162/* GPIO's for LNB power control */
155#define DM1105_LNB_MASK 0x00000000 163#define DM1105_LNB_MASK 0x00000000
164#define DM1105_LNB_OFF 0x00020000
156#define DM1105_LNB_13V 0x00010100 165#define DM1105_LNB_13V 0x00010100
157#define DM1105_LNB_18V 0x00000100 166#define DM1105_LNB_18V 0x00000100
158 167
159/* GPIO's for LNB power control for Axess DM05 */ 168/* GPIO's for LNB power control for Axess DM05 */
160#define DM05_LNB_MASK 0x00000000 169#define DM05_LNB_MASK 0x00000000
170#define DM05_LNB_OFF 0x00020000/* actually 13v */
161#define DM05_LNB_13V 0x00020000 171#define DM05_LNB_13V 0x00020000
162#define DM05_LNB_18V 0x00030000 172#define DM05_LNB_18V 0x00030000
163 173
174static unsigned int card[] = {[0 ... 3] = UNSET };
175module_param_array(card, int, NULL, 0444);
176MODULE_PARM_DESC(card, "card type");
177
164static int ir_debug; 178static int ir_debug;
165module_param(ir_debug, int, 0644); 179module_param(ir_debug, int, 0644);
166MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding"); 180MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding");
167 181
182static unsigned int dm1105_devcount;
183
168DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 184DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
169 185
186struct dm1105_board {
187 char *name;
188};
189
190struct dm1105_subid {
191 u16 subvendor;
192 u16 subdevice;
193 u32 card;
194};
195
196static const struct dm1105_board dm1105_boards[] = {
197 [DM1105_BOARD_UNKNOWN] = {
198 .name = "UNKNOWN/GENERIC",
199 },
200 [DM1105_BOARD_DVBWORLD_2002] = {
201 .name = "DVBWorld PCI 2002",
202 },
203 [DM1105_BOARD_DVBWORLD_2004] = {
204 .name = "DVBWorld PCI 2004",
205 },
206 [DM1105_BOARD_AXESS_DM05] = {
207 .name = "Axess/EasyTv DM05",
208 },
209};
210
211static const struct dm1105_subid dm1105_subids[] = {
212 {
213 .subvendor = 0x0000,
214 .subdevice = 0x2002,
215 .card = DM1105_BOARD_DVBWORLD_2002,
216 }, {
217 .subvendor = 0x0001,
218 .subdevice = 0x2002,
219 .card = DM1105_BOARD_DVBWORLD_2002,
220 }, {
221 .subvendor = 0x0000,
222 .subdevice = 0x2004,
223 .card = DM1105_BOARD_DVBWORLD_2004,
224 }, {
225 .subvendor = 0x0001,
226 .subdevice = 0x2004,
227 .card = DM1105_BOARD_DVBWORLD_2004,
228 }, {
229 .subvendor = 0x195d,
230 .subdevice = 0x1105,
231 .card = DM1105_BOARD_AXESS_DM05,
232 },
233};
234
235static void dm1105_card_list(struct pci_dev *pci)
236{
237 int i;
238
239 if (0 == pci->subsystem_vendor &&
240 0 == pci->subsystem_device) {
241 printk(KERN_ERR
242 "dm1105: Your board has no valid PCI Subsystem ID\n"
243 "dm1105: and thus can't be autodetected\n"
244 "dm1105: Please pass card=<n> insmod option to\n"
245 "dm1105: workaround that. Redirect complaints to\n"
246 "dm1105: the vendor of the TV card. Best regards,\n"
247 "dm1105: -- tux\n");
248 } else {
249 printk(KERN_ERR
250 "dm1105: Your board isn't known (yet) to the driver.\n"
251 "dm1105: You can try to pick one of the existing\n"
252 "dm1105: card configs via card=<n> insmod option.\n"
253 "dm1105: Updating to the latest version might help\n"
254 "dm1105: as well.\n");
255 }
256 printk(KERN_ERR "Here is a list of valid choices for the card=<n> "
257 "insmod option:\n");
258 for (i = 0; i < ARRAY_SIZE(dm1105_boards); i++)
259 printk(KERN_ERR "dm1105: card=%d -> %s\n",
260 i, dm1105_boards[i].name);
261}
262
170/* infrared remote control */ 263/* infrared remote control */
171struct infrared { 264struct infrared {
172 struct input_dev *input_dev; 265 struct input_dev *input_dev;
@@ -193,6 +286,8 @@ struct dm1105dvb {
193 struct dvb_frontend *fe; 286 struct dvb_frontend *fe;
194 struct dvb_net dvbnet; 287 struct dvb_net dvbnet;
195 unsigned int full_ts_users; 288 unsigned int full_ts_users;
289 unsigned int boardnr;
290 int nr;
196 291
197 /* i2c */ 292 /* i2c */
198 struct i2c_adapter i2c_adap; 293 struct i2c_adapter i2c_adap;
@@ -211,7 +306,6 @@ struct dm1105dvb {
211 unsigned int PacketErrorCount; 306 unsigned int PacketErrorCount;
212 unsigned int dmarst; 307 unsigned int dmarst;
213 spinlock_t lock; 308 spinlock_t lock;
214
215}; 309};
216 310
217#define dm_io_mem(reg) ((unsigned long)(&dm1105dvb->io_mem[reg])) 311#define dm_io_mem(reg) ((unsigned long)(&dm1105dvb->io_mem[reg]))
@@ -326,16 +420,20 @@ static inline struct dm1105dvb *frontend_to_dm1105dvb(struct dvb_frontend *fe)
326static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 420static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
327{ 421{
328 struct dm1105dvb *dm1105dvb = frontend_to_dm1105dvb(fe); 422 struct dm1105dvb *dm1105dvb = frontend_to_dm1105dvb(fe);
329 u32 lnb_mask, lnb_13v, lnb_18v; 423 u32 lnb_mask, lnb_13v, lnb_18v, lnb_off;
330 424
331 switch (dm1105dvb->pdev->subsystem_device) { 425 switch (dm1105dvb->boardnr) {
332 case PCI_DEVICE_ID_DM05: 426 case DM1105_BOARD_AXESS_DM05:
333 lnb_mask = DM05_LNB_MASK; 427 lnb_mask = DM05_LNB_MASK;
428 lnb_off = DM05_LNB_OFF;
334 lnb_13v = DM05_LNB_13V; 429 lnb_13v = DM05_LNB_13V;
335 lnb_18v = DM05_LNB_18V; 430 lnb_18v = DM05_LNB_18V;
336 break; 431 break;
432 case DM1105_BOARD_DVBWORLD_2002:
433 case DM1105_BOARD_DVBWORLD_2004:
337 default: 434 default:
338 lnb_mask = DM1105_LNB_MASK; 435 lnb_mask = DM1105_LNB_MASK;
436 lnb_off = DM1105_LNB_OFF;
339 lnb_13v = DM1105_LNB_13V; 437 lnb_13v = DM1105_LNB_13V;
340 lnb_18v = DM1105_LNB_18V; 438 lnb_18v = DM1105_LNB_18V;
341 } 439 }
@@ -343,8 +441,10 @@ static int dm1105dvb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t volta
343 outl(lnb_mask, dm_io_mem(DM1105_GPIOCTR)); 441 outl(lnb_mask, dm_io_mem(DM1105_GPIOCTR));
344 if (voltage == SEC_VOLTAGE_18) 442 if (voltage == SEC_VOLTAGE_18)
345 outl(lnb_18v , dm_io_mem(DM1105_GPIOVAL)); 443 outl(lnb_18v , dm_io_mem(DM1105_GPIOVAL));
346 else 444 else if (voltage == SEC_VOLTAGE_13)
347 outl(lnb_13v, dm_io_mem(DM1105_GPIOVAL)); 445 outl(lnb_13v, dm_io_mem(DM1105_GPIOVAL));
446 else
447 outl(lnb_off, dm_io_mem(DM1105_GPIOVAL));
348 448
349 return 0; 449 return 0;
350} 450}
@@ -477,7 +577,7 @@ static irqreturn_t dm1105dvb_irq(int irq, void *dev_id)
477int __devinit dm1105_ir_init(struct dm1105dvb *dm1105) 577int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
478{ 578{
479 struct input_dev *input_dev; 579 struct input_dev *input_dev;
480 IR_KEYTAB_TYPE *ir_codes = ir_codes_dm1105_nec; 580 struct ir_scancode_table *ir_codes = &ir_codes_dm1105_nec_table;
481 int ir_type = IR_TYPE_OTHER; 581 int ir_type = IR_TYPE_OTHER;
482 int err = -ENOMEM; 582 int err = -ENOMEM;
483 583
@@ -589,8 +689,8 @@ static int __devinit frontend_init(struct dm1105dvb *dm1105dvb)
589{ 689{
590 int ret; 690 int ret;
591 691
592 switch (dm1105dvb->pdev->subsystem_device) { 692 switch (dm1105dvb->boardnr) {
593 case PCI_DEVICE_ID_DW2004: 693 case DM1105_BOARD_DVBWORLD_2004:
594 dm1105dvb->fe = dvb_attach( 694 dm1105dvb->fe = dvb_attach(
595 cx24116_attach, &serit_sp2633_config, 695 cx24116_attach, &serit_sp2633_config,
596 &dm1105dvb->i2c_adap); 696 &dm1105dvb->i2c_adap);
@@ -598,6 +698,8 @@ static int __devinit frontend_init(struct dm1105dvb *dm1105dvb)
598 dm1105dvb->fe->ops.set_voltage = dm1105dvb_set_voltage; 698 dm1105dvb->fe->ops.set_voltage = dm1105dvb_set_voltage;
599 699
600 break; 700 break;
701 case DM1105_BOARD_DVBWORLD_2002:
702 case DM1105_BOARD_AXESS_DM05:
601 default: 703 default:
602 dm1105dvb->fe = dvb_attach( 704 dm1105dvb->fe = dvb_attach(
603 stv0299_attach, &sharp_z0194a_config, 705 stv0299_attach, &sharp_z0194a_config,
@@ -676,11 +778,31 @@ static int __devinit dm1105_probe(struct pci_dev *pdev,
676 struct dvb_demux *dvbdemux; 778 struct dvb_demux *dvbdemux;
677 struct dmx_demux *dmx; 779 struct dmx_demux *dmx;
678 int ret = -ENOMEM; 780 int ret = -ENOMEM;
781 int i;
679 782
680 dm1105dvb = kzalloc(sizeof(struct dm1105dvb), GFP_KERNEL); 783 dm1105dvb = kzalloc(sizeof(struct dm1105dvb), GFP_KERNEL);
681 if (!dm1105dvb) 784 if (!dm1105dvb)
682 return -ENOMEM; 785 return -ENOMEM;
683 786
787 /* board config */
788 dm1105dvb->nr = dm1105_devcount;
789 dm1105dvb->boardnr = UNSET;
790 if (card[dm1105dvb->nr] < ARRAY_SIZE(dm1105_boards))
791 dm1105dvb->boardnr = card[dm1105dvb->nr];
792 for (i = 0; UNSET == dm1105dvb->boardnr &&
793 i < ARRAY_SIZE(dm1105_subids); i++)
794 if (pdev->subsystem_vendor ==
795 dm1105_subids[i].subvendor &&
796 pdev->subsystem_device ==
797 dm1105_subids[i].subdevice)
798 dm1105dvb->boardnr = dm1105_subids[i].card;
799
800 if (UNSET == dm1105dvb->boardnr) {
801 dm1105dvb->boardnr = DM1105_BOARD_UNKNOWN;
802 dm1105_card_list(pdev);
803 }
804
805 dm1105_devcount++;
684 dm1105dvb->pdev = pdev; 806 dm1105dvb->pdev = pdev;
685 dm1105dvb->buffer_size = 5 * DM1105_DMA_BYTES; 807 dm1105dvb->buffer_size = 5 * DM1105_DMA_BYTES;
686 dm1105dvb->PacketErrorCount = 0; 808 dm1105dvb->PacketErrorCount = 0;
@@ -853,6 +975,7 @@ static void __devexit dm1105_remove(struct pci_dev *pdev)
853 pci_release_regions(pdev); 975 pci_release_regions(pdev);
854 pci_disable_device(pdev); 976 pci_disable_device(pdev);
855 pci_set_drvdata(pdev, NULL); 977 pci_set_drvdata(pdev, NULL);
978 dm1105_devcount--;
856 kfree(dm1105dvb); 979 kfree(dm1105dvb);
857} 980}
858 981
@@ -861,17 +984,12 @@ static struct pci_device_id dm1105_id_table[] __devinitdata = {
861 .vendor = PCI_VENDOR_ID_TRIGEM, 984 .vendor = PCI_VENDOR_ID_TRIGEM,
862 .device = PCI_DEVICE_ID_DM1105, 985 .device = PCI_DEVICE_ID_DM1105,
863 .subvendor = PCI_ANY_ID, 986 .subvendor = PCI_ANY_ID,
864 .subdevice = PCI_DEVICE_ID_DW2002, 987 .subdevice = PCI_ANY_ID,
865 }, {
866 .vendor = PCI_VENDOR_ID_TRIGEM,
867 .device = PCI_DEVICE_ID_DM1105,
868 .subvendor = PCI_ANY_ID,
869 .subdevice = PCI_DEVICE_ID_DW2004,
870 }, { 988 }, {
871 .vendor = PCI_VENDOR_ID_AXESS, 989 .vendor = PCI_VENDOR_ID_AXESS,
872 .device = PCI_DEVICE_ID_DM05, 990 .device = PCI_DEVICE_ID_DM05,
873 .subvendor = PCI_VENDOR_ID_AXESS, 991 .subvendor = PCI_ANY_ID,
874 .subdevice = PCI_DEVICE_ID_DM05, 992 .subdevice = PCI_ANY_ID,
875 }, { 993 }, {
876 /* empty */ 994 /* empty */
877 }, 995 },
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 6d6121eb5d59..3750ff48cba1 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -430,6 +430,8 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
430/* stop feed but only mark the specified filter as stopped (state set) */ 430/* stop feed but only mark the specified filter as stopped (state set) */
431static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter) 431static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
432{ 432{
433 struct dmxdev_feed *feed;
434
433 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET); 435 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
434 436
435 switch (dmxdevfilter->type) { 437 switch (dmxdevfilter->type) {
@@ -438,7 +440,8 @@ static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
438 dmxdevfilter->feed.sec->stop_filtering(dmxdevfilter->feed.sec); 440 dmxdevfilter->feed.sec->stop_filtering(dmxdevfilter->feed.sec);
439 break; 441 break;
440 case DMXDEV_TYPE_PES: 442 case DMXDEV_TYPE_PES:
441 dmxdevfilter->feed.ts->stop_filtering(dmxdevfilter->feed.ts); 443 list_for_each_entry(feed, &dmxdevfilter->feed.ts, next)
444 feed->ts->stop_filtering(feed->ts);
442 break; 445 break;
443 default: 446 default:
444 return -EINVAL; 447 return -EINVAL;
@@ -449,13 +452,23 @@ static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
449/* start feed associated with the specified filter */ 452/* start feed associated with the specified filter */
450static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter) 453static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
451{ 454{
455 struct dmxdev_feed *feed;
456 int ret;
457
452 dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO); 458 dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO);
453 459
454 switch (filter->type) { 460 switch (filter->type) {
455 case DMXDEV_TYPE_SEC: 461 case DMXDEV_TYPE_SEC:
456 return filter->feed.sec->start_filtering(filter->feed.sec); 462 return filter->feed.sec->start_filtering(filter->feed.sec);
457 case DMXDEV_TYPE_PES: 463 case DMXDEV_TYPE_PES:
458 return filter->feed.ts->start_filtering(filter->feed.ts); 464 list_for_each_entry(feed, &filter->feed.ts, next) {
465 ret = feed->ts->start_filtering(feed->ts);
466 if (ret < 0) {
467 dvb_dmxdev_feed_stop(filter);
468 return ret;
469 }
470 }
471 break;
459 default: 472 default:
460 return -EINVAL; 473 return -EINVAL;
461 } 474 }
@@ -487,6 +500,9 @@ static int dvb_dmxdev_feed_restart(struct dmxdev_filter *filter)
487 500
488static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter) 501static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
489{ 502{
503 struct dmxdev_feed *feed;
504 struct dmx_demux *demux;
505
490 if (dmxdevfilter->state < DMXDEV_STATE_GO) 506 if (dmxdevfilter->state < DMXDEV_STATE_GO)
491 return 0; 507 return 0;
492 508
@@ -503,13 +519,12 @@ static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
503 dmxdevfilter->feed.sec = NULL; 519 dmxdevfilter->feed.sec = NULL;
504 break; 520 break;
505 case DMXDEV_TYPE_PES: 521 case DMXDEV_TYPE_PES:
506 if (!dmxdevfilter->feed.ts)
507 break;
508 dvb_dmxdev_feed_stop(dmxdevfilter); 522 dvb_dmxdev_feed_stop(dmxdevfilter);
509 dmxdevfilter->dev->demux-> 523 demux = dmxdevfilter->dev->demux;
510 release_ts_feed(dmxdevfilter->dev->demux, 524 list_for_each_entry(feed, &dmxdevfilter->feed.ts, next) {
511 dmxdevfilter->feed.ts); 525 demux->release_ts_feed(demux, feed->ts);
512 dmxdevfilter->feed.ts = NULL; 526 feed->ts = NULL;
527 }
513 break; 528 break;
514 default: 529 default:
515 if (dmxdevfilter->state == DMXDEV_STATE_ALLOCATED) 530 if (dmxdevfilter->state == DMXDEV_STATE_ALLOCATED)
@@ -521,19 +536,88 @@ static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
521 return 0; 536 return 0;
522} 537}
523 538
539static void dvb_dmxdev_delete_pids(struct dmxdev_filter *dmxdevfilter)
540{
541 struct dmxdev_feed *feed, *tmp;
542
543 /* delete all PIDs */
544 list_for_each_entry_safe(feed, tmp, &dmxdevfilter->feed.ts, next) {
545 list_del(&feed->next);
546 kfree(feed);
547 }
548
549 BUG_ON(!list_empty(&dmxdevfilter->feed.ts));
550}
551
524static inline int dvb_dmxdev_filter_reset(struct dmxdev_filter *dmxdevfilter) 552static inline int dvb_dmxdev_filter_reset(struct dmxdev_filter *dmxdevfilter)
525{ 553{
526 if (dmxdevfilter->state < DMXDEV_STATE_SET) 554 if (dmxdevfilter->state < DMXDEV_STATE_SET)
527 return 0; 555 return 0;
528 556
557 if (dmxdevfilter->type == DMXDEV_TYPE_PES)
558 dvb_dmxdev_delete_pids(dmxdevfilter);
559
529 dmxdevfilter->type = DMXDEV_TYPE_NONE; 560 dmxdevfilter->type = DMXDEV_TYPE_NONE;
530 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED); 561 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
531 return 0; 562 return 0;
532} 563}
533 564
565static int dvb_dmxdev_start_feed(struct dmxdev *dmxdev,
566 struct dmxdev_filter *filter,
567 struct dmxdev_feed *feed)
568{
569 struct timespec timeout = { 0 };
570 struct dmx_pes_filter_params *para = &filter->params.pes;
571 dmx_output_t otype;
572 int ret;
573 int ts_type;
574 enum dmx_ts_pes ts_pes;
575 struct dmx_ts_feed *tsfeed;
576
577 feed->ts = NULL;
578 otype = para->output;
579
580 ts_pes = (enum dmx_ts_pes)para->pes_type;
581
582 if (ts_pes < DMX_PES_OTHER)
583 ts_type = TS_DECODER;
584 else
585 ts_type = 0;
586
587 if (otype == DMX_OUT_TS_TAP)
588 ts_type |= TS_PACKET;
589 else if (otype == DMX_OUT_TSDEMUX_TAP)
590 ts_type |= TS_PACKET | TS_DEMUX;
591 else if (otype == DMX_OUT_TAP)
592 ts_type |= TS_PACKET | TS_DEMUX | TS_PAYLOAD_ONLY;
593
594 ret = dmxdev->demux->allocate_ts_feed(dmxdev->demux, &feed->ts,
595 dvb_dmxdev_ts_callback);
596 if (ret < 0)
597 return ret;
598
599 tsfeed = feed->ts;
600 tsfeed->priv = filter;
601
602 ret = tsfeed->set(tsfeed, feed->pid, ts_type, ts_pes, 32768, timeout);
603 if (ret < 0) {
604 dmxdev->demux->release_ts_feed(dmxdev->demux, tsfeed);
605 return ret;
606 }
607
608 ret = tsfeed->start_filtering(tsfeed);
609 if (ret < 0) {
610 dmxdev->demux->release_ts_feed(dmxdev->demux, tsfeed);
611 return ret;
612 }
613
614 return 0;
615}
616
534static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) 617static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
535{ 618{
536 struct dmxdev *dmxdev = filter->dev; 619 struct dmxdev *dmxdev = filter->dev;
620 struct dmxdev_feed *feed;
537 void *mem; 621 void *mem;
538 int ret, i; 622 int ret, i;
539 623
@@ -631,56 +715,14 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
631 break; 715 break;
632 } 716 }
633 case DMXDEV_TYPE_PES: 717 case DMXDEV_TYPE_PES:
634 { 718 list_for_each_entry(feed, &filter->feed.ts, next) {
635 struct timespec timeout = { 0 }; 719 ret = dvb_dmxdev_start_feed(dmxdev, filter, feed);
636 struct dmx_pes_filter_params *para = &filter->params.pes; 720 if (ret < 0) {
637 dmx_output_t otype; 721 dvb_dmxdev_filter_stop(filter);
638 int ts_type; 722 return ret;
639 enum dmx_ts_pes ts_pes; 723 }
640 struct dmx_ts_feed **tsfeed = &filter->feed.ts;
641
642 filter->feed.ts = NULL;
643 otype = para->output;
644
645 ts_pes = (enum dmx_ts_pes)para->pes_type;
646
647 if (ts_pes < DMX_PES_OTHER)
648 ts_type = TS_DECODER;
649 else
650 ts_type = 0;
651
652 if (otype == DMX_OUT_TS_TAP)
653 ts_type |= TS_PACKET;
654 else if (otype == DMX_OUT_TSDEMUX_TAP)
655 ts_type |= TS_PACKET | TS_DEMUX;
656 else if (otype == DMX_OUT_TAP)
657 ts_type |= TS_PACKET | TS_DEMUX | TS_PAYLOAD_ONLY;
658
659 ret = dmxdev->demux->allocate_ts_feed(dmxdev->demux,
660 tsfeed,
661 dvb_dmxdev_ts_callback);
662 if (ret < 0)
663 return ret;
664
665 (*tsfeed)->priv = filter;
666
667 ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes,
668 32768, timeout);
669 if (ret < 0) {
670 dmxdev->demux->release_ts_feed(dmxdev->demux,
671 *tsfeed);
672 return ret;
673 }
674
675 ret = filter->feed.ts->start_filtering(filter->feed.ts);
676 if (ret < 0) {
677 dmxdev->demux->release_ts_feed(dmxdev->demux,
678 *tsfeed);
679 return ret;
680 } 724 }
681
682 break; 725 break;
683 }
684 default: 726 default:
685 return -EINVAL; 727 return -EINVAL;
686 } 728 }
@@ -718,7 +760,7 @@ static int dvb_demux_open(struct inode *inode, struct file *file)
718 dvb_ringbuffer_init(&dmxdevfilter->buffer, NULL, 8192); 760 dvb_ringbuffer_init(&dmxdevfilter->buffer, NULL, 8192);
719 dmxdevfilter->type = DMXDEV_TYPE_NONE; 761 dmxdevfilter->type = DMXDEV_TYPE_NONE;
720 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED); 762 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
721 dmxdevfilter->feed.ts = NULL; 763 INIT_LIST_HEAD(&dmxdevfilter->feed.ts);
722 init_timer(&dmxdevfilter->timer); 764 init_timer(&dmxdevfilter->timer);
723 765
724 dvbdev->users++; 766 dvbdev->users++;
@@ -760,6 +802,55 @@ static inline void invert_mode(dmx_filter_t *filter)
760 filter->mode[i] ^= 0xff; 802 filter->mode[i] ^= 0xff;
761} 803}
762 804
805static int dvb_dmxdev_add_pid(struct dmxdev *dmxdev,
806 struct dmxdev_filter *filter, u16 pid)
807{
808 struct dmxdev_feed *feed;
809
810 if ((filter->type != DMXDEV_TYPE_PES) ||
811 (filter->state < DMXDEV_STATE_SET))
812 return -EINVAL;
813
814 /* only TS packet filters may have multiple PIDs */
815 if ((filter->params.pes.output != DMX_OUT_TSDEMUX_TAP) &&
816 (!list_empty(&filter->feed.ts)))
817 return -EINVAL;
818
819 feed = kzalloc(sizeof(struct dmxdev_feed), GFP_KERNEL);
820 if (feed == NULL)
821 return -ENOMEM;
822
823 feed->pid = pid;
824 list_add(&feed->next, &filter->feed.ts);
825
826 if (filter->state >= DMXDEV_STATE_GO)
827 return dvb_dmxdev_start_feed(dmxdev, filter, feed);
828
829 return 0;
830}
831
832static int dvb_dmxdev_remove_pid(struct dmxdev *dmxdev,
833 struct dmxdev_filter *filter, u16 pid)
834{
835 struct dmxdev_feed *feed, *tmp;
836
837 if ((filter->type != DMXDEV_TYPE_PES) ||
838 (filter->state < DMXDEV_STATE_SET))
839 return -EINVAL;
840
841 list_for_each_entry_safe(feed, tmp, &filter->feed.ts, next) {
842 if ((feed->pid == pid) && (feed->ts != NULL)) {
843 feed->ts->stop_filtering(feed->ts);
844 filter->dev->demux->release_ts_feed(filter->dev->demux,
845 feed->ts);
846 list_del(&feed->next);
847 kfree(feed);
848 }
849 }
850
851 return 0;
852}
853
763static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev, 854static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
764 struct dmxdev_filter *dmxdevfilter, 855 struct dmxdev_filter *dmxdevfilter,
765 struct dmx_sct_filter_params *params) 856 struct dmx_sct_filter_params *params)
@@ -784,7 +875,10 @@ static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
784 struct dmxdev_filter *dmxdevfilter, 875 struct dmxdev_filter *dmxdevfilter,
785 struct dmx_pes_filter_params *params) 876 struct dmx_pes_filter_params *params)
786{ 877{
878 int ret;
879
787 dvb_dmxdev_filter_stop(dmxdevfilter); 880 dvb_dmxdev_filter_stop(dmxdevfilter);
881 dvb_dmxdev_filter_reset(dmxdevfilter);
788 882
789 if (params->pes_type > DMX_PES_OTHER || params->pes_type < 0) 883 if (params->pes_type > DMX_PES_OTHER || params->pes_type < 0)
790 return -EINVAL; 884 return -EINVAL;
@@ -795,6 +889,11 @@ static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
795 889
796 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET); 890 dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
797 891
892 ret = dvb_dmxdev_add_pid(dmxdev, dmxdevfilter,
893 dmxdevfilter->params.pes.pid);
894 if (ret < 0)
895 return ret;
896
798 if (params->flags & DMX_IMMEDIATE_START) 897 if (params->flags & DMX_IMMEDIATE_START)
799 return dvb_dmxdev_filter_start(dmxdevfilter); 898 return dvb_dmxdev_filter_start(dmxdevfilter);
800 899
@@ -958,6 +1057,24 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
958 &((struct dmx_stc *)parg)->base); 1057 &((struct dmx_stc *)parg)->base);
959 break; 1058 break;
960 1059
1060 case DMX_ADD_PID:
1061 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
1062 ret = -ERESTARTSYS;
1063 break;
1064 }
1065 ret = dvb_dmxdev_add_pid(dmxdev, dmxdevfilter, *(u16 *)parg);
1066 mutex_unlock(&dmxdevfilter->mutex);
1067 break;
1068
1069 case DMX_REMOVE_PID:
1070 if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
1071 ret = -ERESTARTSYS;
1072 break;
1073 }
1074 ret = dvb_dmxdev_remove_pid(dmxdev, dmxdevfilter, *(u16 *)parg);
1075 mutex_unlock(&dmxdevfilter->mutex);
1076 break;
1077
961 default: 1078 default:
962 ret = -EINVAL; 1079 ret = -EINVAL;
963 break; 1080 break;
diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h
index 29746e70d325..c1379b56dfb4 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.h
+++ b/drivers/media/dvb/dvb-core/dmxdev.h
@@ -53,13 +53,20 @@ enum dmxdev_state {
53 DMXDEV_STATE_TIMEDOUT 53 DMXDEV_STATE_TIMEDOUT
54}; 54};
55 55
56struct dmxdev_feed {
57 u16 pid;
58 struct dmx_ts_feed *ts;
59 struct list_head next;
60};
61
56struct dmxdev_filter { 62struct dmxdev_filter {
57 union { 63 union {
58 struct dmx_section_filter *sec; 64 struct dmx_section_filter *sec;
59 } filter; 65 } filter;
60 66
61 union { 67 union {
62 struct dmx_ts_feed *ts; 68 /* list of TS and PES feeds (struct dmxdev_feed) */
69 struct list_head ts;
63 struct dmx_section_feed *sec; 70 struct dmx_section_feed *sec;
64 } feed; 71 } feed;
65 72
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index cfe2768d24af..eef6d3616626 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -425,13 +425,9 @@ no_dvb_demux_tscheck:
425 if ((DVR_FEED(feed)) && (dvr_done++)) 425 if ((DVR_FEED(feed)) && (dvr_done++))
426 continue; 426 continue;
427 427
428 if (feed->pid == pid) { 428 if (feed->pid == pid)
429 dvb_dmx_swfilter_packet_type(feed, buf); 429 dvb_dmx_swfilter_packet_type(feed, buf);
430 if (DVR_FEED(feed)) 430 else if (feed->pid == 0x2000)
431 continue;
432 }
433
434 if (feed->pid == 0x2000)
435 feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK); 431 feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK);
436 } 432 }
437} 433}
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index f50ca7292a7d..d13ebcb0c6b6 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -72,6 +72,7 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open(
72#define FESTATE_ZIGZAG_FAST 32 72#define FESTATE_ZIGZAG_FAST 32
73#define FESTATE_ZIGZAG_SLOW 64 73#define FESTATE_ZIGZAG_SLOW 64
74#define FESTATE_DISEQC 128 74#define FESTATE_DISEQC 128
75#define FESTATE_ERROR 256
75#define FESTATE_WAITFORLOCK (FESTATE_TUNING_FAST | FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_FAST | FESTATE_ZIGZAG_SLOW | FESTATE_DISEQC) 76#define FESTATE_WAITFORLOCK (FESTATE_TUNING_FAST | FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_FAST | FESTATE_ZIGZAG_SLOW | FESTATE_DISEQC)
76#define FESTATE_SEARCHING_FAST (FESTATE_TUNING_FAST | FESTATE_ZIGZAG_FAST) 77#define FESTATE_SEARCHING_FAST (FESTATE_TUNING_FAST | FESTATE_ZIGZAG_FAST)
77#define FESTATE_SEARCHING_SLOW (FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_SLOW) 78#define FESTATE_SEARCHING_SLOW (FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_SLOW)
@@ -269,6 +270,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
269{ 270{
270 int autoinversion; 271 int autoinversion;
271 int ready = 0; 272 int ready = 0;
273 int fe_set_err = 0;
272 struct dvb_frontend_private *fepriv = fe->frontend_priv; 274 struct dvb_frontend_private *fepriv = fe->frontend_priv;
273 int original_inversion = fepriv->parameters.inversion; 275 int original_inversion = fepriv->parameters.inversion;
274 u32 original_frequency = fepriv->parameters.frequency; 276 u32 original_frequency = fepriv->parameters.frequency;
@@ -345,7 +347,11 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
345 if (autoinversion) 347 if (autoinversion)
346 fepriv->parameters.inversion = fepriv->inversion; 348 fepriv->parameters.inversion = fepriv->inversion;
347 if (fe->ops.set_frontend) 349 if (fe->ops.set_frontend)
348 fe->ops.set_frontend(fe, &fepriv->parameters); 350 fe_set_err = fe->ops.set_frontend(fe, &fepriv->parameters);
351 if (fe_set_err < 0) {
352 fepriv->state = FESTATE_ERROR;
353 return fe_set_err;
354 }
349 355
350 fepriv->parameters.frequency = original_frequency; 356 fepriv->parameters.frequency = original_frequency;
351 fepriv->parameters.inversion = original_inversion; 357 fepriv->parameters.inversion = original_inversion;
@@ -357,6 +363,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
357static void dvb_frontend_swzigzag(struct dvb_frontend *fe) 363static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
358{ 364{
359 fe_status_t s = 0; 365 fe_status_t s = 0;
366 int retval = 0;
360 struct dvb_frontend_private *fepriv = fe->frontend_priv; 367 struct dvb_frontend_private *fepriv = fe->frontend_priv;
361 368
362 /* if we've got no parameters, just keep idling */ 369 /* if we've got no parameters, just keep idling */
@@ -370,8 +377,12 @@ static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
370 if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) { 377 if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) {
371 if (fepriv->state & FESTATE_RETUNE) { 378 if (fepriv->state & FESTATE_RETUNE) {
372 if (fe->ops.set_frontend) 379 if (fe->ops.set_frontend)
373 fe->ops.set_frontend(fe, &fepriv->parameters); 380 retval = fe->ops.set_frontend(fe,
374 fepriv->state = FESTATE_TUNED; 381 &fepriv->parameters);
382 if (retval < 0)
383 fepriv->state = FESTATE_ERROR;
384 else
385 fepriv->state = FESTATE_TUNED;
375 } 386 }
376 fepriv->delay = 3*HZ; 387 fepriv->delay = 3*HZ;
377 fepriv->quality = 0; 388 fepriv->quality = 0;
@@ -449,7 +460,11 @@ static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
449 fepriv->delay = fepriv->min_delay; 460 fepriv->delay = fepriv->min_delay;
450 461
451 /* peform a tune */ 462 /* peform a tune */
452 if (dvb_frontend_swzigzag_autotune(fe, fepriv->check_wrapped)) { 463 retval = dvb_frontend_swzigzag_autotune(fe,
464 fepriv->check_wrapped);
465 if (retval < 0) {
466 return;
467 } else if (retval) {
453 /* OK, if we've run out of trials at the fast speed. 468 /* OK, if we've run out of trials at the fast speed.
454 * Drop back to slow for the _next_ attempt */ 469 * Drop back to slow for the _next_ attempt */
455 fepriv->state = FESTATE_SEARCHING_SLOW; 470 fepriv->state = FESTATE_SEARCHING_SLOW;
@@ -823,6 +838,15 @@ static int dvb_frontend_check_parameters(struct dvb_frontend *fe,
823 } 838 }
824 } 839 }
825 840
841 /* check for supported modulation */
842 if (fe->ops.info.type == FE_QAM &&
843 (parms->u.qam.modulation > QAM_AUTO ||
844 !((1 << (parms->u.qam.modulation + 10)) & fe->ops.info.caps))) {
845 printk(KERN_WARNING "DVB: adapter %i frontend %i modulation %u not supported\n",
846 fe->dvb->num, fe->id, parms->u.qam.modulation);
847 return -EINVAL;
848 }
849
826 return 0; 850 return 0;
827} 851}
828 852
@@ -1499,7 +1523,8 @@ static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
1499 1523
1500 /* if retune was requested but hasn't occured yet, prevent 1524 /* if retune was requested but hasn't occured yet, prevent
1501 * that user get signal state from previous tuning */ 1525 * that user get signal state from previous tuning */
1502 if(fepriv->state == FESTATE_RETUNE) { 1526 if (fepriv->state == FESTATE_RETUNE ||
1527 fepriv->state == FESTATE_ERROR) {
1503 err=0; 1528 err=0;
1504 *status = 0; 1529 *status = 0;
1505 break; 1530 break;
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index 487919bea7ae..895e2efca8a9 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -30,7 +30,12 @@
30 30
31#define DVB_MAJOR 212 31#define DVB_MAJOR 212
32 32
33#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
34#define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
35#else
36#warning invalid CONFIG_DVB_MAX_ADAPTERS value
33#define DVB_MAX_ADAPTERS 8 37#define DVB_MAX_ADAPTERS 8
38#endif
34 39
35#define DVB_UNSET (-1) 40#define DVB_UNSET (-1)
36 41
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 496c1a37034c..8b8bc04ee980 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -253,7 +253,7 @@ config DVB_USB_AF9005_REMOTE
253 Afatech AF9005 based receiver. 253 Afatech AF9005 based receiver.
254 254
255config DVB_USB_DW2102 255config DVB_USB_DW2102
256 tristate "DvbWorld DVB-S/S2 USB2.0 support" 256 tristate "DvbWorld & TeVii DVB-S/S2 USB2.0 support"
257 depends on DVB_USB 257 depends on DVB_USB
258 select DVB_PLL if !DVB_FE_CUSTOMISE 258 select DVB_PLL if !DVB_FE_CUSTOMISE
259 select DVB_STV0299 if !DVB_FE_CUSTOMISE 259 select DVB_STV0299 if !DVB_FE_CUSTOMISE
@@ -262,9 +262,11 @@ config DVB_USB_DW2102
262 select DVB_CX24116 if !DVB_FE_CUSTOMISE 262 select DVB_CX24116 if !DVB_FE_CUSTOMISE
263 select DVB_SI21XX if !DVB_FE_CUSTOMISE 263 select DVB_SI21XX if !DVB_FE_CUSTOMISE
264 select DVB_TDA10021 if !DVB_FE_CUSTOMISE 264 select DVB_TDA10021 if !DVB_FE_CUSTOMISE
265 select DVB_MT312 if !DVB_FE_CUSTOMISE
266 select DVB_ZL10039 if !DVB_FE_CUSTOMISE
265 help 267 help
266 Say Y here to support the DvbWorld DVB-S/S2 USB2.0 receivers 268 Say Y here to support the DvbWorld DVB-S/S2 USB2.0 receivers
267 and the TeVii S650. 269 and the TeVii S650, S630.
268 270
269config DVB_USB_CINERGY_T2 271config DVB_USB_CINERGY_T2
270 tristate "Terratec CinergyT2/qanu USB 2.0 DVB-T receiver" 272 tristate "Terratec CinergyT2/qanu USB 2.0 DVB-T receiver"
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index dc8c8784caa8..6247239982e9 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -38,41 +38,41 @@ static int a800_identify_state(struct usb_device *udev, struct dvb_usb_device_pr
38} 38}
39 39
40static struct dvb_usb_rc_key a800_rc_keys[] = { 40static struct dvb_usb_rc_key a800_rc_keys[] = {
41 { 0x02, 0x01, KEY_PROG1 }, /* SOURCE */ 41 { 0x0201, KEY_PROG1 }, /* SOURCE */
42 { 0x02, 0x00, KEY_POWER }, /* POWER */ 42 { 0x0200, KEY_POWER }, /* POWER */
43 { 0x02, 0x05, KEY_1 }, /* 1 */ 43 { 0x0205, KEY_1 }, /* 1 */
44 { 0x02, 0x06, KEY_2 }, /* 2 */ 44 { 0x0206, KEY_2 }, /* 2 */
45 { 0x02, 0x07, KEY_3 }, /* 3 */ 45 { 0x0207, KEY_3 }, /* 3 */
46 { 0x02, 0x09, KEY_4 }, /* 4 */ 46 { 0x0209, KEY_4 }, /* 4 */
47 { 0x02, 0x0a, KEY_5 }, /* 5 */ 47 { 0x020a, KEY_5 }, /* 5 */
48 { 0x02, 0x0b, KEY_6 }, /* 6 */ 48 { 0x020b, KEY_6 }, /* 6 */
49 { 0x02, 0x0d, KEY_7 }, /* 7 */ 49 { 0x020d, KEY_7 }, /* 7 */
50 { 0x02, 0x0e, KEY_8 }, /* 8 */ 50 { 0x020e, KEY_8 }, /* 8 */
51 { 0x02, 0x0f, KEY_9 }, /* 9 */ 51 { 0x020f, KEY_9 }, /* 9 */
52 { 0x02, 0x12, KEY_LEFT }, /* L / DISPLAY */ 52 { 0x0212, KEY_LEFT }, /* L / DISPLAY */
53 { 0x02, 0x11, KEY_0 }, /* 0 */ 53 { 0x0211, KEY_0 }, /* 0 */
54 { 0x02, 0x13, KEY_RIGHT }, /* R / CH RTN */ 54 { 0x0213, KEY_RIGHT }, /* R / CH RTN */
55 { 0x02, 0x17, KEY_PROG2 }, /* SNAP SHOT */ 55 { 0x0217, KEY_PROG2 }, /* SNAP SHOT */
56 { 0x02, 0x10, KEY_PROG3 }, /* 16-CH PREV */ 56 { 0x0210, KEY_PROG3 }, /* 16-CH PREV */
57 { 0x02, 0x1e, KEY_VOLUMEDOWN }, /* VOL DOWN */ 57 { 0x021e, KEY_VOLUMEDOWN }, /* VOL DOWN */
58 { 0x02, 0x0c, KEY_ZOOM }, /* FULL SCREEN */ 58 { 0x020c, KEY_ZOOM }, /* FULL SCREEN */
59 { 0x02, 0x1f, KEY_VOLUMEUP }, /* VOL UP */ 59 { 0x021f, KEY_VOLUMEUP }, /* VOL UP */
60 { 0x02, 0x14, KEY_MUTE }, /* MUTE */ 60 { 0x0214, KEY_MUTE }, /* MUTE */
61 { 0x02, 0x08, KEY_AUDIO }, /* AUDIO */ 61 { 0x0208, KEY_AUDIO }, /* AUDIO */
62 { 0x02, 0x19, KEY_RECORD }, /* RECORD */ 62 { 0x0219, KEY_RECORD }, /* RECORD */
63 { 0x02, 0x18, KEY_PLAY }, /* PLAY */ 63 { 0x0218, KEY_PLAY }, /* PLAY */
64 { 0x02, 0x1b, KEY_STOP }, /* STOP */ 64 { 0x021b, KEY_STOP }, /* STOP */
65 { 0x02, 0x1a, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */ 65 { 0x021a, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */
66 { 0x02, 0x1d, KEY_BACK }, /* << / RED */ 66 { 0x021d, KEY_BACK }, /* << / RED */
67 { 0x02, 0x1c, KEY_FORWARD }, /* >> / YELLOW */ 67 { 0x021c, KEY_FORWARD }, /* >> / YELLOW */
68 { 0x02, 0x03, KEY_TEXT }, /* TELETEXT */ 68 { 0x0203, KEY_TEXT }, /* TELETEXT */
69 { 0x02, 0x04, KEY_EPG }, /* EPG */ 69 { 0x0204, KEY_EPG }, /* EPG */
70 { 0x02, 0x15, KEY_MENU }, /* MENU */ 70 { 0x0215, KEY_MENU }, /* MENU */
71 71
72 { 0x03, 0x03, KEY_CHANNELUP }, /* CH UP */ 72 { 0x0303, KEY_CHANNELUP }, /* CH UP */
73 { 0x03, 0x02, KEY_CHANNELDOWN }, /* CH DOWN */ 73 { 0x0302, KEY_CHANNELDOWN }, /* CH DOWN */
74 { 0x03, 0x01, KEY_FIRST }, /* |<< / GREEN */ 74 { 0x0301, KEY_FIRST }, /* |<< / GREEN */
75 { 0x03, 0x00, KEY_LAST }, /* >>| / BLUE */ 75 { 0x0300, KEY_LAST }, /* >>| / BLUE */
76 76
77}; 77};
78 78
diff --git a/drivers/media/dvb/dvb-usb/af9005-remote.c b/drivers/media/dvb/dvb-usb/af9005-remote.c
index 7c596f926764..f4379c650a19 100644
--- a/drivers/media/dvb/dvb-usb/af9005-remote.c
+++ b/drivers/media/dvb/dvb-usb/af9005-remote.c
@@ -35,43 +35,43 @@ MODULE_PARM_DESC(debug,
35 35
36struct dvb_usb_rc_key af9005_rc_keys[] = { 36struct dvb_usb_rc_key af9005_rc_keys[] = {
37 37
38 {0x01, 0xb7, KEY_POWER}, 38 {0x01b7, KEY_POWER},
39 {0x01, 0xa7, KEY_VOLUMEUP}, 39 {0x01a7, KEY_VOLUMEUP},
40 {0x01, 0x87, KEY_CHANNELUP}, 40 {0x0187, KEY_CHANNELUP},
41 {0x01, 0x7f, KEY_MUTE}, 41 {0x017f, KEY_MUTE},
42 {0x01, 0xbf, KEY_VOLUMEDOWN}, 42 {0x01bf, KEY_VOLUMEDOWN},
43 {0x01, 0x3f, KEY_CHANNELDOWN}, 43 {0x013f, KEY_CHANNELDOWN},
44 {0x01, 0xdf, KEY_1}, 44 {0x01df, KEY_1},
45 {0x01, 0x5f, KEY_2}, 45 {0x015f, KEY_2},
46 {0x01, 0x9f, KEY_3}, 46 {0x019f, KEY_3},
47 {0x01, 0x1f, KEY_4}, 47 {0x011f, KEY_4},
48 {0x01, 0xef, KEY_5}, 48 {0x01ef, KEY_5},
49 {0x01, 0x6f, KEY_6}, 49 {0x016f, KEY_6},
50 {0x01, 0xaf, KEY_7}, 50 {0x01af, KEY_7},
51 {0x01, 0x27, KEY_8}, 51 {0x0127, KEY_8},
52 {0x01, 0x07, KEY_9}, 52 {0x0107, KEY_9},
53 {0x01, 0xcf, KEY_ZOOM}, 53 {0x01cf, KEY_ZOOM},
54 {0x01, 0x4f, KEY_0}, 54 {0x014f, KEY_0},
55 {0x01, 0x8f, KEY_GOTO}, /* marked jump on the remote */ 55 {0x018f, KEY_GOTO}, /* marked jump on the remote */
56 56
57 {0x00, 0xbd, KEY_POWER}, 57 {0x00bd, KEY_POWER},
58 {0x00, 0x7d, KEY_VOLUMEUP}, 58 {0x007d, KEY_VOLUMEUP},
59 {0x00, 0xfd, KEY_CHANNELUP}, 59 {0x00fd, KEY_CHANNELUP},
60 {0x00, 0x9d, KEY_MUTE}, 60 {0x009d, KEY_MUTE},
61 {0x00, 0x5d, KEY_VOLUMEDOWN}, 61 {0x005d, KEY_VOLUMEDOWN},
62 {0x00, 0xdd, KEY_CHANNELDOWN}, 62 {0x00dd, KEY_CHANNELDOWN},
63 {0x00, 0xad, KEY_1}, 63 {0x00ad, KEY_1},
64 {0x00, 0x6d, KEY_2}, 64 {0x006d, KEY_2},
65 {0x00, 0xed, KEY_3}, 65 {0x00ed, KEY_3},
66 {0x00, 0x8d, KEY_4}, 66 {0x008d, KEY_4},
67 {0x00, 0x4d, KEY_5}, 67 {0x004d, KEY_5},
68 {0x00, 0xcd, KEY_6}, 68 {0x00cd, KEY_6},
69 {0x00, 0xb5, KEY_7}, 69 {0x00b5, KEY_7},
70 {0x00, 0x75, KEY_8}, 70 {0x0075, KEY_8},
71 {0x00, 0xf5, KEY_9}, 71 {0x00f5, KEY_9},
72 {0x00, 0x95, KEY_ZOOM}, 72 {0x0095, KEY_ZOOM},
73 {0x00, 0x55, KEY_0}, 73 {0x0055, KEY_0},
74 {0x00, 0xd5, KEY_GOTO}, /* marked jump on the remote */ 74 {0x00d5, KEY_GOTO}, /* marked jump on the remote */
75}; 75};
76 76
77int af9005_rc_keys_size = ARRAY_SIZE(af9005_rc_keys); 77int af9005_rc_keys_size = ARRAY_SIZE(af9005_rc_keys);
@@ -131,8 +131,8 @@ int af9005_rc_decode(struct dvb_usb_device *d, u8 * data, int len, u32 * event,
131 return 0; 131 return 0;
132 } 132 }
133 for (i = 0; i < af9005_rc_keys_size; i++) { 133 for (i = 0; i < af9005_rc_keys_size; i++) {
134 if (af9005_rc_keys[i].custom == cust 134 if (rc5_custom(&af9005_rc_keys[i]) == cust
135 && af9005_rc_keys[i].data == dat) { 135 && rc5_data(&af9005_rc_keys[i]) == dat) {
136 *event = af9005_rc_keys[i].event; 136 *event = af9005_rc_keys[i].event;
137 *state = REMOTE_KEY_PRESSED; 137 *state = REMOTE_KEY_PRESSED;
138 deb_decode 138 deb_decode
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 26690dfb3260..99cdd0d101ca 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -538,24 +538,22 @@ exit:
538/* dump eeprom */ 538/* dump eeprom */
539static int af9015_eeprom_dump(struct dvb_usb_device *d) 539static int af9015_eeprom_dump(struct dvb_usb_device *d)
540{ 540{
541 char buf[4+3*16+1], buf2[4];
542 u8 reg, val; 541 u8 reg, val;
543 542
544 for (reg = 0; ; reg++) { 543 for (reg = 0; ; reg++) {
545 if (reg % 16 == 0) { 544 if (reg % 16 == 0) {
546 if (reg) 545 if (reg)
547 deb_info("%s\n", buf); 546 deb_info(KERN_CONT "\n");
548 sprintf(buf, "%02x: ", reg); 547 deb_info(KERN_DEBUG "%02x:", reg);
549 } 548 }
550 if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg, &val) == 0) 549 if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg, &val) == 0)
551 sprintf(buf2, "%02x ", val); 550 deb_info(KERN_CONT " %02x", val);
552 else 551 else
553 strcpy(buf2, "-- "); 552 deb_info(KERN_CONT " --");
554 strcat(buf, buf2);
555 if (reg == 0xff) 553 if (reg == 0xff)
556 break; 554 break;
557 } 555 }
558 deb_info("%s\n", buf); 556 deb_info(KERN_CONT "\n");
559 return 0; 557 return 0;
560} 558}
561 559
@@ -1045,8 +1043,8 @@ static int af9015_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1045 *state = REMOTE_NO_KEY_PRESSED; 1043 *state = REMOTE_NO_KEY_PRESSED;
1046 1044
1047 for (i = 0; i < d->props.rc_key_map_size; i++) { 1045 for (i = 0; i < d->props.rc_key_map_size; i++) {
1048 if (!buf[1] && keymap[i].custom == buf[0] && 1046 if (!buf[1] && rc5_custom(&keymap[i]) == buf[0] &&
1049 keymap[i].data == buf[2]) { 1047 rc5_data(&keymap[i]) == buf[2]) {
1050 *event = keymap[i].event; 1048 *event = keymap[i].event;
1051 *state = REMOTE_KEY_PRESSED; 1049 *state = REMOTE_KEY_PRESSED;
1052 break; 1050 break;
@@ -1266,6 +1264,7 @@ static struct usb_device_id af9015_usb_table[] = {
1266 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)}, 1264 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CONCEPTRONIC_CTVDIGRCU)},
1267 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)}, 1265 {USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_MC810)},
1268 {USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03)}, 1266 {USB_DEVICE(USB_VID_KYE, USB_PID_GENIUS_TVGO_DVB_T03)},
1267/* 25 */{USB_DEVICE(USB_VID_KWORLD_2, USB_PID_KWORLD_399U_2)},
1269 {0}, 1268 {0},
1270}; 1269};
1271MODULE_DEVICE_TABLE(usb, af9015_usb_table); 1270MODULE_DEVICE_TABLE(usb, af9015_usb_table);
@@ -1346,7 +1345,8 @@ static struct dvb_usb_device_properties af9015_properties[] = {
1346 { 1345 {
1347 .name = "KWorld PlusTV Dual DVB-T Stick " \ 1346 .name = "KWorld PlusTV Dual DVB-T Stick " \
1348 "(DVB-T 399U)", 1347 "(DVB-T 399U)",
1349 .cold_ids = {&af9015_usb_table[4], NULL}, 1348 .cold_ids = {&af9015_usb_table[4],
1349 &af9015_usb_table[25], NULL},
1350 .warm_ids = {NULL}, 1350 .warm_ids = {NULL},
1351 }, 1351 },
1352 { 1352 {
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h
index 8d81a17c116d..c41f30e4a1b8 100644
--- a/drivers/media/dvb/dvb-usb/af9015.h
+++ b/drivers/media/dvb/dvb-usb/af9015.h
@@ -121,21 +121,21 @@ enum af9015_remote {
121 121
122/* Leadtek WinFast DTV Dongle Gold */ 122/* Leadtek WinFast DTV Dongle Gold */
123static struct dvb_usb_rc_key af9015_rc_keys_leadtek[] = { 123static struct dvb_usb_rc_key af9015_rc_keys_leadtek[] = {
124 { 0x00, 0x1e, KEY_1 }, 124 { 0x001e, KEY_1 },
125 { 0x00, 0x1f, KEY_2 }, 125 { 0x001f, KEY_2 },
126 { 0x00, 0x20, KEY_3 }, 126 { 0x0020, KEY_3 },
127 { 0x00, 0x21, KEY_4 }, 127 { 0x0021, KEY_4 },
128 { 0x00, 0x22, KEY_5 }, 128 { 0x0022, KEY_5 },
129 { 0x00, 0x23, KEY_6 }, 129 { 0x0023, KEY_6 },
130 { 0x00, 0x24, KEY_7 }, 130 { 0x0024, KEY_7 },
131 { 0x00, 0x25, KEY_8 }, 131 { 0x0025, KEY_8 },
132 { 0x00, 0x26, KEY_9 }, 132 { 0x0026, KEY_9 },
133 { 0x00, 0x27, KEY_0 }, 133 { 0x0027, KEY_0 },
134 { 0x00, 0x28, KEY_ENTER }, 134 { 0x0028, KEY_ENTER },
135 { 0x00, 0x4f, KEY_VOLUMEUP }, 135 { 0x004f, KEY_VOLUMEUP },
136 { 0x00, 0x50, KEY_VOLUMEDOWN }, 136 { 0x0050, KEY_VOLUMEDOWN },
137 { 0x00, 0x51, KEY_CHANNELDOWN }, 137 { 0x0051, KEY_CHANNELDOWN },
138 { 0x00, 0x52, KEY_CHANNELUP }, 138 { 0x0052, KEY_CHANNELUP },
139}; 139};
140 140
141static u8 af9015_ir_table_leadtek[] = { 141static u8 af9015_ir_table_leadtek[] = {
@@ -193,60 +193,60 @@ static u8 af9015_ir_table_leadtek[] = {
193 193
194/* TwinHan AzureWave AD-TU700(704J) */ 194/* TwinHan AzureWave AD-TU700(704J) */
195static struct dvb_usb_rc_key af9015_rc_keys_twinhan[] = { 195static struct dvb_usb_rc_key af9015_rc_keys_twinhan[] = {
196 { 0x05, 0x3f, KEY_POWER }, 196 { 0x053f, KEY_POWER },
197 { 0x00, 0x19, KEY_FAVORITES }, /* Favorite List */ 197 { 0x0019, KEY_FAVORITES }, /* Favorite List */
198 { 0x00, 0x04, KEY_TEXT }, /* Teletext */ 198 { 0x0004, KEY_TEXT }, /* Teletext */
199 { 0x00, 0x0e, KEY_POWER }, 199 { 0x000e, KEY_POWER },
200 { 0x00, 0x0e, KEY_INFO }, /* Preview */ 200 { 0x000e, KEY_INFO }, /* Preview */
201 { 0x00, 0x08, KEY_EPG }, /* Info/EPG */ 201 { 0x0008, KEY_EPG }, /* Info/EPG */
202 { 0x00, 0x0f, KEY_LIST }, /* Record List */ 202 { 0x000f, KEY_LIST }, /* Record List */
203 { 0x00, 0x1e, KEY_1 }, 203 { 0x001e, KEY_1 },
204 { 0x00, 0x1f, KEY_2 }, 204 { 0x001f, KEY_2 },
205 { 0x00, 0x20, KEY_3 }, 205 { 0x0020, KEY_3 },
206 { 0x00, 0x21, KEY_4 }, 206 { 0x0021, KEY_4 },
207 { 0x00, 0x22, KEY_5 }, 207 { 0x0022, KEY_5 },
208 { 0x00, 0x23, KEY_6 }, 208 { 0x0023, KEY_6 },
209 { 0x00, 0x24, KEY_7 }, 209 { 0x0024, KEY_7 },
210 { 0x00, 0x25, KEY_8 }, 210 { 0x0025, KEY_8 },
211 { 0x00, 0x26, KEY_9 }, 211 { 0x0026, KEY_9 },
212 { 0x00, 0x27, KEY_0 }, 212 { 0x0027, KEY_0 },
213 { 0x00, 0x29, KEY_CANCEL }, /* Cancel */ 213 { 0x0029, KEY_CANCEL }, /* Cancel */
214 { 0x00, 0x4c, KEY_CLEAR }, /* Clear */ 214 { 0x004c, KEY_CLEAR }, /* Clear */
215 { 0x00, 0x2a, KEY_BACK }, /* Back */ 215 { 0x002a, KEY_BACK }, /* Back */
216 { 0x00, 0x2b, KEY_TAB }, /* Tab */ 216 { 0x002b, KEY_TAB }, /* Tab */
217 { 0x00, 0x52, KEY_UP }, /* up arrow */ 217 { 0x0052, KEY_UP }, /* up arrow */
218 { 0x00, 0x51, KEY_DOWN }, /* down arrow */ 218 { 0x0051, KEY_DOWN }, /* down arrow */
219 { 0x00, 0x4f, KEY_RIGHT }, /* right arrow */ 219 { 0x004f, KEY_RIGHT }, /* right arrow */
220 { 0x00, 0x50, KEY_LEFT }, /* left arrow */ 220 { 0x0050, KEY_LEFT }, /* left arrow */
221 { 0x00, 0x28, KEY_ENTER }, /* Enter / ok */ 221 { 0x0028, KEY_ENTER }, /* Enter / ok */
222 { 0x02, 0x52, KEY_VOLUMEUP }, 222 { 0x0252, KEY_VOLUMEUP },
223 { 0x02, 0x51, KEY_VOLUMEDOWN }, 223 { 0x0251, KEY_VOLUMEDOWN },
224 { 0x00, 0x4e, KEY_CHANNELDOWN }, 224 { 0x004e, KEY_CHANNELDOWN },
225 { 0x00, 0x4b, KEY_CHANNELUP }, 225 { 0x004b, KEY_CHANNELUP },
226 { 0x00, 0x4a, KEY_RECORD }, 226 { 0x004a, KEY_RECORD },
227 { 0x01, 0x11, KEY_PLAY }, 227 { 0x0111, KEY_PLAY },
228 { 0x00, 0x17, KEY_PAUSE }, 228 { 0x0017, KEY_PAUSE },
229 { 0x00, 0x0c, KEY_REWIND }, /* FR << */ 229 { 0x000c, KEY_REWIND }, /* FR << */
230 { 0x00, 0x11, KEY_FASTFORWARD }, /* FF >> */ 230 { 0x0011, KEY_FASTFORWARD }, /* FF >> */
231 { 0x01, 0x15, KEY_PREVIOUS }, /* Replay */ 231 { 0x0115, KEY_PREVIOUS }, /* Replay */
232 { 0x01, 0x0e, KEY_NEXT }, /* Skip */ 232 { 0x010e, KEY_NEXT }, /* Skip */
233 { 0x00, 0x13, KEY_CAMERA }, /* Capture */ 233 { 0x0013, KEY_CAMERA }, /* Capture */
234 { 0x01, 0x0f, KEY_LANGUAGE }, /* SAP */ 234 { 0x010f, KEY_LANGUAGE }, /* SAP */
235 { 0x01, 0x13, KEY_TV2 }, /* PIP */ 235 { 0x0113, KEY_TV2 }, /* PIP */
236 { 0x00, 0x1d, KEY_ZOOM }, /* Full Screen */ 236 { 0x001d, KEY_ZOOM }, /* Full Screen */
237 { 0x01, 0x17, KEY_SUBTITLE }, /* Subtitle / CC */ 237 { 0x0117, KEY_SUBTITLE }, /* Subtitle / CC */
238 { 0x00, 0x10, KEY_MUTE }, 238 { 0x0010, KEY_MUTE },
239 { 0x01, 0x19, KEY_AUDIO }, /* L/R */ /* TODO better event */ 239 { 0x0119, KEY_AUDIO }, /* L/R */ /* TODO better event */
240 { 0x01, 0x16, KEY_SLEEP }, /* Hibernate */ 240 { 0x0116, KEY_SLEEP }, /* Hibernate */
241 { 0x01, 0x16, KEY_SWITCHVIDEOMODE }, 241 { 0x0116, KEY_SWITCHVIDEOMODE },
242 /* A/V */ /* TODO does not work */ 242 /* A/V */ /* TODO does not work */
243 { 0x00, 0x06, KEY_AGAIN }, /* Recall */ 243 { 0x0006, KEY_AGAIN }, /* Recall */
244 { 0x01, 0x16, KEY_KPPLUS }, /* Zoom+ */ /* TODO does not work */ 244 { 0x0116, KEY_KPPLUS }, /* Zoom+ */ /* TODO does not work */
245 { 0x01, 0x16, KEY_KPMINUS }, /* Zoom- */ /* TODO does not work */ 245 { 0x0116, KEY_KPMINUS }, /* Zoom- */ /* TODO does not work */
246 { 0x02, 0x15, KEY_RED }, 246 { 0x0215, KEY_RED },
247 { 0x02, 0x0a, KEY_GREEN }, 247 { 0x020a, KEY_GREEN },
248 { 0x02, 0x1c, KEY_YELLOW }, 248 { 0x021c, KEY_YELLOW },
249 { 0x02, 0x05, KEY_BLUE }, 249 { 0x0205, KEY_BLUE },
250}; 250};
251 251
252static u8 af9015_ir_table_twinhan[] = { 252static u8 af9015_ir_table_twinhan[] = {
@@ -304,24 +304,24 @@ static u8 af9015_ir_table_twinhan[] = {
304 304
305/* A-Link DTU(m) */ 305/* A-Link DTU(m) */
306static struct dvb_usb_rc_key af9015_rc_keys_a_link[] = { 306static struct dvb_usb_rc_key af9015_rc_keys_a_link[] = {
307 { 0x00, 0x1e, KEY_1 }, 307 { 0x001e, KEY_1 },
308 { 0x00, 0x1f, KEY_2 }, 308 { 0x001f, KEY_2 },
309 { 0x00, 0x20, KEY_3 }, 309 { 0x0020, KEY_3 },
310 { 0x00, 0x21, KEY_4 }, 310 { 0x0021, KEY_4 },
311 { 0x00, 0x22, KEY_5 }, 311 { 0x0022, KEY_5 },
312 { 0x00, 0x23, KEY_6 }, 312 { 0x0023, KEY_6 },
313 { 0x00, 0x24, KEY_7 }, 313 { 0x0024, KEY_7 },
314 { 0x00, 0x25, KEY_8 }, 314 { 0x0025, KEY_8 },
315 { 0x00, 0x26, KEY_9 }, 315 { 0x0026, KEY_9 },
316 { 0x00, 0x27, KEY_0 }, 316 { 0x0027, KEY_0 },
317 { 0x00, 0x2e, KEY_CHANNELUP }, 317 { 0x002e, KEY_CHANNELUP },
318 { 0x00, 0x2d, KEY_CHANNELDOWN }, 318 { 0x002d, KEY_CHANNELDOWN },
319 { 0x04, 0x28, KEY_ZOOM }, 319 { 0x0428, KEY_ZOOM },
320 { 0x00, 0x41, KEY_MUTE }, 320 { 0x0041, KEY_MUTE },
321 { 0x00, 0x42, KEY_VOLUMEDOWN }, 321 { 0x0042, KEY_VOLUMEDOWN },
322 { 0x00, 0x43, KEY_VOLUMEUP }, 322 { 0x0043, KEY_VOLUMEUP },
323 { 0x00, 0x44, KEY_GOTO }, /* jump */ 323 { 0x0044, KEY_GOTO }, /* jump */
324 { 0x05, 0x45, KEY_POWER }, 324 { 0x0545, KEY_POWER },
325}; 325};
326 326
327static u8 af9015_ir_table_a_link[] = { 327static u8 af9015_ir_table_a_link[] = {
@@ -347,24 +347,24 @@ static u8 af9015_ir_table_a_link[] = {
347 347
348/* MSI DIGIVOX mini II V3.0 */ 348/* MSI DIGIVOX mini II V3.0 */
349static struct dvb_usb_rc_key af9015_rc_keys_msi[] = { 349static struct dvb_usb_rc_key af9015_rc_keys_msi[] = {
350 { 0x00, 0x1e, KEY_1 }, 350 { 0x001e, KEY_1 },
351 { 0x00, 0x1f, KEY_2 }, 351 { 0x001f, KEY_2 },
352 { 0x00, 0x20, KEY_3 }, 352 { 0x0020, KEY_3 },
353 { 0x00, 0x21, KEY_4 }, 353 { 0x0021, KEY_4 },
354 { 0x00, 0x22, KEY_5 }, 354 { 0x0022, KEY_5 },
355 { 0x00, 0x23, KEY_6 }, 355 { 0x0023, KEY_6 },
356 { 0x00, 0x24, KEY_7 }, 356 { 0x0024, KEY_7 },
357 { 0x00, 0x25, KEY_8 }, 357 { 0x0025, KEY_8 },
358 { 0x00, 0x26, KEY_9 }, 358 { 0x0026, KEY_9 },
359 { 0x00, 0x27, KEY_0 }, 359 { 0x0027, KEY_0 },
360 { 0x03, 0x0f, KEY_CHANNELUP }, 360 { 0x030f, KEY_CHANNELUP },
361 { 0x03, 0x0e, KEY_CHANNELDOWN }, 361 { 0x030e, KEY_CHANNELDOWN },
362 { 0x00, 0x42, KEY_VOLUMEDOWN }, 362 { 0x0042, KEY_VOLUMEDOWN },
363 { 0x00, 0x43, KEY_VOLUMEUP }, 363 { 0x0043, KEY_VOLUMEUP },
364 { 0x05, 0x45, KEY_POWER }, 364 { 0x0545, KEY_POWER },
365 { 0x00, 0x52, KEY_UP }, /* up */ 365 { 0x0052, KEY_UP }, /* up */
366 { 0x00, 0x51, KEY_DOWN }, /* down */ 366 { 0x0051, KEY_DOWN }, /* down */
367 { 0x00, 0x28, KEY_ENTER }, 367 { 0x0028, KEY_ENTER },
368}; 368};
369 369
370static u8 af9015_ir_table_msi[] = { 370static u8 af9015_ir_table_msi[] = {
@@ -390,42 +390,42 @@ static u8 af9015_ir_table_msi[] = {
390 390
391/* MYGICTV U718 */ 391/* MYGICTV U718 */
392static struct dvb_usb_rc_key af9015_rc_keys_mygictv[] = { 392static struct dvb_usb_rc_key af9015_rc_keys_mygictv[] = {
393 { 0x00, 0x3d, KEY_SWITCHVIDEOMODE }, 393 { 0x003d, KEY_SWITCHVIDEOMODE },
394 /* TV / AV */ 394 /* TV / AV */
395 { 0x05, 0x45, KEY_POWER }, 395 { 0x0545, KEY_POWER },
396 { 0x00, 0x1e, KEY_1 }, 396 { 0x001e, KEY_1 },
397 { 0x00, 0x1f, KEY_2 }, 397 { 0x001f, KEY_2 },
398 { 0x00, 0x20, KEY_3 }, 398 { 0x0020, KEY_3 },
399 { 0x00, 0x21, KEY_4 }, 399 { 0x0021, KEY_4 },
400 { 0x00, 0x22, KEY_5 }, 400 { 0x0022, KEY_5 },
401 { 0x00, 0x23, KEY_6 }, 401 { 0x0023, KEY_6 },
402 { 0x00, 0x24, KEY_7 }, 402 { 0x0024, KEY_7 },
403 { 0x00, 0x25, KEY_8 }, 403 { 0x0025, KEY_8 },
404 { 0x00, 0x26, KEY_9 }, 404 { 0x0026, KEY_9 },
405 { 0x00, 0x27, KEY_0 }, 405 { 0x0027, KEY_0 },
406 { 0x00, 0x41, KEY_MUTE }, 406 { 0x0041, KEY_MUTE },
407 { 0x00, 0x2a, KEY_ESC }, /* Esc */ 407 { 0x002a, KEY_ESC }, /* Esc */
408 { 0x00, 0x2e, KEY_CHANNELUP }, 408 { 0x002e, KEY_CHANNELUP },
409 { 0x00, 0x2d, KEY_CHANNELDOWN }, 409 { 0x002d, KEY_CHANNELDOWN },
410 { 0x00, 0x42, KEY_VOLUMEDOWN }, 410 { 0x0042, KEY_VOLUMEDOWN },
411 { 0x00, 0x43, KEY_VOLUMEUP }, 411 { 0x0043, KEY_VOLUMEUP },
412 { 0x00, 0x52, KEY_UP }, /* up arrow */ 412 { 0x0052, KEY_UP }, /* up arrow */
413 { 0x00, 0x51, KEY_DOWN }, /* down arrow */ 413 { 0x0051, KEY_DOWN }, /* down arrow */
414 { 0x00, 0x4f, KEY_RIGHT }, /* right arrow */ 414 { 0x004f, KEY_RIGHT }, /* right arrow */
415 { 0x00, 0x50, KEY_LEFT }, /* left arrow */ 415 { 0x0050, KEY_LEFT }, /* left arrow */
416 { 0x00, 0x28, KEY_ENTER }, /* ok */ 416 { 0x0028, KEY_ENTER }, /* ok */
417 { 0x01, 0x15, KEY_RECORD }, 417 { 0x0115, KEY_RECORD },
418 { 0x03, 0x13, KEY_PLAY }, 418 { 0x0313, KEY_PLAY },
419 { 0x01, 0x13, KEY_PAUSE }, 419 { 0x0113, KEY_PAUSE },
420 { 0x01, 0x16, KEY_STOP }, 420 { 0x0116, KEY_STOP },
421 { 0x03, 0x07, KEY_REWIND }, /* FR << */ 421 { 0x0307, KEY_REWIND }, /* FR << */
422 { 0x03, 0x09, KEY_FASTFORWARD }, /* FF >> */ 422 { 0x0309, KEY_FASTFORWARD }, /* FF >> */
423 { 0x00, 0x3b, KEY_TIME }, /* TimeShift */ 423 { 0x003b, KEY_TIME }, /* TimeShift */
424 { 0x00, 0x3e, KEY_CAMERA }, /* Snapshot */ 424 { 0x003e, KEY_CAMERA }, /* Snapshot */
425 { 0x03, 0x16, KEY_CYCLEWINDOWS }, /* yellow, min / max */ 425 { 0x0316, KEY_CYCLEWINDOWS }, /* yellow, min / max */
426 { 0x00, 0x00, KEY_ZOOM }, /* 'select' (?) */ 426 { 0x0000, KEY_ZOOM }, /* 'select' (?) */
427 { 0x03, 0x16, KEY_SHUFFLE }, /* Shuffle */ 427 { 0x0316, KEY_SHUFFLE }, /* Shuffle */
428 { 0x03, 0x45, KEY_POWER }, 428 { 0x0345, KEY_POWER },
429}; 429};
430 430
431static u8 af9015_ir_table_mygictv[] = { 431static u8 af9015_ir_table_mygictv[] = {
@@ -516,41 +516,41 @@ static u8 af9015_ir_table_kworld[] = {
516 516
517/* AverMedia Volar X */ 517/* AverMedia Volar X */
518static struct dvb_usb_rc_key af9015_rc_keys_avermedia[] = { 518static struct dvb_usb_rc_key af9015_rc_keys_avermedia[] = {
519 { 0x05, 0x3d, KEY_PROG1 }, /* SOURCE */ 519 { 0x053d, KEY_PROG1 }, /* SOURCE */
520 { 0x05, 0x12, KEY_POWER }, /* POWER */ 520 { 0x0512, KEY_POWER }, /* POWER */
521 { 0x05, 0x1e, KEY_1 }, /* 1 */ 521 { 0x051e, KEY_1 }, /* 1 */
522 { 0x05, 0x1f, KEY_2 }, /* 2 */ 522 { 0x051f, KEY_2 }, /* 2 */
523 { 0x05, 0x20, KEY_3 }, /* 3 */ 523 { 0x0520, KEY_3 }, /* 3 */
524 { 0x05, 0x21, KEY_4 }, /* 4 */ 524 { 0x0521, KEY_4 }, /* 4 */
525 { 0x05, 0x22, KEY_5 }, /* 5 */ 525 { 0x0522, KEY_5 }, /* 5 */
526 { 0x05, 0x23, KEY_6 }, /* 6 */ 526 { 0x0523, KEY_6 }, /* 6 */
527 { 0x05, 0x24, KEY_7 }, /* 7 */ 527 { 0x0524, KEY_7 }, /* 7 */
528 { 0x05, 0x25, KEY_8 }, /* 8 */ 528 { 0x0525, KEY_8 }, /* 8 */
529 { 0x05, 0x26, KEY_9 }, /* 9 */ 529 { 0x0526, KEY_9 }, /* 9 */
530 { 0x05, 0x3f, KEY_LEFT }, /* L / DISPLAY */ 530 { 0x053f, KEY_LEFT }, /* L / DISPLAY */
531 { 0x05, 0x27, KEY_0 }, /* 0 */ 531 { 0x0527, KEY_0 }, /* 0 */
532 { 0x05, 0x0f, KEY_RIGHT }, /* R / CH RTN */ 532 { 0x050f, KEY_RIGHT }, /* R / CH RTN */
533 { 0x05, 0x18, KEY_PROG2 }, /* SNAP SHOT */ 533 { 0x0518, KEY_PROG2 }, /* SNAP SHOT */
534 { 0x05, 0x1c, KEY_PROG3 }, /* 16-CH PREV */ 534 { 0x051c, KEY_PROG3 }, /* 16-CH PREV */
535 { 0x05, 0x2d, KEY_VOLUMEDOWN }, /* VOL DOWN */ 535 { 0x052d, KEY_VOLUMEDOWN }, /* VOL DOWN */
536 { 0x05, 0x3e, KEY_ZOOM }, /* FULL SCREEN */ 536 { 0x053e, KEY_ZOOM }, /* FULL SCREEN */
537 { 0x05, 0x2e, KEY_VOLUMEUP }, /* VOL UP */ 537 { 0x052e, KEY_VOLUMEUP }, /* VOL UP */
538 { 0x05, 0x10, KEY_MUTE }, /* MUTE */ 538 { 0x0510, KEY_MUTE }, /* MUTE */
539 { 0x05, 0x04, KEY_AUDIO }, /* AUDIO */ 539 { 0x0504, KEY_AUDIO }, /* AUDIO */
540 { 0x05, 0x15, KEY_RECORD }, /* RECORD */ 540 { 0x0515, KEY_RECORD }, /* RECORD */
541 { 0x05, 0x11, KEY_PLAY }, /* PLAY */ 541 { 0x0511, KEY_PLAY }, /* PLAY */
542 { 0x05, 0x16, KEY_STOP }, /* STOP */ 542 { 0x0516, KEY_STOP }, /* STOP */
543 { 0x05, 0x0c, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */ 543 { 0x050c, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */
544 { 0x05, 0x05, KEY_BACK }, /* << / RED */ 544 { 0x0505, KEY_BACK }, /* << / RED */
545 { 0x05, 0x09, KEY_FORWARD }, /* >> / YELLOW */ 545 { 0x0509, KEY_FORWARD }, /* >> / YELLOW */
546 { 0x05, 0x17, KEY_TEXT }, /* TELETEXT */ 546 { 0x0517, KEY_TEXT }, /* TELETEXT */
547 { 0x05, 0x0a, KEY_EPG }, /* EPG */ 547 { 0x050a, KEY_EPG }, /* EPG */
548 { 0x05, 0x13, KEY_MENU }, /* MENU */ 548 { 0x0513, KEY_MENU }, /* MENU */
549 549
550 { 0x05, 0x0e, KEY_CHANNELUP }, /* CH UP */ 550 { 0x050e, KEY_CHANNELUP }, /* CH UP */
551 { 0x05, 0x0d, KEY_CHANNELDOWN }, /* CH DOWN */ 551 { 0x050d, KEY_CHANNELDOWN }, /* CH DOWN */
552 { 0x05, 0x19, KEY_FIRST }, /* |<< / GREEN */ 552 { 0x0519, KEY_FIRST }, /* |<< / GREEN */
553 { 0x05, 0x08, KEY_LAST }, /* >>| / BLUE */ 553 { 0x0508, KEY_LAST }, /* >>| / BLUE */
554}; 554};
555 555
556static u8 af9015_ir_table_avermedia[] = { 556static u8 af9015_ir_table_avermedia[] = {
@@ -622,34 +622,34 @@ static u8 af9015_ir_table_avermedia_ks[] = {
622 622
623/* Digittrade DVB-T USB Stick */ 623/* Digittrade DVB-T USB Stick */
624static struct dvb_usb_rc_key af9015_rc_keys_digittrade[] = { 624static struct dvb_usb_rc_key af9015_rc_keys_digittrade[] = {
625 { 0x01, 0x0f, KEY_LAST }, /* RETURN */ 625 { 0x010f, KEY_LAST }, /* RETURN */
626 { 0x05, 0x17, KEY_TEXT }, /* TELETEXT */ 626 { 0x0517, KEY_TEXT }, /* TELETEXT */
627 { 0x01, 0x08, KEY_EPG }, /* EPG */ 627 { 0x0108, KEY_EPG }, /* EPG */
628 { 0x05, 0x13, KEY_POWER }, /* POWER */ 628 { 0x0513, KEY_POWER }, /* POWER */
629 { 0x01, 0x09, KEY_ZOOM }, /* FULLSCREEN */ 629 { 0x0109, KEY_ZOOM }, /* FULLSCREEN */
630 { 0x00, 0x40, KEY_AUDIO }, /* DUAL SOUND */ 630 { 0x0040, KEY_AUDIO }, /* DUAL SOUND */
631 { 0x00, 0x2c, KEY_PRINT }, /* SNAPSHOT */ 631 { 0x002c, KEY_PRINT }, /* SNAPSHOT */
632 { 0x05, 0x16, KEY_SUBTITLE }, /* SUBTITLE */ 632 { 0x0516, KEY_SUBTITLE }, /* SUBTITLE */
633 { 0x00, 0x52, KEY_CHANNELUP }, /* CH Up */ 633 { 0x0052, KEY_CHANNELUP }, /* CH Up */
634 { 0x00, 0x51, KEY_CHANNELDOWN },/* Ch Dn */ 634 { 0x0051, KEY_CHANNELDOWN },/* Ch Dn */
635 { 0x00, 0x57, KEY_VOLUMEUP }, /* Vol Up */ 635 { 0x0057, KEY_VOLUMEUP }, /* Vol Up */
636 { 0x00, 0x56, KEY_VOLUMEDOWN }, /* Vol Dn */ 636 { 0x0056, KEY_VOLUMEDOWN }, /* Vol Dn */
637 { 0x01, 0x10, KEY_MUTE }, /* MUTE */ 637 { 0x0110, KEY_MUTE }, /* MUTE */
638 { 0x00, 0x27, KEY_0 }, 638 { 0x0027, KEY_0 },
639 { 0x00, 0x1e, KEY_1 }, 639 { 0x001e, KEY_1 },
640 { 0x00, 0x1f, KEY_2 }, 640 { 0x001f, KEY_2 },
641 { 0x00, 0x20, KEY_3 }, 641 { 0x0020, KEY_3 },
642 { 0x00, 0x21, KEY_4 }, 642 { 0x0021, KEY_4 },
643 { 0x00, 0x22, KEY_5 }, 643 { 0x0022, KEY_5 },
644 { 0x00, 0x23, KEY_6 }, 644 { 0x0023, KEY_6 },
645 { 0x00, 0x24, KEY_7 }, 645 { 0x0024, KEY_7 },
646 { 0x00, 0x25, KEY_8 }, 646 { 0x0025, KEY_8 },
647 { 0x00, 0x26, KEY_9 }, 647 { 0x0026, KEY_9 },
648 { 0x01, 0x17, KEY_PLAYPAUSE }, /* TIMESHIFT */ 648 { 0x0117, KEY_PLAYPAUSE }, /* TIMESHIFT */
649 { 0x01, 0x15, KEY_RECORD }, /* RECORD */ 649 { 0x0115, KEY_RECORD }, /* RECORD */
650 { 0x03, 0x13, KEY_PLAY }, /* PLAY */ 650 { 0x0313, KEY_PLAY }, /* PLAY */
651 { 0x01, 0x16, KEY_STOP }, /* STOP */ 651 { 0x0116, KEY_STOP }, /* STOP */
652 { 0x01, 0x13, KEY_PAUSE }, /* PAUSE */ 652 { 0x0113, KEY_PAUSE }, /* PAUSE */
653}; 653};
654 654
655static u8 af9015_ir_table_digittrade[] = { 655static u8 af9015_ir_table_digittrade[] = {
@@ -685,34 +685,34 @@ static u8 af9015_ir_table_digittrade[] = {
685 685
686/* TREKSTOR DVB-T USB Stick */ 686/* TREKSTOR DVB-T USB Stick */
687static struct dvb_usb_rc_key af9015_rc_keys_trekstor[] = { 687static struct dvb_usb_rc_key af9015_rc_keys_trekstor[] = {
688 { 0x07, 0x04, KEY_AGAIN }, /* Home */ 688 { 0x0704, KEY_AGAIN }, /* Home */
689 { 0x07, 0x05, KEY_MUTE }, /* Mute */ 689 { 0x0705, KEY_MUTE }, /* Mute */
690 { 0x07, 0x06, KEY_UP }, /* Up */ 690 { 0x0706, KEY_UP }, /* Up */
691 { 0x07, 0x07, KEY_DOWN }, /* Down */ 691 { 0x0707, KEY_DOWN }, /* Down */
692 { 0x07, 0x09, KEY_RIGHT }, /* Right */ 692 { 0x0709, KEY_RIGHT }, /* Right */
693 { 0x07, 0x0a, KEY_ENTER }, /* OK */ 693 { 0x070a, KEY_ENTER }, /* OK */
694 { 0x07, 0x0b, KEY_FASTFORWARD }, /* Fast forward */ 694 { 0x070b, KEY_FASTFORWARD }, /* Fast forward */
695 { 0x07, 0x0c, KEY_REWIND }, /* Rewind */ 695 { 0x070c, KEY_REWIND }, /* Rewind */
696 { 0x07, 0x0d, KEY_PLAY }, /* Play/Pause */ 696 { 0x070d, KEY_PLAY }, /* Play/Pause */
697 { 0x07, 0x0e, KEY_VOLUMEUP }, /* Volume + */ 697 { 0x070e, KEY_VOLUMEUP }, /* Volume + */
698 { 0x07, 0x0f, KEY_VOLUMEDOWN }, /* Volume - */ 698 { 0x070f, KEY_VOLUMEDOWN }, /* Volume - */
699 { 0x07, 0x10, KEY_RECORD }, /* Record */ 699 { 0x0710, KEY_RECORD }, /* Record */
700 { 0x07, 0x11, KEY_STOP }, /* Stop */ 700 { 0x0711, KEY_STOP }, /* Stop */
701 { 0x07, 0x12, KEY_ZOOM }, /* TV */ 701 { 0x0712, KEY_ZOOM }, /* TV */
702 { 0x07, 0x13, KEY_EPG }, /* Info/EPG */ 702 { 0x0713, KEY_EPG }, /* Info/EPG */
703 { 0x07, 0x14, KEY_CHANNELDOWN }, /* Channel - */ 703 { 0x0714, KEY_CHANNELDOWN }, /* Channel - */
704 { 0x07, 0x15, KEY_CHANNELUP }, /* Channel + */ 704 { 0x0715, KEY_CHANNELUP }, /* Channel + */
705 { 0x07, 0x1e, KEY_1 }, 705 { 0x071e, KEY_1 },
706 { 0x07, 0x1f, KEY_2 }, 706 { 0x071f, KEY_2 },
707 { 0x07, 0x20, KEY_3 }, 707 { 0x0720, KEY_3 },
708 { 0x07, 0x21, KEY_4 }, 708 { 0x0721, KEY_4 },
709 { 0x07, 0x22, KEY_5 }, 709 { 0x0722, KEY_5 },
710 { 0x07, 0x23, KEY_6 }, 710 { 0x0723, KEY_6 },
711 { 0x07, 0x24, KEY_7 }, 711 { 0x0724, KEY_7 },
712 { 0x07, 0x25, KEY_8 }, 712 { 0x0725, KEY_8 },
713 { 0x07, 0x26, KEY_9 }, 713 { 0x0726, KEY_9 },
714 { 0x07, 0x08, KEY_LEFT }, /* LEFT */ 714 { 0x0708, KEY_LEFT }, /* LEFT */
715 { 0x07, 0x27, KEY_0 }, 715 { 0x0727, KEY_0 },
716}; 716};
717 717
718static u8 af9015_ir_table_trekstor[] = { 718static u8 af9015_ir_table_trekstor[] = {
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index c6e7b4215d6b..7381aff4dcf6 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -389,8 +389,8 @@ static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
389 *state = REMOTE_NO_KEY_PRESSED; 389 *state = REMOTE_NO_KEY_PRESSED;
390 390
391 for (i = 0; i < d->props.rc_key_map_size; i++) { 391 for (i = 0; i < d->props.rc_key_map_size; i++) {
392 if (keymap[i].custom == ircode[0] && 392 if (rc5_custom(&keymap[i]) == ircode[0] &&
393 keymap[i].data == ircode[1]) { 393 rc5_data(&keymap[i]) == ircode[1]) {
394 *event = keymap[i].event; 394 *event = keymap[i].event;
395 *state = REMOTE_KEY_PRESSED; 395 *state = REMOTE_KEY_PRESSED;
396 return 0; 396 return 0;
@@ -400,50 +400,50 @@ static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
400} 400}
401 401
402static struct dvb_usb_rc_key anysee_rc_keys[] = { 402static struct dvb_usb_rc_key anysee_rc_keys[] = {
403 { 0x01, 0x00, KEY_0 }, 403 { 0x0100, KEY_0 },
404 { 0x01, 0x01, KEY_1 }, 404 { 0x0101, KEY_1 },
405 { 0x01, 0x02, KEY_2 }, 405 { 0x0102, KEY_2 },
406 { 0x01, 0x03, KEY_3 }, 406 { 0x0103, KEY_3 },
407 { 0x01, 0x04, KEY_4 }, 407 { 0x0104, KEY_4 },
408 { 0x01, 0x05, KEY_5 }, 408 { 0x0105, KEY_5 },
409 { 0x01, 0x06, KEY_6 }, 409 { 0x0106, KEY_6 },
410 { 0x01, 0x07, KEY_7 }, 410 { 0x0107, KEY_7 },
411 { 0x01, 0x08, KEY_8 }, 411 { 0x0108, KEY_8 },
412 { 0x01, 0x09, KEY_9 }, 412 { 0x0109, KEY_9 },
413 { 0x01, 0x0a, KEY_POWER }, 413 { 0x010a, KEY_POWER },
414 { 0x01, 0x0b, KEY_DOCUMENTS }, /* * */ 414 { 0x010b, KEY_DOCUMENTS }, /* * */
415 { 0x01, 0x19, KEY_FAVORITES }, 415 { 0x0119, KEY_FAVORITES },
416 { 0x01, 0x20, KEY_SLEEP }, 416 { 0x0120, KEY_SLEEP },
417 { 0x01, 0x21, KEY_MODE }, /* 4:3 / 16:9 select */ 417 { 0x0121, KEY_MODE }, /* 4:3 / 16:9 select */
418 { 0x01, 0x22, KEY_ZOOM }, 418 { 0x0122, KEY_ZOOM },
419 { 0x01, 0x47, KEY_TEXT }, 419 { 0x0147, KEY_TEXT },
420 { 0x01, 0x16, KEY_TV }, /* TV / radio select */ 420 { 0x0116, KEY_TV }, /* TV / radio select */
421 { 0x01, 0x1e, KEY_LANGUAGE }, /* Second Audio Program */ 421 { 0x011e, KEY_LANGUAGE }, /* Second Audio Program */
422 { 0x01, 0x1a, KEY_SUBTITLE }, 422 { 0x011a, KEY_SUBTITLE },
423 { 0x01, 0x1b, KEY_CAMERA }, /* screenshot */ 423 { 0x011b, KEY_CAMERA }, /* screenshot */
424 { 0x01, 0x42, KEY_MUTE }, 424 { 0x0142, KEY_MUTE },
425 { 0x01, 0x0e, KEY_MENU }, 425 { 0x010e, KEY_MENU },
426 { 0x01, 0x0f, KEY_EPG }, 426 { 0x010f, KEY_EPG },
427 { 0x01, 0x17, KEY_INFO }, 427 { 0x0117, KEY_INFO },
428 { 0x01, 0x10, KEY_EXIT }, 428 { 0x0110, KEY_EXIT },
429 { 0x01, 0x13, KEY_VOLUMEUP }, 429 { 0x0113, KEY_VOLUMEUP },
430 { 0x01, 0x12, KEY_VOLUMEDOWN }, 430 { 0x0112, KEY_VOLUMEDOWN },
431 { 0x01, 0x11, KEY_CHANNELUP }, 431 { 0x0111, KEY_CHANNELUP },
432 { 0x01, 0x14, KEY_CHANNELDOWN }, 432 { 0x0114, KEY_CHANNELDOWN },
433 { 0x01, 0x15, KEY_OK }, 433 { 0x0115, KEY_OK },
434 { 0x01, 0x1d, KEY_RED }, 434 { 0x011d, KEY_RED },
435 { 0x01, 0x1f, KEY_GREEN }, 435 { 0x011f, KEY_GREEN },
436 { 0x01, 0x1c, KEY_YELLOW }, 436 { 0x011c, KEY_YELLOW },
437 { 0x01, 0x44, KEY_BLUE }, 437 { 0x0144, KEY_BLUE },
438 { 0x01, 0x0c, KEY_SHUFFLE }, /* snapshot */ 438 { 0x010c, KEY_SHUFFLE }, /* snapshot */
439 { 0x01, 0x48, KEY_STOP }, 439 { 0x0148, KEY_STOP },
440 { 0x01, 0x50, KEY_PLAY }, 440 { 0x0150, KEY_PLAY },
441 { 0x01, 0x51, KEY_PAUSE }, 441 { 0x0151, KEY_PAUSE },
442 { 0x01, 0x49, KEY_RECORD }, 442 { 0x0149, KEY_RECORD },
443 { 0x01, 0x18, KEY_PREVIOUS }, /* |<< */ 443 { 0x0118, KEY_PREVIOUS }, /* |<< */
444 { 0x01, 0x0d, KEY_NEXT }, /* >>| */ 444 { 0x010d, KEY_NEXT }, /* >>| */
445 { 0x01, 0x24, KEY_PROG1 }, /* F1 */ 445 { 0x0124, KEY_PROG1 }, /* F1 */
446 { 0x01, 0x25, KEY_PROG2 }, /* F2 */ 446 { 0x0125, KEY_PROG2 }, /* F2 */
447}; 447};
448 448
449/* DVB USB Driver stuff */ 449/* DVB USB Driver stuff */
diff --git a/drivers/media/dvb/dvb-usb/cinergyT2-core.c b/drivers/media/dvb/dvb-usb/cinergyT2-core.c
index 80e37a0d0892..e37ac4d48602 100644
--- a/drivers/media/dvb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/dvb/dvb-usb/cinergyT2-core.c
@@ -85,43 +85,43 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
85} 85}
86 86
87static struct dvb_usb_rc_key cinergyt2_rc_keys[] = { 87static struct dvb_usb_rc_key cinergyt2_rc_keys[] = {
88 { 0x04, 0x01, KEY_POWER }, 88 { 0x0401, KEY_POWER },
89 { 0x04, 0x02, KEY_1 }, 89 { 0x0402, KEY_1 },
90 { 0x04, 0x03, KEY_2 }, 90 { 0x0403, KEY_2 },
91 { 0x04, 0x04, KEY_3 }, 91 { 0x0404, KEY_3 },
92 { 0x04, 0x05, KEY_4 }, 92 { 0x0405, KEY_4 },
93 { 0x04, 0x06, KEY_5 }, 93 { 0x0406, KEY_5 },
94 { 0x04, 0x07, KEY_6 }, 94 { 0x0407, KEY_6 },
95 { 0x04, 0x08, KEY_7 }, 95 { 0x0408, KEY_7 },
96 { 0x04, 0x09, KEY_8 }, 96 { 0x0409, KEY_8 },
97 { 0x04, 0x0a, KEY_9 }, 97 { 0x040a, KEY_9 },
98 { 0x04, 0x0c, KEY_0 }, 98 { 0x040c, KEY_0 },
99 { 0x04, 0x0b, KEY_VIDEO }, 99 { 0x040b, KEY_VIDEO },
100 { 0x04, 0x0d, KEY_REFRESH }, 100 { 0x040d, KEY_REFRESH },
101 { 0x04, 0x0e, KEY_SELECT }, 101 { 0x040e, KEY_SELECT },
102 { 0x04, 0x0f, KEY_EPG }, 102 { 0x040f, KEY_EPG },
103 { 0x04, 0x10, KEY_UP }, 103 { 0x0410, KEY_UP },
104 { 0x04, 0x14, KEY_DOWN }, 104 { 0x0414, KEY_DOWN },
105 { 0x04, 0x11, KEY_LEFT }, 105 { 0x0411, KEY_LEFT },
106 { 0x04, 0x13, KEY_RIGHT }, 106 { 0x0413, KEY_RIGHT },
107 { 0x04, 0x12, KEY_OK }, 107 { 0x0412, KEY_OK },
108 { 0x04, 0x15, KEY_TEXT }, 108 { 0x0415, KEY_TEXT },
109 { 0x04, 0x16, KEY_INFO }, 109 { 0x0416, KEY_INFO },
110 { 0x04, 0x17, KEY_RED }, 110 { 0x0417, KEY_RED },
111 { 0x04, 0x18, KEY_GREEN }, 111 { 0x0418, KEY_GREEN },
112 { 0x04, 0x19, KEY_YELLOW }, 112 { 0x0419, KEY_YELLOW },
113 { 0x04, 0x1a, KEY_BLUE }, 113 { 0x041a, KEY_BLUE },
114 { 0x04, 0x1c, KEY_VOLUMEUP }, 114 { 0x041c, KEY_VOLUMEUP },
115 { 0x04, 0x1e, KEY_VOLUMEDOWN }, 115 { 0x041e, KEY_VOLUMEDOWN },
116 { 0x04, 0x1d, KEY_MUTE }, 116 { 0x041d, KEY_MUTE },
117 { 0x04, 0x1b, KEY_CHANNELUP }, 117 { 0x041b, KEY_CHANNELUP },
118 { 0x04, 0x1f, KEY_CHANNELDOWN }, 118 { 0x041f, KEY_CHANNELDOWN },
119 { 0x04, 0x40, KEY_PAUSE }, 119 { 0x0440, KEY_PAUSE },
120 { 0x04, 0x4c, KEY_PLAY }, 120 { 0x044c, KEY_PLAY },
121 { 0x04, 0x58, KEY_RECORD }, 121 { 0x0458, KEY_RECORD },
122 { 0x04, 0x54, KEY_PREVIOUS }, 122 { 0x0454, KEY_PREVIOUS },
123 { 0x04, 0x48, KEY_STOP }, 123 { 0x0448, KEY_STOP },
124 { 0x04, 0x5c, KEY_NEXT } 124 { 0x045c, KEY_NEXT }
125}; 125};
126 126
127/* Number of keypresses to ignore before detect repeating */ 127/* Number of keypresses to ignore before detect repeating */
diff --git a/drivers/media/dvb/dvb-usb/cinergyT2-fe.c b/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
index 649f25cca49e..9cd51ac12076 100644
--- a/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
+++ b/drivers/media/dvb/dvb-usb/cinergyT2-fe.c
@@ -275,6 +275,7 @@ static int cinergyt2_fe_set_frontend(struct dvb_frontend *fe,
275 param.tps = cpu_to_le16(compute_tps(fep)); 275 param.tps = cpu_to_le16(compute_tps(fep));
276 param.freq = cpu_to_le32(fep->frequency / 1000); 276 param.freq = cpu_to_le32(fep->frequency / 1000);
277 param.bandwidth = 8 - fep->u.ofdm.bandwidth - BANDWIDTH_8_MHZ; 277 param.bandwidth = 8 - fep->u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
278 param.flags = 0;
278 279
279 err = dvb_usb_generic_rw(state->d, 280 err = dvb_usb_generic_rw(state->d,
280 (char *)&param, sizeof(param), 281 (char *)&param, sizeof(param),
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 406d7fba369d..f65591fb7cec 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -38,7 +38,7 @@
38#include "mxl5005s.h" 38#include "mxl5005s.h"
39#include "dib7000p.h" 39#include "dib7000p.h"
40#include "dib0070.h" 40#include "dib0070.h"
41#include "lgs8gl5.h" 41#include "lgs8gxx.h"
42 42
43/* debug */ 43/* debug */
44static int dvb_usb_cxusb_debug; 44static int dvb_usb_cxusb_debug;
@@ -392,8 +392,8 @@ static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
392 *state = REMOTE_NO_KEY_PRESSED; 392 *state = REMOTE_NO_KEY_PRESSED;
393 393
394 for (i = 0; i < d->props.rc_key_map_size; i++) { 394 for (i = 0; i < d->props.rc_key_map_size; i++) {
395 if (keymap[i].custom == ircode[2] && 395 if (rc5_custom(&keymap[i]) == ircode[2] &&
396 keymap[i].data == ircode[3]) { 396 rc5_data(&keymap[i]) == ircode[3]) {
397 *event = keymap[i].event; 397 *event = keymap[i].event;
398 *state = REMOTE_KEY_PRESSED; 398 *state = REMOTE_KEY_PRESSED;
399 399
@@ -420,8 +420,8 @@ static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
420 return 0; 420 return 0;
421 421
422 for (i = 0; i < d->props.rc_key_map_size; i++) { 422 for (i = 0; i < d->props.rc_key_map_size; i++) {
423 if (keymap[i].custom == ircode[1] && 423 if (rc5_custom(&keymap[i]) == ircode[1] &&
424 keymap[i].data == ircode[2]) { 424 rc5_data(&keymap[i]) == ircode[2]) {
425 *event = keymap[i].event; 425 *event = keymap[i].event;
426 *state = REMOTE_KEY_PRESSED; 426 *state = REMOTE_KEY_PRESSED;
427 427
@@ -446,8 +446,8 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
446 return 0; 446 return 0;
447 447
448 for (i = 0; i < d->props.rc_key_map_size; i++) { 448 for (i = 0; i < d->props.rc_key_map_size; i++) {
449 if (keymap[i].custom == ircode[0] && 449 if (rc5_custom(&keymap[i]) == ircode[0] &&
450 keymap[i].data == ircode[1]) { 450 rc5_data(&keymap[i]) == ircode[1]) {
451 *event = keymap[i].event; 451 *event = keymap[i].event;
452 *state = REMOTE_KEY_PRESSED; 452 *state = REMOTE_KEY_PRESSED;
453 453
@@ -459,128 +459,128 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
459} 459}
460 460
461static struct dvb_usb_rc_key dvico_mce_rc_keys[] = { 461static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
462 { 0xfe, 0x02, KEY_TV }, 462 { 0xfe02, KEY_TV },
463 { 0xfe, 0x0e, KEY_MP3 }, 463 { 0xfe0e, KEY_MP3 },
464 { 0xfe, 0x1a, KEY_DVD }, 464 { 0xfe1a, KEY_DVD },
465 { 0xfe, 0x1e, KEY_FAVORITES }, 465 { 0xfe1e, KEY_FAVORITES },
466 { 0xfe, 0x16, KEY_SETUP }, 466 { 0xfe16, KEY_SETUP },
467 { 0xfe, 0x46, KEY_POWER2 }, 467 { 0xfe46, KEY_POWER2 },
468 { 0xfe, 0x0a, KEY_EPG }, 468 { 0xfe0a, KEY_EPG },
469 { 0xfe, 0x49, KEY_BACK }, 469 { 0xfe49, KEY_BACK },
470 { 0xfe, 0x4d, KEY_MENU }, 470 { 0xfe4d, KEY_MENU },
471 { 0xfe, 0x51, KEY_UP }, 471 { 0xfe51, KEY_UP },
472 { 0xfe, 0x5b, KEY_LEFT }, 472 { 0xfe5b, KEY_LEFT },
473 { 0xfe, 0x5f, KEY_RIGHT }, 473 { 0xfe5f, KEY_RIGHT },
474 { 0xfe, 0x53, KEY_DOWN }, 474 { 0xfe53, KEY_DOWN },
475 { 0xfe, 0x5e, KEY_OK }, 475 { 0xfe5e, KEY_OK },
476 { 0xfe, 0x59, KEY_INFO }, 476 { 0xfe59, KEY_INFO },
477 { 0xfe, 0x55, KEY_TAB }, 477 { 0xfe55, KEY_TAB },
478 { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */ 478 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
479 { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */ 479 { 0xfe12, KEY_NEXTSONG }, /* Skip */
480 { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */ 480 { 0xfe42, KEY_ENTER }, /* Windows/Start */
481 { 0xfe, 0x15, KEY_VOLUMEUP }, 481 { 0xfe15, KEY_VOLUMEUP },
482 { 0xfe, 0x05, KEY_VOLUMEDOWN }, 482 { 0xfe05, KEY_VOLUMEDOWN },
483 { 0xfe, 0x11, KEY_CHANNELUP }, 483 { 0xfe11, KEY_CHANNELUP },
484 { 0xfe, 0x09, KEY_CHANNELDOWN }, 484 { 0xfe09, KEY_CHANNELDOWN },
485 { 0xfe, 0x52, KEY_CAMERA }, 485 { 0xfe52, KEY_CAMERA },
486 { 0xfe, 0x5a, KEY_TUNER }, /* Live */ 486 { 0xfe5a, KEY_TUNER }, /* Live */
487 { 0xfe, 0x19, KEY_OPEN }, 487 { 0xfe19, KEY_OPEN },
488 { 0xfe, 0x0b, KEY_1 }, 488 { 0xfe0b, KEY_1 },
489 { 0xfe, 0x17, KEY_2 }, 489 { 0xfe17, KEY_2 },
490 { 0xfe, 0x1b, KEY_3 }, 490 { 0xfe1b, KEY_3 },
491 { 0xfe, 0x07, KEY_4 }, 491 { 0xfe07, KEY_4 },
492 { 0xfe, 0x50, KEY_5 }, 492 { 0xfe50, KEY_5 },
493 { 0xfe, 0x54, KEY_6 }, 493 { 0xfe54, KEY_6 },
494 { 0xfe, 0x48, KEY_7 }, 494 { 0xfe48, KEY_7 },
495 { 0xfe, 0x4c, KEY_8 }, 495 { 0xfe4c, KEY_8 },
496 { 0xfe, 0x58, KEY_9 }, 496 { 0xfe58, KEY_9 },
497 { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */ 497 { 0xfe13, KEY_ANGLE }, /* Aspect */
498 { 0xfe, 0x03, KEY_0 }, 498 { 0xfe03, KEY_0 },
499 { 0xfe, 0x1f, KEY_ZOOM }, 499 { 0xfe1f, KEY_ZOOM },
500 { 0xfe, 0x43, KEY_REWIND }, 500 { 0xfe43, KEY_REWIND },
501 { 0xfe, 0x47, KEY_PLAYPAUSE }, 501 { 0xfe47, KEY_PLAYPAUSE },
502 { 0xfe, 0x4f, KEY_FASTFORWARD }, 502 { 0xfe4f, KEY_FASTFORWARD },
503 { 0xfe, 0x57, KEY_MUTE }, 503 { 0xfe57, KEY_MUTE },
504 { 0xfe, 0x0d, KEY_STOP }, 504 { 0xfe0d, KEY_STOP },
505 { 0xfe, 0x01, KEY_RECORD }, 505 { 0xfe01, KEY_RECORD },
506 { 0xfe, 0x4e, KEY_POWER }, 506 { 0xfe4e, KEY_POWER },
507}; 507};
508 508
509static struct dvb_usb_rc_key dvico_portable_rc_keys[] = { 509static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
510 { 0xfc, 0x02, KEY_SETUP }, /* Profile */ 510 { 0xfc02, KEY_SETUP }, /* Profile */
511 { 0xfc, 0x43, KEY_POWER2 }, 511 { 0xfc43, KEY_POWER2 },
512 { 0xfc, 0x06, KEY_EPG }, 512 { 0xfc06, KEY_EPG },
513 { 0xfc, 0x5a, KEY_BACK }, 513 { 0xfc5a, KEY_BACK },
514 { 0xfc, 0x05, KEY_MENU }, 514 { 0xfc05, KEY_MENU },
515 { 0xfc, 0x47, KEY_INFO }, 515 { 0xfc47, KEY_INFO },
516 { 0xfc, 0x01, KEY_TAB }, 516 { 0xfc01, KEY_TAB },
517 { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */ 517 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
518 { 0xfc, 0x49, KEY_VOLUMEUP }, 518 { 0xfc49, KEY_VOLUMEUP },
519 { 0xfc, 0x09, KEY_VOLUMEDOWN }, 519 { 0xfc09, KEY_VOLUMEDOWN },
520 { 0xfc, 0x54, KEY_CHANNELUP }, 520 { 0xfc54, KEY_CHANNELUP },
521 { 0xfc, 0x0b, KEY_CHANNELDOWN }, 521 { 0xfc0b, KEY_CHANNELDOWN },
522 { 0xfc, 0x16, KEY_CAMERA }, 522 { 0xfc16, KEY_CAMERA },
523 { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */ 523 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
524 { 0xfc, 0x45, KEY_OPEN }, 524 { 0xfc45, KEY_OPEN },
525 { 0xfc, 0x19, KEY_1 }, 525 { 0xfc19, KEY_1 },
526 { 0xfc, 0x18, KEY_2 }, 526 { 0xfc18, KEY_2 },
527 { 0xfc, 0x1b, KEY_3 }, 527 { 0xfc1b, KEY_3 },
528 { 0xfc, 0x1a, KEY_4 }, 528 { 0xfc1a, KEY_4 },
529 { 0xfc, 0x58, KEY_5 }, 529 { 0xfc58, KEY_5 },
530 { 0xfc, 0x59, KEY_6 }, 530 { 0xfc59, KEY_6 },
531 { 0xfc, 0x15, KEY_7 }, 531 { 0xfc15, KEY_7 },
532 { 0xfc, 0x14, KEY_8 }, 532 { 0xfc14, KEY_8 },
533 { 0xfc, 0x17, KEY_9 }, 533 { 0xfc17, KEY_9 },
534 { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */ 534 { 0xfc44, KEY_ANGLE }, /* Aspect */
535 { 0xfc, 0x55, KEY_0 }, 535 { 0xfc55, KEY_0 },
536 { 0xfc, 0x07, KEY_ZOOM }, 536 { 0xfc07, KEY_ZOOM },
537 { 0xfc, 0x0a, KEY_REWIND }, 537 { 0xfc0a, KEY_REWIND },
538 { 0xfc, 0x08, KEY_PLAYPAUSE }, 538 { 0xfc08, KEY_PLAYPAUSE },
539 { 0xfc, 0x4b, KEY_FASTFORWARD }, 539 { 0xfc4b, KEY_FASTFORWARD },
540 { 0xfc, 0x5b, KEY_MUTE }, 540 { 0xfc5b, KEY_MUTE },
541 { 0xfc, 0x04, KEY_STOP }, 541 { 0xfc04, KEY_STOP },
542 { 0xfc, 0x56, KEY_RECORD }, 542 { 0xfc56, KEY_RECORD },
543 { 0xfc, 0x57, KEY_POWER }, 543 { 0xfc57, KEY_POWER },
544 { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */ 544 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
545 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */ 545 { 0xfc00, KEY_UNKNOWN }, /* HD */
546}; 546};
547 547
548static struct dvb_usb_rc_key d680_dmb_rc_keys[] = { 548static struct dvb_usb_rc_key d680_dmb_rc_keys[] = {
549 { 0x00, 0x38, KEY_UNKNOWN }, /* TV/AV */ 549 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
550 { 0x08, 0x0c, KEY_ZOOM }, 550 { 0x080c, KEY_ZOOM },
551 { 0x08, 0x00, KEY_0 }, 551 { 0x0800, KEY_0 },
552 { 0x00, 0x01, KEY_1 }, 552 { 0x0001, KEY_1 },
553 { 0x08, 0x02, KEY_2 }, 553 { 0x0802, KEY_2 },
554 { 0x00, 0x03, KEY_3 }, 554 { 0x0003, KEY_3 },
555 { 0x08, 0x04, KEY_4 }, 555 { 0x0804, KEY_4 },
556 { 0x00, 0x05, KEY_5 }, 556 { 0x0005, KEY_5 },
557 { 0x08, 0x06, KEY_6 }, 557 { 0x0806, KEY_6 },
558 { 0x00, 0x07, KEY_7 }, 558 { 0x0007, KEY_7 },
559 { 0x08, 0x08, KEY_8 }, 559 { 0x0808, KEY_8 },
560 { 0x00, 0x09, KEY_9 }, 560 { 0x0009, KEY_9 },
561 { 0x00, 0x0a, KEY_MUTE }, 561 { 0x000a, KEY_MUTE },
562 { 0x08, 0x29, KEY_BACK }, 562 { 0x0829, KEY_BACK },
563 { 0x00, 0x12, KEY_CHANNELUP }, 563 { 0x0012, KEY_CHANNELUP },
564 { 0x08, 0x13, KEY_CHANNELDOWN }, 564 { 0x0813, KEY_CHANNELDOWN },
565 { 0x00, 0x2b, KEY_VOLUMEUP }, 565 { 0x002b, KEY_VOLUMEUP },
566 { 0x08, 0x2c, KEY_VOLUMEDOWN }, 566 { 0x082c, KEY_VOLUMEDOWN },
567 { 0x00, 0x20, KEY_UP }, 567 { 0x0020, KEY_UP },
568 { 0x08, 0x21, KEY_DOWN }, 568 { 0x0821, KEY_DOWN },
569 { 0x00, 0x11, KEY_LEFT }, 569 { 0x0011, KEY_LEFT },
570 { 0x08, 0x10, KEY_RIGHT }, 570 { 0x0810, KEY_RIGHT },
571 { 0x00, 0x0d, KEY_OK }, 571 { 0x000d, KEY_OK },
572 { 0x08, 0x1f, KEY_RECORD }, 572 { 0x081f, KEY_RECORD },
573 { 0x00, 0x17, KEY_PLAYPAUSE }, 573 { 0x0017, KEY_PLAYPAUSE },
574 { 0x08, 0x16, KEY_PLAYPAUSE }, 574 { 0x0816, KEY_PLAYPAUSE },
575 { 0x00, 0x0b, KEY_STOP }, 575 { 0x000b, KEY_STOP },
576 { 0x08, 0x27, KEY_FASTFORWARD }, 576 { 0x0827, KEY_FASTFORWARD },
577 { 0x00, 0x26, KEY_REWIND }, 577 { 0x0026, KEY_REWIND },
578 { 0x08, 0x1e, KEY_UNKNOWN }, /* Time Shift */ 578 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
579 { 0x00, 0x0e, KEY_UNKNOWN }, /* Snapshot */ 579 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
580 { 0x08, 0x2d, KEY_UNKNOWN }, /* Mouse Cursor */ 580 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
581 { 0x00, 0x0f, KEY_UNKNOWN }, /* Minimize/Maximize */ 581 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
582 { 0x08, 0x14, KEY_UNKNOWN }, /* Shuffle */ 582 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
583 { 0x00, 0x25, KEY_POWER }, 583 { 0x0025, KEY_POWER },
584}; 584};
585 585
586static int cxusb_dee1601_demod_init(struct dvb_frontend* fe) 586static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
@@ -1094,8 +1094,18 @@ static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1094 return -EIO; 1094 return -EIO;
1095} 1095}
1096 1096
1097static struct lgs8gl5_config lgs8gl5_cfg = { 1097static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1098 .prod = LGS8GXX_PROD_LGS8GL5,
1098 .demod_address = 0x19, 1099 .demod_address = 0x19,
1100 .serial_ts = 0,
1101 .ts_clk_pol = 0,
1102 .ts_clk_gated = 1,
1103 .if_clk_freq = 30400, /* 30.4 MHz */
1104 .if_freq = 5725, /* 5.725 MHz */
1105 .if_neg_center = 0,
1106 .ext_adc = 0,
1107 .adc_signed = 0,
1108 .if_neg_edge = 0,
1099}; 1109};
1100 1110
1101static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap) 1111static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
@@ -1135,7 +1145,7 @@ static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1135 msleep(100); 1145 msleep(100);
1136 1146
1137 /* Attach frontend */ 1147 /* Attach frontend */
1138 adap->fe = dvb_attach(lgs8gl5_attach, &lgs8gl5_cfg, &d->i2c_adap); 1148 adap->fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
1139 if (adap->fe == NULL) 1149 if (adap->fe == NULL)
1140 return -EIO; 1150 return -EIO;
1141 1151
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 818b2ab584bf..d1d6f4491403 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -310,7 +310,7 @@ static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap)
310 struct i2c_adapter *tun_i2c; 310 struct i2c_adapter *tun_i2c;
311 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1); 311 tun_i2c = dib7000p_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
312 return dvb_attach(mt2266_attach, adap->fe, tun_i2c, 312 return dvb_attach(mt2266_attach, adap->fe, tun_i2c,
313 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;; 313 &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;
314} 314}
315 315
316/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */ 316/* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */
@@ -509,7 +509,8 @@ static int dib0700_rc_query_legacy(struct dvb_usb_device *d, u32 *event,
509 return 0; 509 return 0;
510 } 510 }
511 for (i=0;i<d->props.rc_key_map_size; i++) { 511 for (i=0;i<d->props.rc_key_map_size; i++) {
512 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) { 512 if (rc5_custom(&keymap[i]) == key[3-2] &&
513 rc5_data(&keymap[i]) == key[3-3]) {
513 st->rc_counter = 0; 514 st->rc_counter = 0;
514 *event = keymap[i].event; 515 *event = keymap[i].event;
515 *state = REMOTE_KEY_PRESSED; 516 *state = REMOTE_KEY_PRESSED;
@@ -522,7 +523,8 @@ static int dib0700_rc_query_legacy(struct dvb_usb_device *d, u32 *event,
522 default: { 523 default: {
523 /* RC-5 protocol changes toggle bit on new keypress */ 524 /* RC-5 protocol changes toggle bit on new keypress */
524 for (i = 0; i < d->props.rc_key_map_size; i++) { 525 for (i = 0; i < d->props.rc_key_map_size; i++) {
525 if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) { 526 if (rc5_custom(&keymap[i]) == key[3-2] &&
527 rc5_data(&keymap[i]) == key[3-3]) {
526 if (d->last_event == keymap[i].event && 528 if (d->last_event == keymap[i].event &&
527 key[3-1] == st->rc_toggle) { 529 key[3-1] == st->rc_toggle) {
528 st->rc_counter++; 530 st->rc_counter++;
@@ -616,8 +618,8 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
616 618
617 /* Find the key in the map */ 619 /* Find the key in the map */
618 for (i = 0; i < d->props.rc_key_map_size; i++) { 620 for (i = 0; i < d->props.rc_key_map_size; i++) {
619 if (keymap[i].custom == poll_reply.system_lsb && 621 if (rc5_custom(&keymap[i]) == poll_reply.system_lsb &&
620 keymap[i].data == poll_reply.data) { 622 rc5_data(&keymap[i]) == poll_reply.data) {
621 *event = keymap[i].event; 623 *event = keymap[i].event;
622 found = 1; 624 found = 1;
623 break; 625 break;
@@ -684,193 +686,193 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
684 686
685static struct dvb_usb_rc_key dib0700_rc_keys[] = { 687static struct dvb_usb_rc_key dib0700_rc_keys[] = {
686 /* Key codes for the tiny Pinnacle remote*/ 688 /* Key codes for the tiny Pinnacle remote*/
687 { 0x07, 0x00, KEY_MUTE }, 689 { 0x0700, KEY_MUTE },
688 { 0x07, 0x01, KEY_MENU }, // Pinnacle logo 690 { 0x0701, KEY_MENU }, /* Pinnacle logo */
689 { 0x07, 0x39, KEY_POWER }, 691 { 0x0739, KEY_POWER },
690 { 0x07, 0x03, KEY_VOLUMEUP }, 692 { 0x0703, KEY_VOLUMEUP },
691 { 0x07, 0x09, KEY_VOLUMEDOWN }, 693 { 0x0709, KEY_VOLUMEDOWN },
692 { 0x07, 0x06, KEY_CHANNELUP }, 694 { 0x0706, KEY_CHANNELUP },
693 { 0x07, 0x0c, KEY_CHANNELDOWN }, 695 { 0x070c, KEY_CHANNELDOWN },
694 { 0x07, 0x0f, KEY_1 }, 696 { 0x070f, KEY_1 },
695 { 0x07, 0x15, KEY_2 }, 697 { 0x0715, KEY_2 },
696 { 0x07, 0x10, KEY_3 }, 698 { 0x0710, KEY_3 },
697 { 0x07, 0x18, KEY_4 }, 699 { 0x0718, KEY_4 },
698 { 0x07, 0x1b, KEY_5 }, 700 { 0x071b, KEY_5 },
699 { 0x07, 0x1e, KEY_6 }, 701 { 0x071e, KEY_6 },
700 { 0x07, 0x11, KEY_7 }, 702 { 0x0711, KEY_7 },
701 { 0x07, 0x21, KEY_8 }, 703 { 0x0721, KEY_8 },
702 { 0x07, 0x12, KEY_9 }, 704 { 0x0712, KEY_9 },
703 { 0x07, 0x27, KEY_0 }, 705 { 0x0727, KEY_0 },
704 { 0x07, 0x24, KEY_SCREEN }, // 'Square' key 706 { 0x0724, KEY_SCREEN }, /* 'Square' key */
705 { 0x07, 0x2a, KEY_TEXT }, // 'T' key 707 { 0x072a, KEY_TEXT }, /* 'T' key */
706 { 0x07, 0x2d, KEY_REWIND }, 708 { 0x072d, KEY_REWIND },
707 { 0x07, 0x30, KEY_PLAY }, 709 { 0x0730, KEY_PLAY },
708 { 0x07, 0x33, KEY_FASTFORWARD }, 710 { 0x0733, KEY_FASTFORWARD },
709 { 0x07, 0x36, KEY_RECORD }, 711 { 0x0736, KEY_RECORD },
710 { 0x07, 0x3c, KEY_STOP }, 712 { 0x073c, KEY_STOP },
711 { 0x07, 0x3f, KEY_CANCEL }, // '?' key 713 { 0x073f, KEY_CANCEL }, /* '?' key */
712 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */ 714 /* Key codes for the Terratec Cinergy DT XS Diversity, similar to cinergyT2.c */
713 { 0xeb, 0x01, KEY_POWER }, 715 { 0xeb01, KEY_POWER },
714 { 0xeb, 0x02, KEY_1 }, 716 { 0xeb02, KEY_1 },
715 { 0xeb, 0x03, KEY_2 }, 717 { 0xeb03, KEY_2 },
716 { 0xeb, 0x04, KEY_3 }, 718 { 0xeb04, KEY_3 },
717 { 0xeb, 0x05, KEY_4 }, 719 { 0xeb05, KEY_4 },
718 { 0xeb, 0x06, KEY_5 }, 720 { 0xeb06, KEY_5 },
719 { 0xeb, 0x07, KEY_6 }, 721 { 0xeb07, KEY_6 },
720 { 0xeb, 0x08, KEY_7 }, 722 { 0xeb08, KEY_7 },
721 { 0xeb, 0x09, KEY_8 }, 723 { 0xeb09, KEY_8 },
722 { 0xeb, 0x0a, KEY_9 }, 724 { 0xeb0a, KEY_9 },
723 { 0xeb, 0x0b, KEY_VIDEO }, 725 { 0xeb0b, KEY_VIDEO },
724 { 0xeb, 0x0c, KEY_0 }, 726 { 0xeb0c, KEY_0 },
725 { 0xeb, 0x0d, KEY_REFRESH }, 727 { 0xeb0d, KEY_REFRESH },
726 { 0xeb, 0x0f, KEY_EPG }, 728 { 0xeb0f, KEY_EPG },
727 { 0xeb, 0x10, KEY_UP }, 729 { 0xeb10, KEY_UP },
728 { 0xeb, 0x11, KEY_LEFT }, 730 { 0xeb11, KEY_LEFT },
729 { 0xeb, 0x12, KEY_OK }, 731 { 0xeb12, KEY_OK },
730 { 0xeb, 0x13, KEY_RIGHT }, 732 { 0xeb13, KEY_RIGHT },
731 { 0xeb, 0x14, KEY_DOWN }, 733 { 0xeb14, KEY_DOWN },
732 { 0xeb, 0x16, KEY_INFO }, 734 { 0xeb16, KEY_INFO },
733 { 0xeb, 0x17, KEY_RED }, 735 { 0xeb17, KEY_RED },
734 { 0xeb, 0x18, KEY_GREEN }, 736 { 0xeb18, KEY_GREEN },
735 { 0xeb, 0x19, KEY_YELLOW }, 737 { 0xeb19, KEY_YELLOW },
736 { 0xeb, 0x1a, KEY_BLUE }, 738 { 0xeb1a, KEY_BLUE },
737 { 0xeb, 0x1b, KEY_CHANNELUP }, 739 { 0xeb1b, KEY_CHANNELUP },
738 { 0xeb, 0x1c, KEY_VOLUMEUP }, 740 { 0xeb1c, KEY_VOLUMEUP },
739 { 0xeb, 0x1d, KEY_MUTE }, 741 { 0xeb1d, KEY_MUTE },
740 { 0xeb, 0x1e, KEY_VOLUMEDOWN }, 742 { 0xeb1e, KEY_VOLUMEDOWN },
741 { 0xeb, 0x1f, KEY_CHANNELDOWN }, 743 { 0xeb1f, KEY_CHANNELDOWN },
742 { 0xeb, 0x40, KEY_PAUSE }, 744 { 0xeb40, KEY_PAUSE },
743 { 0xeb, 0x41, KEY_HOME }, 745 { 0xeb41, KEY_HOME },
744 { 0xeb, 0x42, KEY_MENU }, /* DVD Menu */ 746 { 0xeb42, KEY_MENU }, /* DVD Menu */
745 { 0xeb, 0x43, KEY_SUBTITLE }, 747 { 0xeb43, KEY_SUBTITLE },
746 { 0xeb, 0x44, KEY_TEXT }, /* Teletext */ 748 { 0xeb44, KEY_TEXT }, /* Teletext */
747 { 0xeb, 0x45, KEY_DELETE }, 749 { 0xeb45, KEY_DELETE },
748 { 0xeb, 0x46, KEY_TV }, 750 { 0xeb46, KEY_TV },
749 { 0xeb, 0x47, KEY_DVD }, 751 { 0xeb47, KEY_DVD },
750 { 0xeb, 0x48, KEY_STOP }, 752 { 0xeb48, KEY_STOP },
751 { 0xeb, 0x49, KEY_VIDEO }, 753 { 0xeb49, KEY_VIDEO },
752 { 0xeb, 0x4a, KEY_AUDIO }, /* Music */ 754 { 0xeb4a, KEY_AUDIO }, /* Music */
753 { 0xeb, 0x4b, KEY_SCREEN }, /* Pic */ 755 { 0xeb4b, KEY_SCREEN }, /* Pic */
754 { 0xeb, 0x4c, KEY_PLAY }, 756 { 0xeb4c, KEY_PLAY },
755 { 0xeb, 0x4d, KEY_BACK }, 757 { 0xeb4d, KEY_BACK },
756 { 0xeb, 0x4e, KEY_REWIND }, 758 { 0xeb4e, KEY_REWIND },
757 { 0xeb, 0x4f, KEY_FASTFORWARD }, 759 { 0xeb4f, KEY_FASTFORWARD },
758 { 0xeb, 0x54, KEY_PREVIOUS }, 760 { 0xeb54, KEY_PREVIOUS },
759 { 0xeb, 0x58, KEY_RECORD }, 761 { 0xeb58, KEY_RECORD },
760 { 0xeb, 0x5c, KEY_NEXT }, 762 { 0xeb5c, KEY_NEXT },
761 763
762 /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */ 764 /* Key codes for the Haupauge WinTV Nova-TD, copied from nova-t-usb2.c (Nova-T USB2) */
763 { 0x1e, 0x00, KEY_0 }, 765 { 0x1e00, KEY_0 },
764 { 0x1e, 0x01, KEY_1 }, 766 { 0x1e01, KEY_1 },
765 { 0x1e, 0x02, KEY_2 }, 767 { 0x1e02, KEY_2 },
766 { 0x1e, 0x03, KEY_3 }, 768 { 0x1e03, KEY_3 },
767 { 0x1e, 0x04, KEY_4 }, 769 { 0x1e04, KEY_4 },
768 { 0x1e, 0x05, KEY_5 }, 770 { 0x1e05, KEY_5 },
769 { 0x1e, 0x06, KEY_6 }, 771 { 0x1e06, KEY_6 },
770 { 0x1e, 0x07, KEY_7 }, 772 { 0x1e07, KEY_7 },
771 { 0x1e, 0x08, KEY_8 }, 773 { 0x1e08, KEY_8 },
772 { 0x1e, 0x09, KEY_9 }, 774 { 0x1e09, KEY_9 },
773 { 0x1e, 0x0a, KEY_KPASTERISK }, 775 { 0x1e0a, KEY_KPASTERISK },
774 { 0x1e, 0x0b, KEY_RED }, 776 { 0x1e0b, KEY_RED },
775 { 0x1e, 0x0c, KEY_RADIO }, 777 { 0x1e0c, KEY_RADIO },
776 { 0x1e, 0x0d, KEY_MENU }, 778 { 0x1e0d, KEY_MENU },
777 { 0x1e, 0x0e, KEY_GRAVE }, /* # */ 779 { 0x1e0e, KEY_GRAVE }, /* # */
778 { 0x1e, 0x0f, KEY_MUTE }, 780 { 0x1e0f, KEY_MUTE },
779 { 0x1e, 0x10, KEY_VOLUMEUP }, 781 { 0x1e10, KEY_VOLUMEUP },
780 { 0x1e, 0x11, KEY_VOLUMEDOWN }, 782 { 0x1e11, KEY_VOLUMEDOWN },
781 { 0x1e, 0x12, KEY_CHANNEL }, 783 { 0x1e12, KEY_CHANNEL },
782 { 0x1e, 0x14, KEY_UP }, 784 { 0x1e14, KEY_UP },
783 { 0x1e, 0x15, KEY_DOWN }, 785 { 0x1e15, KEY_DOWN },
784 { 0x1e, 0x16, KEY_LEFT }, 786 { 0x1e16, KEY_LEFT },
785 { 0x1e, 0x17, KEY_RIGHT }, 787 { 0x1e17, KEY_RIGHT },
786 { 0x1e, 0x18, KEY_VIDEO }, 788 { 0x1e18, KEY_VIDEO },
787 { 0x1e, 0x19, KEY_AUDIO }, 789 { 0x1e19, KEY_AUDIO },
788 { 0x1e, 0x1a, KEY_MEDIA }, 790 { 0x1e1a, KEY_MEDIA },
789 { 0x1e, 0x1b, KEY_EPG }, 791 { 0x1e1b, KEY_EPG },
790 { 0x1e, 0x1c, KEY_TV }, 792 { 0x1e1c, KEY_TV },
791 { 0x1e, 0x1e, KEY_NEXT }, 793 { 0x1e1e, KEY_NEXT },
792 { 0x1e, 0x1f, KEY_BACK }, 794 { 0x1e1f, KEY_BACK },
793 { 0x1e, 0x20, KEY_CHANNELUP }, 795 { 0x1e20, KEY_CHANNELUP },
794 { 0x1e, 0x21, KEY_CHANNELDOWN }, 796 { 0x1e21, KEY_CHANNELDOWN },
795 { 0x1e, 0x24, KEY_LAST }, /* Skip backwards */ 797 { 0x1e24, KEY_LAST }, /* Skip backwards */
796 { 0x1e, 0x25, KEY_OK }, 798 { 0x1e25, KEY_OK },
797 { 0x1e, 0x29, KEY_BLUE}, 799 { 0x1e29, KEY_BLUE},
798 { 0x1e, 0x2e, KEY_GREEN }, 800 { 0x1e2e, KEY_GREEN },
799 { 0x1e, 0x30, KEY_PAUSE }, 801 { 0x1e30, KEY_PAUSE },
800 { 0x1e, 0x32, KEY_REWIND }, 802 { 0x1e32, KEY_REWIND },
801 { 0x1e, 0x34, KEY_FASTFORWARD }, 803 { 0x1e34, KEY_FASTFORWARD },
802 { 0x1e, 0x35, KEY_PLAY }, 804 { 0x1e35, KEY_PLAY },
803 { 0x1e, 0x36, KEY_STOP }, 805 { 0x1e36, KEY_STOP },
804 { 0x1e, 0x37, KEY_RECORD }, 806 { 0x1e37, KEY_RECORD },
805 { 0x1e, 0x38, KEY_YELLOW }, 807 { 0x1e38, KEY_YELLOW },
806 { 0x1e, 0x3b, KEY_GOTO }, 808 { 0x1e3b, KEY_GOTO },
807 { 0x1e, 0x3d, KEY_POWER }, 809 { 0x1e3d, KEY_POWER },
808 810
809 /* Key codes for the Leadtek Winfast DTV Dongle */ 811 /* Key codes for the Leadtek Winfast DTV Dongle */
810 { 0x00, 0x42, KEY_POWER }, 812 { 0x0042, KEY_POWER },
811 { 0x07, 0x7c, KEY_TUNER }, 813 { 0x077c, KEY_TUNER },
812 { 0x0f, 0x4e, KEY_PRINT }, /* PREVIEW */ 814 { 0x0f4e, KEY_PRINT }, /* PREVIEW */
813 { 0x08, 0x40, KEY_SCREEN }, /* full screen toggle*/ 815 { 0x0840, KEY_SCREEN }, /* full screen toggle*/
814 { 0x0f, 0x71, KEY_DOT }, /* frequency */ 816 { 0x0f71, KEY_DOT }, /* frequency */
815 { 0x07, 0x43, KEY_0 }, 817 { 0x0743, KEY_0 },
816 { 0x0c, 0x41, KEY_1 }, 818 { 0x0c41, KEY_1 },
817 { 0x04, 0x43, KEY_2 }, 819 { 0x0443, KEY_2 },
818 { 0x0b, 0x7f, KEY_3 }, 820 { 0x0b7f, KEY_3 },
819 { 0x0e, 0x41, KEY_4 }, 821 { 0x0e41, KEY_4 },
820 { 0x06, 0x43, KEY_5 }, 822 { 0x0643, KEY_5 },
821 { 0x09, 0x7f, KEY_6 }, 823 { 0x097f, KEY_6 },
822 { 0x0d, 0x7e, KEY_7 }, 824 { 0x0d7e, KEY_7 },
823 { 0x05, 0x7c, KEY_8 }, 825 { 0x057c, KEY_8 },
824 { 0x0a, 0x40, KEY_9 }, 826 { 0x0a40, KEY_9 },
825 { 0x0e, 0x4e, KEY_CLEAR }, 827 { 0x0e4e, KEY_CLEAR },
826 { 0x04, 0x7c, KEY_CHANNEL }, /* show channel number */ 828 { 0x047c, KEY_CHANNEL }, /* show channel number */
827 { 0x0f, 0x41, KEY_LAST }, /* recall */ 829 { 0x0f41, KEY_LAST }, /* recall */
828 { 0x03, 0x42, KEY_MUTE }, 830 { 0x0342, KEY_MUTE },
829 { 0x06, 0x4c, KEY_RESERVED }, /* PIP button*/ 831 { 0x064c, KEY_RESERVED }, /* PIP button*/
830 { 0x01, 0x72, KEY_SHUFFLE }, /* SNAPSHOT */ 832 { 0x0172, KEY_SHUFFLE }, /* SNAPSHOT */
831 { 0x0c, 0x4e, KEY_PLAYPAUSE }, /* TIMESHIFT */ 833 { 0x0c4e, KEY_PLAYPAUSE }, /* TIMESHIFT */
832 { 0x0b, 0x70, KEY_RECORD }, 834 { 0x0b70, KEY_RECORD },
833 { 0x03, 0x7d, KEY_VOLUMEUP }, 835 { 0x037d, KEY_VOLUMEUP },
834 { 0x01, 0x7d, KEY_VOLUMEDOWN }, 836 { 0x017d, KEY_VOLUMEDOWN },
835 { 0x02, 0x42, KEY_CHANNELUP }, 837 { 0x0242, KEY_CHANNELUP },
836 { 0x00, 0x7d, KEY_CHANNELDOWN }, 838 { 0x007d, KEY_CHANNELDOWN },
837 839
838 /* Key codes for Nova-TD "credit card" remote control. */ 840 /* Key codes for Nova-TD "credit card" remote control. */
839 { 0x1d, 0x00, KEY_0 }, 841 { 0x1d00, KEY_0 },
840 { 0x1d, 0x01, KEY_1 }, 842 { 0x1d01, KEY_1 },
841 { 0x1d, 0x02, KEY_2 }, 843 { 0x1d02, KEY_2 },
842 { 0x1d, 0x03, KEY_3 }, 844 { 0x1d03, KEY_3 },
843 { 0x1d, 0x04, KEY_4 }, 845 { 0x1d04, KEY_4 },
844 { 0x1d, 0x05, KEY_5 }, 846 { 0x1d05, KEY_5 },
845 { 0x1d, 0x06, KEY_6 }, 847 { 0x1d06, KEY_6 },
846 { 0x1d, 0x07, KEY_7 }, 848 { 0x1d07, KEY_7 },
847 { 0x1d, 0x08, KEY_8 }, 849 { 0x1d08, KEY_8 },
848 { 0x1d, 0x09, KEY_9 }, 850 { 0x1d09, KEY_9 },
849 { 0x1d, 0x0a, KEY_TEXT }, 851 { 0x1d0a, KEY_TEXT },
850 { 0x1d, 0x0d, KEY_MENU }, 852 { 0x1d0d, KEY_MENU },
851 { 0x1d, 0x0f, KEY_MUTE }, 853 { 0x1d0f, KEY_MUTE },
852 { 0x1d, 0x10, KEY_VOLUMEUP }, 854 { 0x1d10, KEY_VOLUMEUP },
853 { 0x1d, 0x11, KEY_VOLUMEDOWN }, 855 { 0x1d11, KEY_VOLUMEDOWN },
854 { 0x1d, 0x12, KEY_CHANNEL }, 856 { 0x1d12, KEY_CHANNEL },
855 { 0x1d, 0x14, KEY_UP }, 857 { 0x1d14, KEY_UP },
856 { 0x1d, 0x15, KEY_DOWN }, 858 { 0x1d15, KEY_DOWN },
857 { 0x1d, 0x16, KEY_LEFT }, 859 { 0x1d16, KEY_LEFT },
858 { 0x1d, 0x17, KEY_RIGHT }, 860 { 0x1d17, KEY_RIGHT },
859 { 0x1d, 0x1c, KEY_TV }, 861 { 0x1d1c, KEY_TV },
860 { 0x1d, 0x1e, KEY_NEXT }, 862 { 0x1d1e, KEY_NEXT },
861 { 0x1d, 0x1f, KEY_BACK }, 863 { 0x1d1f, KEY_BACK },
862 { 0x1d, 0x20, KEY_CHANNELUP }, 864 { 0x1d20, KEY_CHANNELUP },
863 { 0x1d, 0x21, KEY_CHANNELDOWN }, 865 { 0x1d21, KEY_CHANNELDOWN },
864 { 0x1d, 0x24, KEY_LAST }, 866 { 0x1d24, KEY_LAST },
865 { 0x1d, 0x25, KEY_OK }, 867 { 0x1d25, KEY_OK },
866 { 0x1d, 0x30, KEY_PAUSE }, 868 { 0x1d30, KEY_PAUSE },
867 { 0x1d, 0x32, KEY_REWIND }, 869 { 0x1d32, KEY_REWIND },
868 { 0x1d, 0x34, KEY_FASTFORWARD }, 870 { 0x1d34, KEY_FASTFORWARD },
869 { 0x1d, 0x35, KEY_PLAY }, 871 { 0x1d35, KEY_PLAY },
870 { 0x1d, 0x36, KEY_STOP }, 872 { 0x1d36, KEY_STOP },
871 { 0x1d, 0x37, KEY_RECORD }, 873 { 0x1d37, KEY_RECORD },
872 { 0x1d, 0x3b, KEY_GOTO }, 874 { 0x1d3b, KEY_GOTO },
873 { 0x1d, 0x3d, KEY_POWER }, 875 { 0x1d3d, KEY_POWER },
874}; 876};
875 877
876/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */ 878/* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
@@ -1497,6 +1499,8 @@ struct usb_device_id dib0700_usb_id_table[] = {
1497 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) }, 1499 { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_H) },
1498 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) }, 1500 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T3) },
1499 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) }, 1501 { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_T5) },
1502 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D) },
1503 { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_STK7700D_2) },
1500 { 0 } /* Terminating entry */ 1504 { 0 } /* Terminating entry */
1501}; 1505};
1502MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); 1506MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -1624,7 +1628,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1624 } 1628 }
1625 }, 1629 },
1626 1630
1627 .num_device_descs = 4, 1631 .num_device_descs = 5,
1628 .devices = { 1632 .devices = {
1629 { "Pinnacle PCTV 2000e", 1633 { "Pinnacle PCTV 2000e",
1630 { &dib0700_usb_id_table[11], NULL }, 1634 { &dib0700_usb_id_table[11], NULL },
@@ -1642,6 +1646,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1642 { &dib0700_usb_id_table[14], NULL }, 1646 { &dib0700_usb_id_table[14], NULL },
1643 { NULL }, 1647 { NULL },
1644 }, 1648 },
1649 { "YUAN High-Tech DiBcom STK7700D",
1650 { &dib0700_usb_id_table[55], NULL },
1651 { NULL },
1652 },
1645 1653
1646 }, 1654 },
1647 1655
@@ -1822,7 +1830,7 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1822 }, 1830 },
1823 }, 1831 },
1824 1832
1825 .num_device_descs = 8, 1833 .num_device_descs = 9,
1826 .devices = { 1834 .devices = {
1827 { "Terratec Cinergy HT USB XE", 1835 { "Terratec Cinergy HT USB XE",
1828 { &dib0700_usb_id_table[27], NULL }, 1836 { &dib0700_usb_id_table[27], NULL },
@@ -1856,7 +1864,10 @@ struct dvb_usb_device_properties dib0700_devices[] = {
1856 { &dib0700_usb_id_table[51], NULL }, 1864 { &dib0700_usb_id_table[51], NULL },
1857 { NULL }, 1865 { NULL },
1858 }, 1866 },
1859 1867 { "YUAN High-Tech STK7700D",
1868 { &dib0700_usb_id_table[54], NULL },
1869 { NULL },
1870 },
1860 }, 1871 },
1861 .rc_interval = DEFAULT_RC_INTERVAL, 1872 .rc_interval = DEFAULT_RC_INTERVAL,
1862 .rc_key_map = dib0700_rc_keys, 1873 .rc_key_map = dib0700_rc_keys,
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 8dbad1ec53c4..da34979b5337 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -318,132 +318,132 @@ EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);
318 */ 318 */
319struct dvb_usb_rc_key dibusb_rc_keys[] = { 319struct dvb_usb_rc_key dibusb_rc_keys[] = {
320 /* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */ 320 /* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */
321 { 0x00, 0x16, KEY_POWER }, 321 { 0x0016, KEY_POWER },
322 { 0x00, 0x10, KEY_MUTE }, 322 { 0x0010, KEY_MUTE },
323 { 0x00, 0x03, KEY_1 }, 323 { 0x0003, KEY_1 },
324 { 0x00, 0x01, KEY_2 }, 324 { 0x0001, KEY_2 },
325 { 0x00, 0x06, KEY_3 }, 325 { 0x0006, KEY_3 },
326 { 0x00, 0x09, KEY_4 }, 326 { 0x0009, KEY_4 },
327 { 0x00, 0x1d, KEY_5 }, 327 { 0x001d, KEY_5 },
328 { 0x00, 0x1f, KEY_6 }, 328 { 0x001f, KEY_6 },
329 { 0x00, 0x0d, KEY_7 }, 329 { 0x000d, KEY_7 },
330 { 0x00, 0x19, KEY_8 }, 330 { 0x0019, KEY_8 },
331 { 0x00, 0x1b, KEY_9 }, 331 { 0x001b, KEY_9 },
332 { 0x00, 0x15, KEY_0 }, 332 { 0x0015, KEY_0 },
333 { 0x00, 0x05, KEY_CHANNELUP }, 333 { 0x0005, KEY_CHANNELUP },
334 { 0x00, 0x02, KEY_CHANNELDOWN }, 334 { 0x0002, KEY_CHANNELDOWN },
335 { 0x00, 0x1e, KEY_VOLUMEUP }, 335 { 0x001e, KEY_VOLUMEUP },
336 { 0x00, 0x0a, KEY_VOLUMEDOWN }, 336 { 0x000a, KEY_VOLUMEDOWN },
337 { 0x00, 0x11, KEY_RECORD }, 337 { 0x0011, KEY_RECORD },
338 { 0x00, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */ 338 { 0x0017, KEY_FAVORITES }, /* Heart symbol - Channel list. */
339 { 0x00, 0x14, KEY_PLAY }, 339 { 0x0014, KEY_PLAY },
340 { 0x00, 0x1a, KEY_STOP }, 340 { 0x001a, KEY_STOP },
341 { 0x00, 0x40, KEY_REWIND }, 341 { 0x0040, KEY_REWIND },
342 { 0x00, 0x12, KEY_FASTFORWARD }, 342 { 0x0012, KEY_FASTFORWARD },
343 { 0x00, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */ 343 { 0x000e, KEY_PREVIOUS }, /* Recall - Previous channel. */
344 { 0x00, 0x4c, KEY_PAUSE }, 344 { 0x004c, KEY_PAUSE },
345 { 0x00, 0x4d, KEY_SCREEN }, /* Full screen mode. */ 345 { 0x004d, KEY_SCREEN }, /* Full screen mode. */
346 { 0x00, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */ 346 { 0x0054, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
347 /* additional keys TwinHan VisionPlus, the Artec seemingly not have */ 347 /* additional keys TwinHan VisionPlus, the Artec seemingly not have */
348 { 0x00, 0x0c, KEY_CANCEL }, /* Cancel */ 348 { 0x000c, KEY_CANCEL }, /* Cancel */
349 { 0x00, 0x1c, KEY_EPG }, /* EPG */ 349 { 0x001c, KEY_EPG }, /* EPG */
350 { 0x00, 0x00, KEY_TAB }, /* Tab */ 350 { 0x0000, KEY_TAB }, /* Tab */
351 { 0x00, 0x48, KEY_INFO }, /* Preview */ 351 { 0x0048, KEY_INFO }, /* Preview */
352 { 0x00, 0x04, KEY_LIST }, /* RecordList */ 352 { 0x0004, KEY_LIST }, /* RecordList */
353 { 0x00, 0x0f, KEY_TEXT }, /* Teletext */ 353 { 0x000f, KEY_TEXT }, /* Teletext */
354 /* Key codes for the KWorld/ADSTech/JetWay remote. */ 354 /* Key codes for the KWorld/ADSTech/JetWay remote. */
355 { 0x86, 0x12, KEY_POWER }, 355 { 0x8612, KEY_POWER },
356 { 0x86, 0x0f, KEY_SELECT }, /* source */ 356 { 0x860f, KEY_SELECT }, /* source */
357 { 0x86, 0x0c, KEY_UNKNOWN }, /* scan */ 357 { 0x860c, KEY_UNKNOWN }, /* scan */
358 { 0x86, 0x0b, KEY_EPG }, 358 { 0x860b, KEY_EPG },
359 { 0x86, 0x10, KEY_MUTE }, 359 { 0x8610, KEY_MUTE },
360 { 0x86, 0x01, KEY_1 }, 360 { 0x8601, KEY_1 },
361 { 0x86, 0x02, KEY_2 }, 361 { 0x8602, KEY_2 },
362 { 0x86, 0x03, KEY_3 }, 362 { 0x8603, KEY_3 },
363 { 0x86, 0x04, KEY_4 }, 363 { 0x8604, KEY_4 },
364 { 0x86, 0x05, KEY_5 }, 364 { 0x8605, KEY_5 },
365 { 0x86, 0x06, KEY_6 }, 365 { 0x8606, KEY_6 },
366 { 0x86, 0x07, KEY_7 }, 366 { 0x8607, KEY_7 },
367 { 0x86, 0x08, KEY_8 }, 367 { 0x8608, KEY_8 },
368 { 0x86, 0x09, KEY_9 }, 368 { 0x8609, KEY_9 },
369 { 0x86, 0x0a, KEY_0 }, 369 { 0x860a, KEY_0 },
370 { 0x86, 0x18, KEY_ZOOM }, 370 { 0x8618, KEY_ZOOM },
371 { 0x86, 0x1c, KEY_UNKNOWN }, /* preview */ 371 { 0x861c, KEY_UNKNOWN }, /* preview */
372 { 0x86, 0x13, KEY_UNKNOWN }, /* snap */ 372 { 0x8613, KEY_UNKNOWN }, /* snap */
373 { 0x86, 0x00, KEY_UNDO }, 373 { 0x8600, KEY_UNDO },
374 { 0x86, 0x1d, KEY_RECORD }, 374 { 0x861d, KEY_RECORD },
375 { 0x86, 0x0d, KEY_STOP }, 375 { 0x860d, KEY_STOP },
376 { 0x86, 0x0e, KEY_PAUSE }, 376 { 0x860e, KEY_PAUSE },
377 { 0x86, 0x16, KEY_PLAY }, 377 { 0x8616, KEY_PLAY },
378 { 0x86, 0x11, KEY_BACK }, 378 { 0x8611, KEY_BACK },
379 { 0x86, 0x19, KEY_FORWARD }, 379 { 0x8619, KEY_FORWARD },
380 { 0x86, 0x14, KEY_UNKNOWN }, /* pip */ 380 { 0x8614, KEY_UNKNOWN }, /* pip */
381 { 0x86, 0x15, KEY_ESC }, 381 { 0x8615, KEY_ESC },
382 { 0x86, 0x1a, KEY_UP }, 382 { 0x861a, KEY_UP },
383 { 0x86, 0x1e, KEY_DOWN }, 383 { 0x861e, KEY_DOWN },
384 { 0x86, 0x1f, KEY_LEFT }, 384 { 0x861f, KEY_LEFT },
385 { 0x86, 0x1b, KEY_RIGHT }, 385 { 0x861b, KEY_RIGHT },
386 386
387 /* Key codes for the DiBcom MOD3000 remote. */ 387 /* Key codes for the DiBcom MOD3000 remote. */
388 { 0x80, 0x00, KEY_MUTE }, 388 { 0x8000, KEY_MUTE },
389 { 0x80, 0x01, KEY_TEXT }, 389 { 0x8001, KEY_TEXT },
390 { 0x80, 0x02, KEY_HOME }, 390 { 0x8002, KEY_HOME },
391 { 0x80, 0x03, KEY_POWER }, 391 { 0x8003, KEY_POWER },
392 392
393 { 0x80, 0x04, KEY_RED }, 393 { 0x8004, KEY_RED },
394 { 0x80, 0x05, KEY_GREEN }, 394 { 0x8005, KEY_GREEN },
395 { 0x80, 0x06, KEY_YELLOW }, 395 { 0x8006, KEY_YELLOW },
396 { 0x80, 0x07, KEY_BLUE }, 396 { 0x8007, KEY_BLUE },
397 397
398 { 0x80, 0x08, KEY_DVD }, 398 { 0x8008, KEY_DVD },
399 { 0x80, 0x09, KEY_AUDIO }, 399 { 0x8009, KEY_AUDIO },
400 { 0x80, 0x0a, KEY_MEDIA }, /* Pictures */ 400 { 0x800a, KEY_MEDIA }, /* Pictures */
401 { 0x80, 0x0b, KEY_VIDEO }, 401 { 0x800b, KEY_VIDEO },
402 402
403 { 0x80, 0x0c, KEY_BACK }, 403 { 0x800c, KEY_BACK },
404 { 0x80, 0x0d, KEY_UP }, 404 { 0x800d, KEY_UP },
405 { 0x80, 0x0e, KEY_RADIO }, 405 { 0x800e, KEY_RADIO },
406 { 0x80, 0x0f, KEY_EPG }, 406 { 0x800f, KEY_EPG },
407 407
408 { 0x80, 0x10, KEY_LEFT }, 408 { 0x8010, KEY_LEFT },
409 { 0x80, 0x11, KEY_OK }, 409 { 0x8011, KEY_OK },
410 { 0x80, 0x12, KEY_RIGHT }, 410 { 0x8012, KEY_RIGHT },
411 { 0x80, 0x13, KEY_UNKNOWN }, /* SAP */ 411 { 0x8013, KEY_UNKNOWN }, /* SAP */
412 412
413 { 0x80, 0x14, KEY_TV }, 413 { 0x8014, KEY_TV },
414 { 0x80, 0x15, KEY_DOWN }, 414 { 0x8015, KEY_DOWN },
415 { 0x80, 0x16, KEY_MENU }, /* DVD Menu */ 415 { 0x8016, KEY_MENU }, /* DVD Menu */
416 { 0x80, 0x17, KEY_LAST }, 416 { 0x8017, KEY_LAST },
417 417
418 { 0x80, 0x18, KEY_RECORD }, 418 { 0x8018, KEY_RECORD },
419 { 0x80, 0x19, KEY_STOP }, 419 { 0x8019, KEY_STOP },
420 { 0x80, 0x1a, KEY_PAUSE }, 420 { 0x801a, KEY_PAUSE },
421 { 0x80, 0x1b, KEY_PLAY }, 421 { 0x801b, KEY_PLAY },
422 422
423 { 0x80, 0x1c, KEY_PREVIOUS }, 423 { 0x801c, KEY_PREVIOUS },
424 { 0x80, 0x1d, KEY_REWIND }, 424 { 0x801d, KEY_REWIND },
425 { 0x80, 0x1e, KEY_FASTFORWARD }, 425 { 0x801e, KEY_FASTFORWARD },
426 { 0x80, 0x1f, KEY_NEXT}, 426 { 0x801f, KEY_NEXT},
427 427
428 { 0x80, 0x40, KEY_1 }, 428 { 0x8040, KEY_1 },
429 { 0x80, 0x41, KEY_2 }, 429 { 0x8041, KEY_2 },
430 { 0x80, 0x42, KEY_3 }, 430 { 0x8042, KEY_3 },
431 { 0x80, 0x43, KEY_CHANNELUP }, 431 { 0x8043, KEY_CHANNELUP },
432 432
433 { 0x80, 0x44, KEY_4 }, 433 { 0x8044, KEY_4 },
434 { 0x80, 0x45, KEY_5 }, 434 { 0x8045, KEY_5 },
435 { 0x80, 0x46, KEY_6 }, 435 { 0x8046, KEY_6 },
436 { 0x80, 0x47, KEY_CHANNELDOWN }, 436 { 0x8047, KEY_CHANNELDOWN },
437 437
438 { 0x80, 0x48, KEY_7 }, 438 { 0x8048, KEY_7 },
439 { 0x80, 0x49, KEY_8 }, 439 { 0x8049, KEY_8 },
440 { 0x80, 0x4a, KEY_9 }, 440 { 0x804a, KEY_9 },
441 { 0x80, 0x4b, KEY_VOLUMEUP }, 441 { 0x804b, KEY_VOLUMEUP },
442 442
443 { 0x80, 0x4c, KEY_CLEAR }, 443 { 0x804c, KEY_CLEAR },
444 { 0x80, 0x4d, KEY_0 }, 444 { 0x804d, KEY_0 },
445 { 0x80, 0x4e, KEY_ENTER }, 445 { 0x804e, KEY_ENTER },
446 { 0x80, 0x4f, KEY_VOLUMEDOWN }, 446 { 0x804f, KEY_VOLUMEDOWN },
447}; 447};
448EXPORT_SYMBOL(dibusb_rc_keys); 448EXPORT_SYMBOL(dibusb_rc_keys);
449 449
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index 059cec955318..a05b9f875663 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -42,6 +42,8 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
42/* 11 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_WARM) }, 42/* 11 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_WARM) },
43/* 12 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_COLD) }, 43/* 12 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_COLD) },
44/* 13 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_WARM) }, 44/* 13 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_WARM) },
45/* 14 */ { USB_DEVICE(USB_VID_HUMAX_COEX, USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD) },
46/* 15 */ { USB_DEVICE(USB_VID_HUMAX_COEX, USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM) },
45 { } /* Terminating entry */ 47 { } /* Terminating entry */
46}; 48};
47MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table); 49MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -66,7 +68,7 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
66 /* parameter for the MPEG2-data transfer */ 68 /* parameter for the MPEG2-data transfer */
67 .stream = { 69 .stream = {
68 .type = USB_BULK, 70 .type = USB_BULK,
69 .count = 7, 71 .count = 8,
70 .endpoint = 0x06, 72 .endpoint = 0x06,
71 .u = { 73 .u = {
72 .bulk = { 74 .bulk = {
@@ -88,7 +90,7 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
88 90
89 .generic_bulk_ctrl_endpoint = 0x01, 91 .generic_bulk_ctrl_endpoint = 0x01,
90 92
91 .num_device_descs = 7, 93 .num_device_descs = 8,
92 .devices = { 94 .devices = {
93 { "DiBcom USB2.0 DVB-T reference design (MOD3000P)", 95 { "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
94 { &dibusb_dib3000mc_table[0], NULL }, 96 { &dibusb_dib3000mc_table[0], NULL },
@@ -119,6 +121,10 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
119 { &dibusb_dib3000mc_table[12], NULL }, 121 { &dibusb_dib3000mc_table[12], NULL },
120 { &dibusb_dib3000mc_table[13], NULL }, 122 { &dibusb_dib3000mc_table[13], NULL },
121 }, 123 },
124 { "Humax/Coex DVB-T USB Stick 2.0 High Speed",
125 { &dibusb_dib3000mc_table[14], NULL },
126 { &dibusb_dib3000mc_table[15], NULL },
127 },
122 { NULL }, 128 { NULL },
123 } 129 }
124}; 130};
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index b545cf3eab2e..955147d00756 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -162,61 +162,61 @@ static int digitv_tuner_attach(struct dvb_usb_adapter *adap)
162} 162}
163 163
164static struct dvb_usb_rc_key digitv_rc_keys[] = { 164static struct dvb_usb_rc_key digitv_rc_keys[] = {
165 { 0x5f, 0x55, KEY_0 }, 165 { 0x5f55, KEY_0 },
166 { 0x6f, 0x55, KEY_1 }, 166 { 0x6f55, KEY_1 },
167 { 0x9f, 0x55, KEY_2 }, 167 { 0x9f55, KEY_2 },
168 { 0xaf, 0x55, KEY_3 }, 168 { 0xaf55, KEY_3 },
169 { 0x5f, 0x56, KEY_4 }, 169 { 0x5f56, KEY_4 },
170 { 0x6f, 0x56, KEY_5 }, 170 { 0x6f56, KEY_5 },
171 { 0x9f, 0x56, KEY_6 }, 171 { 0x9f56, KEY_6 },
172 { 0xaf, 0x56, KEY_7 }, 172 { 0xaf56, KEY_7 },
173 { 0x5f, 0x59, KEY_8 }, 173 { 0x5f59, KEY_8 },
174 { 0x6f, 0x59, KEY_9 }, 174 { 0x6f59, KEY_9 },
175 { 0x9f, 0x59, KEY_TV }, 175 { 0x9f59, KEY_TV },
176 { 0xaf, 0x59, KEY_AUX }, 176 { 0xaf59, KEY_AUX },
177 { 0x5f, 0x5a, KEY_DVD }, 177 { 0x5f5a, KEY_DVD },
178 { 0x6f, 0x5a, KEY_POWER }, 178 { 0x6f5a, KEY_POWER },
179 { 0x9f, 0x5a, KEY_MHP }, /* labelled 'Picture' */ 179 { 0x9f5a, KEY_MHP }, /* labelled 'Picture' */
180 { 0xaf, 0x5a, KEY_AUDIO }, 180 { 0xaf5a, KEY_AUDIO },
181 { 0x5f, 0x65, KEY_INFO }, 181 { 0x5f65, KEY_INFO },
182 { 0x6f, 0x65, KEY_F13 }, /* 16:9 */ 182 { 0x6f65, KEY_F13 }, /* 16:9 */
183 { 0x9f, 0x65, KEY_F14 }, /* 14:9 */ 183 { 0x9f65, KEY_F14 }, /* 14:9 */
184 { 0xaf, 0x65, KEY_EPG }, 184 { 0xaf65, KEY_EPG },
185 { 0x5f, 0x66, KEY_EXIT }, 185 { 0x5f66, KEY_EXIT },
186 { 0x6f, 0x66, KEY_MENU }, 186 { 0x6f66, KEY_MENU },
187 { 0x9f, 0x66, KEY_UP }, 187 { 0x9f66, KEY_UP },
188 { 0xaf, 0x66, KEY_DOWN }, 188 { 0xaf66, KEY_DOWN },
189 { 0x5f, 0x69, KEY_LEFT }, 189 { 0x5f69, KEY_LEFT },
190 { 0x6f, 0x69, KEY_RIGHT }, 190 { 0x6f69, KEY_RIGHT },
191 { 0x9f, 0x69, KEY_ENTER }, 191 { 0x9f69, KEY_ENTER },
192 { 0xaf, 0x69, KEY_CHANNELUP }, 192 { 0xaf69, KEY_CHANNELUP },
193 { 0x5f, 0x6a, KEY_CHANNELDOWN }, 193 { 0x5f6a, KEY_CHANNELDOWN },
194 { 0x6f, 0x6a, KEY_VOLUMEUP }, 194 { 0x6f6a, KEY_VOLUMEUP },
195 { 0x9f, 0x6a, KEY_VOLUMEDOWN }, 195 { 0x9f6a, KEY_VOLUMEDOWN },
196 { 0xaf, 0x6a, KEY_RED }, 196 { 0xaf6a, KEY_RED },
197 { 0x5f, 0x95, KEY_GREEN }, 197 { 0x5f95, KEY_GREEN },
198 { 0x6f, 0x95, KEY_YELLOW }, 198 { 0x6f95, KEY_YELLOW },
199 { 0x9f, 0x95, KEY_BLUE }, 199 { 0x9f95, KEY_BLUE },
200 { 0xaf, 0x95, KEY_SUBTITLE }, 200 { 0xaf95, KEY_SUBTITLE },
201 { 0x5f, 0x96, KEY_F15 }, /* AD */ 201 { 0x5f96, KEY_F15 }, /* AD */
202 { 0x6f, 0x96, KEY_TEXT }, 202 { 0x6f96, KEY_TEXT },
203 { 0x9f, 0x96, KEY_MUTE }, 203 { 0x9f96, KEY_MUTE },
204 { 0xaf, 0x96, KEY_REWIND }, 204 { 0xaf96, KEY_REWIND },
205 { 0x5f, 0x99, KEY_STOP }, 205 { 0x5f99, KEY_STOP },
206 { 0x6f, 0x99, KEY_PLAY }, 206 { 0x6f99, KEY_PLAY },
207 { 0x9f, 0x99, KEY_FASTFORWARD }, 207 { 0x9f99, KEY_FASTFORWARD },
208 { 0xaf, 0x99, KEY_F16 }, /* chapter */ 208 { 0xaf99, KEY_F16 }, /* chapter */
209 { 0x5f, 0x9a, KEY_PAUSE }, 209 { 0x5f9a, KEY_PAUSE },
210 { 0x6f, 0x9a, KEY_PLAY }, 210 { 0x6f9a, KEY_PLAY },
211 { 0x9f, 0x9a, KEY_RECORD }, 211 { 0x9f9a, KEY_RECORD },
212 { 0xaf, 0x9a, KEY_F17 }, /* picture in picture */ 212 { 0xaf9a, KEY_F17 }, /* picture in picture */
213 { 0x5f, 0xa5, KEY_KPPLUS }, /* zoom in */ 213 { 0x5fa5, KEY_KPPLUS }, /* zoom in */
214 { 0x6f, 0xa5, KEY_KPMINUS }, /* zoom out */ 214 { 0x6fa5, KEY_KPMINUS }, /* zoom out */
215 { 0x9f, 0xa5, KEY_F18 }, /* capture */ 215 { 0x9fa5, KEY_F18 }, /* capture */
216 { 0xaf, 0xa5, KEY_F19 }, /* web */ 216 { 0xafa5, KEY_F19 }, /* web */
217 { 0x5f, 0xa6, KEY_EMAIL }, 217 { 0x5fa6, KEY_EMAIL },
218 { 0x6f, 0xa6, KEY_PHONE }, 218 { 0x6fa6, KEY_PHONE },
219 { 0x9f, 0xa6, KEY_PC }, 219 { 0x9fa6, KEY_PC },
220}; 220};
221 221
222static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 222static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
@@ -238,8 +238,8 @@ static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
238 if (key[1] != 0) 238 if (key[1] != 0)
239 { 239 {
240 for (i = 0; i < d->props.rc_key_map_size; i++) { 240 for (i = 0; i < d->props.rc_key_map_size; i++) {
241 if (d->props.rc_key_map[i].custom == key[1] && 241 if (rc5_custom(&d->props.rc_key_map[i]) == key[1] &&
242 d->props.rc_key_map[i].data == key[2]) { 242 rc5_data(&d->props.rc_key_map[i]) == key[2]) {
243 *event = d->props.rc_key_map[i].event; 243 *event = d->props.rc_key_map[i].event;
244 *state = REMOTE_KEY_PRESSED; 244 *state = REMOTE_KEY_PRESSED;
245 return 0; 245 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index 81a6cbf60160..a1b12b01cbe4 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -58,24 +58,24 @@ static int dtt200u_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
58/* remote control */ 58/* remote control */
59/* key list for the tiny remote control (Yakumo, don't know about the others) */ 59/* key list for the tiny remote control (Yakumo, don't know about the others) */
60static struct dvb_usb_rc_key dtt200u_rc_keys[] = { 60static struct dvb_usb_rc_key dtt200u_rc_keys[] = {
61 { 0x80, 0x01, KEY_MUTE }, 61 { 0x8001, KEY_MUTE },
62 { 0x80, 0x02, KEY_CHANNELDOWN }, 62 { 0x8002, KEY_CHANNELDOWN },
63 { 0x80, 0x03, KEY_VOLUMEDOWN }, 63 { 0x8003, KEY_VOLUMEDOWN },
64 { 0x80, 0x04, KEY_1 }, 64 { 0x8004, KEY_1 },
65 { 0x80, 0x05, KEY_2 }, 65 { 0x8005, KEY_2 },
66 { 0x80, 0x06, KEY_3 }, 66 { 0x8006, KEY_3 },
67 { 0x80, 0x07, KEY_4 }, 67 { 0x8007, KEY_4 },
68 { 0x80, 0x08, KEY_5 }, 68 { 0x8008, KEY_5 },
69 { 0x80, 0x09, KEY_6 }, 69 { 0x8009, KEY_6 },
70 { 0x80, 0x0a, KEY_7 }, 70 { 0x800a, KEY_7 },
71 { 0x80, 0x0c, KEY_ZOOM }, 71 { 0x800c, KEY_ZOOM },
72 { 0x80, 0x0d, KEY_0 }, 72 { 0x800d, KEY_0 },
73 { 0x80, 0x0e, KEY_SELECT }, 73 { 0x800e, KEY_SELECT },
74 { 0x80, 0x12, KEY_POWER }, 74 { 0x8012, KEY_POWER },
75 { 0x80, 0x1a, KEY_CHANNELUP }, 75 { 0x801a, KEY_CHANNELUP },
76 { 0x80, 0x1b, KEY_8 }, 76 { 0x801b, KEY_8 },
77 { 0x80, 0x1e, KEY_VOLUMEUP }, 77 { 0x801e, KEY_VOLUMEUP },
78 { 0x80, 0x1f, KEY_9 }, 78 { 0x801f, KEY_9 },
79}; 79};
80 80
81static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 81static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
index 326f7608954b..cead089bbb4f 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
@@ -19,7 +19,7 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
19 return -EINVAL; 19 return -EINVAL;
20 } 20 }
21 21
22 strncpy(d->i2c_adap.name, d->desc->name, sizeof(d->i2c_adap.name)); 22 strlcpy(d->i2c_adap.name, d->desc->name, sizeof(d->i2c_adap.name));
23 d->i2c_adap.class = I2C_CLASS_TV_DIGITAL, 23 d->i2c_adap.class = I2C_CLASS_TV_DIGITAL,
24 d->i2c_adap.algo = d->props.i2c_algo; 24 d->i2c_adap.algo = d->props.i2c_algo;
25 d->i2c_adap.algo_data = NULL; 25 d->i2c_adap.algo_data = NULL;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 9593b7289994..185a5069b10b 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -58,6 +58,7 @@
58#define USB_VID_GIGABYTE 0x1044 58#define USB_VID_GIGABYTE 0x1044
59#define USB_VID_YUAN 0x1164 59#define USB_VID_YUAN 0x1164
60#define USB_VID_XTENSIONS 0x1ae7 60#define USB_VID_XTENSIONS 0x1ae7
61#define USB_VID_HUMAX_COEX 0x10b9
61 62
62/* Product IDs */ 63/* Product IDs */
63#define USB_PID_ADSTECH_USB2_COLD 0xa333 64#define USB_PID_ADSTECH_USB2_COLD 0xa333
@@ -103,6 +104,7 @@
103#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 104#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
104#define USB_PID_INTEL_CE9500 0x9500 105#define USB_PID_INTEL_CE9500 0x9500
105#define USB_PID_KWORLD_399U 0xe399 106#define USB_PID_KWORLD_399U 0xe399
107#define USB_PID_KWORLD_399U_2 0xe400
106#define USB_PID_KWORLD_395U 0xe396 108#define USB_PID_KWORLD_395U 0xe396
107#define USB_PID_KWORLD_395U_2 0xe39b 109#define USB_PID_KWORLD_395U_2 0xe39b
108#define USB_PID_KWORLD_395U_3 0xe395 110#define USB_PID_KWORLD_395U_3 0xe395
@@ -252,6 +254,8 @@
252#define USB_PID_YUAN_STK7700PH 0x1f08 254#define USB_PID_YUAN_STK7700PH 0x1f08
253#define USB_PID_YUAN_PD378S 0x2edc 255#define USB_PID_YUAN_PD378S 0x2edc
254#define USB_PID_YUAN_MC770 0x0871 256#define USB_PID_YUAN_MC770 0x0871
257#define USB_PID_YUAN_STK7700D 0x1efc
258#define USB_PID_YUAN_STK7700D_2 0x1e8c
255#define USB_PID_DW2102 0x2102 259#define USB_PID_DW2102 0x2102
256#define USB_PID_XTENSIONS_XD_380 0x0381 260#define USB_PID_XTENSIONS_XD_380 0x0381
257#define USB_PID_TELESTAR_STARSTICK_2 0x8000 261#define USB_PID_TELESTAR_STARSTICK_2 0x8000
@@ -259,5 +263,7 @@
259#define USB_PID_SONY_PLAYTV 0x0003 263#define USB_PID_SONY_PLAYTV 0x0003
260#define USB_PID_ELGATO_EYETV_DTT 0x0021 264#define USB_PID_ELGATO_EYETV_DTT 0x0021
261#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020 265#define USB_PID_ELGATO_EYETV_DTT_Dlx 0x0020
266#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD 0x5000
267#define USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM 0x5001
262 268
263#endif 269#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index c0c2c22ddd83..edde87c6aa3a 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -8,6 +8,71 @@
8#include "dvb-usb-common.h" 8#include "dvb-usb-common.h"
9#include <linux/usb/input.h> 9#include <linux/usb/input.h>
10 10
11static int dvb_usb_getkeycode(struct input_dev *dev,
12 int scancode, int *keycode)
13{
14 struct dvb_usb_device *d = input_get_drvdata(dev);
15
16 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
17 int i;
18
19 /* See if we can match the raw key code. */
20 for (i = 0; i < d->props.rc_key_map_size; i++)
21 if (keymap[i].scan == scancode) {
22 *keycode = keymap[i].event;
23 return 0;
24 }
25
26 /*
27 * If is there extra space, returns KEY_RESERVED,
28 * otherwise, input core won't let dvb_usb_setkeycode
29 * to work
30 */
31 for (i = 0; i < d->props.rc_key_map_size; i++)
32 if (keymap[i].event == KEY_RESERVED ||
33 keymap[i].event == KEY_UNKNOWN) {
34 *keycode = KEY_RESERVED;
35 return 0;
36 }
37
38 return -EINVAL;
39}
40
41static int dvb_usb_setkeycode(struct input_dev *dev,
42 int scancode, int keycode)
43{
44 struct dvb_usb_device *d = input_get_drvdata(dev);
45
46 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
47 int i;
48
49 /* Search if it is replacing an existing keycode */
50 for (i = 0; i < d->props.rc_key_map_size; i++)
51 if (keymap[i].scan == scancode) {
52 keymap[i].event = keycode;
53 return 0;
54 }
55
56 /* Search if is there a clean entry. If so, use it */
57 for (i = 0; i < d->props.rc_key_map_size; i++)
58 if (keymap[i].event == KEY_RESERVED ||
59 keymap[i].event == KEY_UNKNOWN) {
60 keymap[i].scan = scancode;
61 keymap[i].event = keycode;
62 return 0;
63 }
64
65 /*
66 * FIXME: Currently, it is not possible to increase the size of
67 * scancode table. For it to happen, one possibility
68 * would be to allocate a table with key_map_size + 1,
69 * copying data, appending the new key on it, and freeing
70 * the old one - or maybe just allocating some spare space
71 */
72
73 return -EINVAL;
74}
75
11/* Remote-control poll function - called every dib->rc_query_interval ms to see 76/* Remote-control poll function - called every dib->rc_query_interval ms to see
12 * whether the remote control has received anything. 77 * whether the remote control has received anything.
13 * 78 *
@@ -111,6 +176,8 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
111 input_dev->phys = d->rc_phys; 176 input_dev->phys = d->rc_phys;
112 usb_to_input_id(d->udev, &input_dev->id); 177 usb_to_input_id(d->udev, &input_dev->id);
113 input_dev->dev.parent = &d->udev->dev; 178 input_dev->dev.parent = &d->udev->dev;
179 input_dev->getkeycode = dvb_usb_getkeycode;
180 input_dev->setkeycode = dvb_usb_setkeycode;
114 181
115 /* set the bits for the keys */ 182 /* set the bits for the keys */
116 deb_rc("key map size: %d\n", d->props.rc_key_map_size); 183 deb_rc("key map size: %d\n", d->props.rc_key_map_size);
@@ -128,6 +195,8 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
128 input_dev->rep[REP_PERIOD] = d->props.rc_interval; 195 input_dev->rep[REP_PERIOD] = d->props.rc_interval;
129 input_dev->rep[REP_DELAY] = d->props.rc_interval + 150; 196 input_dev->rep[REP_DELAY] = d->props.rc_interval + 150;
130 197
198 input_set_drvdata(input_dev, d);
199
131 err = input_register_device(input_dev); 200 err = input_register_device(input_dev);
132 if (err) { 201 if (err) {
133 input_free_device(input_dev); 202 input_free_device(input_dev);
@@ -178,8 +247,8 @@ int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *d,
178 } 247 }
179 /* See if we can match the raw key code. */ 248 /* See if we can match the raw key code. */
180 for (i = 0; i < d->props.rc_key_map_size; i++) 249 for (i = 0; i < d->props.rc_key_map_size; i++)
181 if (keymap[i].custom == keybuf[1] && 250 if (rc5_custom(&keymap[i]) == keybuf[1] &&
182 keymap[i].data == keybuf[3]) { 251 rc5_data(&keymap[i]) == keybuf[3]) {
183 *event = keymap[i].event; 252 *event = keymap[i].event;
184 *state = REMOTE_KEY_PRESSED; 253 *state = REMOTE_KEY_PRESSED;
185 return 0; 254 return 0;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index e441d274e6c1..fe2b87efb3f1 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -81,10 +81,25 @@ struct dvb_usb_device_description {
81 * @event: the input event assigned to key identified by custom and data 81 * @event: the input event assigned to key identified by custom and data
82 */ 82 */
83struct dvb_usb_rc_key { 83struct dvb_usb_rc_key {
84 u8 custom,data; 84 u16 scan;
85 u32 event; 85 u32 event;
86}; 86};
87 87
88static inline u8 rc5_custom(struct dvb_usb_rc_key *key)
89{
90 return (key->scan >> 8) & 0xff;
91}
92
93static inline u8 rc5_data(struct dvb_usb_rc_key *key)
94{
95 return key->scan & 0xff;
96}
97
98static inline u8 rc5_scan(struct dvb_usb_rc_key *key)
99{
100 return key->scan & 0xffff;
101}
102
88struct dvb_usb_device; 103struct dvb_usb_device;
89struct dvb_usb_adapter; 104struct dvb_usb_adapter;
90struct usb_data_stream; 105struct usb_data_stream;
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c
index 75de49c0d943..5bb9479d154e 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -1,6 +1,6 @@
1/* DVB USB framework compliant Linux driver for the 1/* DVB USB framework compliant Linux driver for the
2* DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 2* DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101,
3* TeVii S600, S650 Cards 3* TeVii S600, S630, S650 Cards
4* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by) 4* Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by)
5* 5*
6* This program is free software; you can redistribute it and/or modify it 6* This program is free software; you can redistribute it and/or modify it
@@ -18,6 +18,8 @@
18#include "eds1547.h" 18#include "eds1547.h"
19#include "cx24116.h" 19#include "cx24116.h"
20#include "tda1002x.h" 20#include "tda1002x.h"
21#include "mt312.h"
22#include "zl10039.h"
21 23
22#ifndef USB_PID_DW2102 24#ifndef USB_PID_DW2102
23#define USB_PID_DW2102 0x2102 25#define USB_PID_DW2102 0x2102
@@ -39,6 +41,10 @@
39#define USB_PID_TEVII_S650 0xd650 41#define USB_PID_TEVII_S650 0xd650
40#endif 42#endif
41 43
44#ifndef USB_PID_TEVII_S630
45#define USB_PID_TEVII_S630 0xd630
46#endif
47
42#define DW210X_READ_MSG 0 48#define DW210X_READ_MSG 0
43#define DW210X_WRITE_MSG 1 49#define DW210X_WRITE_MSG 1
44 50
@@ -436,6 +442,69 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
436 return num; 442 return num;
437} 443}
438 444
445static int s630_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
446 int num)
447{
448 struct dvb_usb_device *d = i2c_get_adapdata(adap);
449 int ret = 0;
450
451 if (!d)
452 return -ENODEV;
453 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
454 return -EAGAIN;
455
456 switch (num) {
457 case 2: { /* read */
458 u8 ibuf[msg[1].len], obuf[3];
459 obuf[0] = msg[1].len;
460 obuf[1] = (msg[0].addr << 1);
461 obuf[2] = msg[0].buf[0];
462
463 ret = dw210x_op_rw(d->udev, 0x90, 0, 0,
464 obuf, 3, DW210X_WRITE_MSG);
465 msleep(5);
466 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
467 ibuf, msg[1].len, DW210X_READ_MSG);
468 memcpy(msg[1].buf, ibuf, msg[1].len);
469 break;
470 }
471 case 1:
472 switch (msg[0].addr) {
473 case 0x60:
474 case 0x0e: {
475 /* write to zl10313, zl10039 register, */
476 u8 obuf[msg[0].len + 2];
477 obuf[0] = msg[0].len + 1;
478 obuf[1] = (msg[0].addr << 1);
479 memcpy(obuf + 2, msg[0].buf, msg[0].len);
480 ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
481 obuf, msg[0].len + 2, DW210X_WRITE_MSG);
482 break;
483 }
484 case (DW2102_RC_QUERY): {
485 u8 ibuf[4];
486 ret = dw210x_op_rw(d->udev, 0xb8, 0, 0,
487 ibuf, 4, DW210X_READ_MSG);
488 msg[0].buf[0] = ibuf[3];
489 break;
490 }
491 case (DW2102_VOLTAGE_CTRL): {
492 u8 obuf[2];
493 obuf[0] = 0x03;
494 obuf[1] = msg[0].buf[0];
495 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
496 obuf, 2, DW210X_WRITE_MSG);
497 break;
498 }
499 }
500
501 break;
502 }
503
504 mutex_unlock(&d->i2c_mutex);
505 return num;
506}
507
439static u32 dw210x_i2c_func(struct i2c_adapter *adapter) 508static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
440{ 509{
441 return I2C_FUNC_I2C; 510 return I2C_FUNC_I2C;
@@ -466,6 +535,11 @@ static struct i2c_algorithm dw3101_i2c_algo = {
466 .functionality = dw210x_i2c_func, 535 .functionality = dw210x_i2c_func,
467}; 536};
468 537
538static struct i2c_algorithm s630_i2c_algo = {
539 .master_xfer = s630_i2c_transfer,
540 .functionality = dw210x_i2c_func,
541};
542
469static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) 543static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
470{ 544{
471 int i; 545 int i;
@@ -490,6 +564,37 @@ static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
490 return 0; 564 return 0;
491}; 565};
492 566
567static int s630_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
568{
569 int i, ret;
570 u8 buf[3], eeprom[256], eepromline[16];
571
572 for (i = 0; i < 256; i++) {
573 buf[0] = 1;
574 buf[1] = 0xa0;
575 buf[2] = i;
576 ret = dw210x_op_rw(d->udev, 0x90, 0, 0,
577 buf, 3, DW210X_WRITE_MSG);
578 ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
579 buf, 1, DW210X_READ_MSG);
580 if (ret < 0) {
581 err("read eeprom failed.");
582 return -1;
583 } else {
584 eepromline[i % 16] = buf[0];
585 eeprom[i] = buf[0];
586 }
587
588 if ((i % 16) == 15) {
589 deb_xfer("%02x: ", i - 15);
590 debug_dump(eepromline, 16, deb_xfer);
591 }
592 }
593
594 memcpy(mac, eeprom + 16, 6);
595 return 0;
596};
597
493static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 598static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
494{ 599{
495 static u8 command_13v[1] = {0x00}; 600 static u8 command_13v[1] = {0x00};
@@ -535,6 +640,10 @@ static struct tda10023_config dw3101_tda10023_config = {
535 .invert = 1, 640 .invert = 1,
536}; 641};
537 642
643static struct mt312_config zl313_config = {
644 .demod_address = 0x0e,
645};
646
538static int dw2104_frontend_attach(struct dvb_usb_adapter *d) 647static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
539{ 648{
540 if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config, 649 if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config,
@@ -596,6 +705,18 @@ static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
596 return -EIO; 705 return -EIO;
597} 706}
598 707
708static int s630_frontend_attach(struct dvb_usb_adapter *d)
709{
710 d->fe = dvb_attach(mt312_attach, &zl313_config,
711 &d->dev->i2c_adap);
712 if (d->fe != NULL) {
713 d->fe->ops.set_voltage = dw210x_set_voltage;
714 info("Attached zl10313!\n");
715 return 0;
716 }
717 return -EIO;
718}
719
599static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) 720static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
600{ 721{
601 dvb_attach(dvb_pll_attach, adap->fe, 0x60, 722 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
@@ -619,123 +740,131 @@ static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
619 return 0; 740 return 0;
620} 741}
621 742
743static int s630_zl10039_tuner_attach(struct dvb_usb_adapter *adap)
744{
745 dvb_attach(zl10039_attach, adap->fe, 0x60,
746 &adap->dev->i2c_adap);
747
748 return 0;
749}
750
622static struct dvb_usb_rc_key dw210x_rc_keys[] = { 751static struct dvb_usb_rc_key dw210x_rc_keys[] = {
623 { 0xf8, 0x0a, KEY_Q }, /*power*/ 752 { 0xf80a, KEY_Q }, /*power*/
624 { 0xf8, 0x0c, KEY_M }, /*mute*/ 753 { 0xf80c, KEY_M }, /*mute*/
625 { 0xf8, 0x11, KEY_1 }, 754 { 0xf811, KEY_1 },
626 { 0xf8, 0x12, KEY_2 }, 755 { 0xf812, KEY_2 },
627 { 0xf8, 0x13, KEY_3 }, 756 { 0xf813, KEY_3 },
628 { 0xf8, 0x14, KEY_4 }, 757 { 0xf814, KEY_4 },
629 { 0xf8, 0x15, KEY_5 }, 758 { 0xf815, KEY_5 },
630 { 0xf8, 0x16, KEY_6 }, 759 { 0xf816, KEY_6 },
631 { 0xf8, 0x17, KEY_7 }, 760 { 0xf817, KEY_7 },
632 { 0xf8, 0x18, KEY_8 }, 761 { 0xf818, KEY_8 },
633 { 0xf8, 0x19, KEY_9 }, 762 { 0xf819, KEY_9 },
634 { 0xf8, 0x10, KEY_0 }, 763 { 0xf810, KEY_0 },
635 { 0xf8, 0x1c, KEY_PAGEUP }, /*ch+*/ 764 { 0xf81c, KEY_PAGEUP }, /*ch+*/
636 { 0xf8, 0x0f, KEY_PAGEDOWN }, /*ch-*/ 765 { 0xf80f, KEY_PAGEDOWN }, /*ch-*/
637 { 0xf8, 0x1a, KEY_O }, /*vol+*/ 766 { 0xf81a, KEY_O }, /*vol+*/
638 { 0xf8, 0x0e, KEY_Z }, /*vol-*/ 767 { 0xf80e, KEY_Z }, /*vol-*/
639 { 0xf8, 0x04, KEY_R }, /*rec*/ 768 { 0xf804, KEY_R }, /*rec*/
640 { 0xf8, 0x09, KEY_D }, /*fav*/ 769 { 0xf809, KEY_D }, /*fav*/
641 { 0xf8, 0x08, KEY_BACKSPACE }, /*rewind*/ 770 { 0xf808, KEY_BACKSPACE }, /*rewind*/
642 { 0xf8, 0x07, KEY_A }, /*fast*/ 771 { 0xf807, KEY_A }, /*fast*/
643 { 0xf8, 0x0b, KEY_P }, /*pause*/ 772 { 0xf80b, KEY_P }, /*pause*/
644 { 0xf8, 0x02, KEY_ESC }, /*cancel*/ 773 { 0xf802, KEY_ESC }, /*cancel*/
645 { 0xf8, 0x03, KEY_G }, /*tab*/ 774 { 0xf803, KEY_G }, /*tab*/
646 { 0xf8, 0x00, KEY_UP }, /*up*/ 775 { 0xf800, KEY_UP }, /*up*/
647 { 0xf8, 0x1f, KEY_ENTER }, /*ok*/ 776 { 0xf81f, KEY_ENTER }, /*ok*/
648 { 0xf8, 0x01, KEY_DOWN }, /*down*/ 777 { 0xf801, KEY_DOWN }, /*down*/
649 { 0xf8, 0x05, KEY_C }, /*cap*/ 778 { 0xf805, KEY_C }, /*cap*/
650 { 0xf8, 0x06, KEY_S }, /*stop*/ 779 { 0xf806, KEY_S }, /*stop*/
651 { 0xf8, 0x40, KEY_F }, /*full*/ 780 { 0xf840, KEY_F }, /*full*/
652 { 0xf8, 0x1e, KEY_W }, /*tvmode*/ 781 { 0xf81e, KEY_W }, /*tvmode*/
653 { 0xf8, 0x1b, KEY_B }, /*recall*/ 782 { 0xf81b, KEY_B }, /*recall*/
654}; 783};
655 784
656static struct dvb_usb_rc_key tevii_rc_keys[] = { 785static struct dvb_usb_rc_key tevii_rc_keys[] = {
657 { 0xf8, 0x0a, KEY_POWER }, 786 { 0xf80a, KEY_POWER },
658 { 0xf8, 0x0c, KEY_MUTE }, 787 { 0xf80c, KEY_MUTE },
659 { 0xf8, 0x11, KEY_1 }, 788 { 0xf811, KEY_1 },
660 { 0xf8, 0x12, KEY_2 }, 789 { 0xf812, KEY_2 },
661 { 0xf8, 0x13, KEY_3 }, 790 { 0xf813, KEY_3 },
662 { 0xf8, 0x14, KEY_4 }, 791 { 0xf814, KEY_4 },
663 { 0xf8, 0x15, KEY_5 }, 792 { 0xf815, KEY_5 },
664 { 0xf8, 0x16, KEY_6 }, 793 { 0xf816, KEY_6 },
665 { 0xf8, 0x17, KEY_7 }, 794 { 0xf817, KEY_7 },
666 { 0xf8, 0x18, KEY_8 }, 795 { 0xf818, KEY_8 },
667 { 0xf8, 0x19, KEY_9 }, 796 { 0xf819, KEY_9 },
668 { 0xf8, 0x10, KEY_0 }, 797 { 0xf810, KEY_0 },
669 { 0xf8, 0x1c, KEY_MENU }, 798 { 0xf81c, KEY_MENU },
670 { 0xf8, 0x0f, KEY_VOLUMEDOWN }, 799 { 0xf80f, KEY_VOLUMEDOWN },
671 { 0xf8, 0x1a, KEY_LAST }, 800 { 0xf81a, KEY_LAST },
672 { 0xf8, 0x0e, KEY_OPEN }, 801 { 0xf80e, KEY_OPEN },
673 { 0xf8, 0x04, KEY_RECORD }, 802 { 0xf804, KEY_RECORD },
674 { 0xf8, 0x09, KEY_VOLUMEUP }, 803 { 0xf809, KEY_VOLUMEUP },
675 { 0xf8, 0x08, KEY_CHANNELUP }, 804 { 0xf808, KEY_CHANNELUP },
676 { 0xf8, 0x07, KEY_PVR }, 805 { 0xf807, KEY_PVR },
677 { 0xf8, 0x0b, KEY_TIME }, 806 { 0xf80b, KEY_TIME },
678 { 0xf8, 0x02, KEY_RIGHT }, 807 { 0xf802, KEY_RIGHT },
679 { 0xf8, 0x03, KEY_LEFT }, 808 { 0xf803, KEY_LEFT },
680 { 0xf8, 0x00, KEY_UP }, 809 { 0xf800, KEY_UP },
681 { 0xf8, 0x1f, KEY_OK }, 810 { 0xf81f, KEY_OK },
682 { 0xf8, 0x01, KEY_DOWN }, 811 { 0xf801, KEY_DOWN },
683 { 0xf8, 0x05, KEY_TUNER }, 812 { 0xf805, KEY_TUNER },
684 { 0xf8, 0x06, KEY_CHANNELDOWN }, 813 { 0xf806, KEY_CHANNELDOWN },
685 { 0xf8, 0x40, KEY_PLAYPAUSE }, 814 { 0xf840, KEY_PLAYPAUSE },
686 { 0xf8, 0x1e, KEY_REWIND }, 815 { 0xf81e, KEY_REWIND },
687 { 0xf8, 0x1b, KEY_FAVORITES }, 816 { 0xf81b, KEY_FAVORITES },
688 { 0xf8, 0x1d, KEY_BACK }, 817 { 0xf81d, KEY_BACK },
689 { 0xf8, 0x4d, KEY_FASTFORWARD }, 818 { 0xf84d, KEY_FASTFORWARD },
690 { 0xf8, 0x44, KEY_EPG }, 819 { 0xf844, KEY_EPG },
691 { 0xf8, 0x4c, KEY_INFO }, 820 { 0xf84c, KEY_INFO },
692 { 0xf8, 0x41, KEY_AB }, 821 { 0xf841, KEY_AB },
693 { 0xf8, 0x43, KEY_AUDIO }, 822 { 0xf843, KEY_AUDIO },
694 { 0xf8, 0x45, KEY_SUBTITLE }, 823 { 0xf845, KEY_SUBTITLE },
695 { 0xf8, 0x4a, KEY_LIST }, 824 { 0xf84a, KEY_LIST },
696 { 0xf8, 0x46, KEY_F1 }, 825 { 0xf846, KEY_F1 },
697 { 0xf8, 0x47, KEY_F2 }, 826 { 0xf847, KEY_F2 },
698 { 0xf8, 0x5e, KEY_F3 }, 827 { 0xf85e, KEY_F3 },
699 { 0xf8, 0x5c, KEY_F4 }, 828 { 0xf85c, KEY_F4 },
700 { 0xf8, 0x52, KEY_F5 }, 829 { 0xf852, KEY_F5 },
701 { 0xf8, 0x5a, KEY_F6 }, 830 { 0xf85a, KEY_F6 },
702 { 0xf8, 0x56, KEY_MODE }, 831 { 0xf856, KEY_MODE },
703 { 0xf8, 0x58, KEY_SWITCHVIDEOMODE }, 832 { 0xf858, KEY_SWITCHVIDEOMODE },
704}; 833};
705 834
706static struct dvb_usb_rc_key tbs_rc_keys[] = { 835static struct dvb_usb_rc_key tbs_rc_keys[] = {
707 { 0xf8, 0x84, KEY_POWER }, 836 { 0xf884, KEY_POWER },
708 { 0xf8, 0x94, KEY_MUTE }, 837 { 0xf894, KEY_MUTE },
709 { 0xf8, 0x87, KEY_1 }, 838 { 0xf887, KEY_1 },
710 { 0xf8, 0x86, KEY_2 }, 839 { 0xf886, KEY_2 },
711 { 0xf8, 0x85, KEY_3 }, 840 { 0xf885, KEY_3 },
712 { 0xf8, 0x8b, KEY_4 }, 841 { 0xf88b, KEY_4 },
713 { 0xf8, 0x8a, KEY_5 }, 842 { 0xf88a, KEY_5 },
714 { 0xf8, 0x89, KEY_6 }, 843 { 0xf889, KEY_6 },
715 { 0xf8, 0x8f, KEY_7 }, 844 { 0xf88f, KEY_7 },
716 { 0xf8, 0x8e, KEY_8 }, 845 { 0xf88e, KEY_8 },
717 { 0xf8, 0x8d, KEY_9 }, 846 { 0xf88d, KEY_9 },
718 { 0xf8, 0x92, KEY_0 }, 847 { 0xf892, KEY_0 },
719 { 0xf8, 0x96, KEY_CHANNELUP }, 848 { 0xf896, KEY_CHANNELUP },
720 { 0xf8, 0x91, KEY_CHANNELDOWN }, 849 { 0xf891, KEY_CHANNELDOWN },
721 { 0xf8, 0x93, KEY_VOLUMEUP }, 850 { 0xf893, KEY_VOLUMEUP },
722 { 0xf8, 0x8c, KEY_VOLUMEDOWN }, 851 { 0xf88c, KEY_VOLUMEDOWN },
723 { 0xf8, 0x83, KEY_RECORD }, 852 { 0xf883, KEY_RECORD },
724 { 0xf8, 0x98, KEY_PAUSE }, 853 { 0xf898, KEY_PAUSE },
725 { 0xf8, 0x99, KEY_OK }, 854 { 0xf899, KEY_OK },
726 { 0xf8, 0x9a, KEY_SHUFFLE }, 855 { 0xf89a, KEY_SHUFFLE },
727 { 0xf8, 0x81, KEY_UP }, 856 { 0xf881, KEY_UP },
728 { 0xf8, 0x90, KEY_LEFT }, 857 { 0xf890, KEY_LEFT },
729 { 0xf8, 0x82, KEY_RIGHT }, 858 { 0xf882, KEY_RIGHT },
730 { 0xf8, 0x88, KEY_DOWN }, 859 { 0xf888, KEY_DOWN },
731 { 0xf8, 0x95, KEY_FAVORITES }, 860 { 0xf895, KEY_FAVORITES },
732 { 0xf8, 0x97, KEY_SUBTITLE }, 861 { 0xf897, KEY_SUBTITLE },
733 { 0xf8, 0x9d, KEY_ZOOM }, 862 { 0xf89d, KEY_ZOOM },
734 { 0xf8, 0x9f, KEY_EXIT }, 863 { 0xf89f, KEY_EXIT },
735 { 0xf8, 0x9e, KEY_MENU }, 864 { 0xf89e, KEY_MENU },
736 { 0xf8, 0x9c, KEY_EPG }, 865 { 0xf89c, KEY_EPG },
737 { 0xf8, 0x80, KEY_PREVIOUS }, 866 { 0xf880, KEY_PREVIOUS },
738 { 0xf8, 0x9b, KEY_MODE } 867 { 0xf89b, KEY_MODE }
739}; 868};
740 869
741static struct dvb_usb_rc_keys_table keys_tables[] = { 870static struct dvb_usb_rc_keys_table keys_tables[] = {
@@ -763,9 +892,9 @@ static int dw2102_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
763 } 892 }
764 893
765 *state = REMOTE_NO_KEY_PRESSED; 894 *state = REMOTE_NO_KEY_PRESSED;
766 if (dw2102_i2c_transfer(&d->i2c_adap, &msg, 1) == 1) { 895 if (d->props.i2c_algo->master_xfer(&d->i2c_adap, &msg, 1) == 1) {
767 for (i = 0; i < keymap_size ; i++) { 896 for (i = 0; i < keymap_size ; i++) {
768 if (keymap[i].data == msg.buf[0]) { 897 if (rc5_data(&keymap[i]) == msg.buf[0]) {
769 *state = REMOTE_KEY_PRESSED; 898 *state = REMOTE_KEY_PRESSED;
770 *event = keymap[i].event; 899 *event = keymap[i].event;
771 break; 900 break;
@@ -792,6 +921,7 @@ static struct usb_device_id dw2102_table[] = {
792 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)}, 921 {USB_DEVICE(0x9022, USB_PID_TEVII_S650)},
793 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)}, 922 {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
794 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)}, 923 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
924 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
795 { } 925 { }
796}; 926};
797 927
@@ -806,6 +936,7 @@ static int dw2102_load_firmware(struct usb_device *dev,
806 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0}; 936 u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
807 const struct firmware *fw; 937 const struct firmware *fw;
808 const char *filename = "dvb-usb-dw2101.fw"; 938 const char *filename = "dvb-usb-dw2101.fw";
939
809 switch (dev->descriptor.idProduct) { 940 switch (dev->descriptor.idProduct) {
810 case 0x2101: 941 case 0x2101:
811 ret = request_firmware(&fw, filename, &dev->dev); 942 ret = request_firmware(&fw, filename, &dev->dev);
@@ -1053,6 +1184,48 @@ static struct dvb_usb_device_properties dw3101_properties = {
1053 } 1184 }
1054}; 1185};
1055 1186
1187static struct dvb_usb_device_properties s630_properties = {
1188 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1189 .usb_ctrl = DEVICE_SPECIFIC,
1190 .firmware = "dvb-usb-s630.fw",
1191 .no_reconnect = 1,
1192
1193 .i2c_algo = &s630_i2c_algo,
1194 .rc_key_map = tevii_rc_keys,
1195 .rc_key_map_size = ARRAY_SIZE(tevii_rc_keys),
1196 .rc_interval = 150,
1197 .rc_query = dw2102_rc_query,
1198
1199 .generic_bulk_ctrl_endpoint = 0x81,
1200 .num_adapters = 1,
1201 .download_firmware = dw2102_load_firmware,
1202 .read_mac_address = s630_read_mac_address,
1203 .adapter = {
1204 {
1205 .frontend_attach = s630_frontend_attach,
1206 .streaming_ctrl = NULL,
1207 .tuner_attach = s630_zl10039_tuner_attach,
1208 .stream = {
1209 .type = USB_BULK,
1210 .count = 8,
1211 .endpoint = 0x82,
1212 .u = {
1213 .bulk = {
1214 .buffersize = 4096,
1215 }
1216 }
1217 },
1218 }
1219 },
1220 .num_device_descs = 1,
1221 .devices = {
1222 {"TeVii S630 USB",
1223 {&dw2102_table[6], NULL},
1224 {NULL},
1225 },
1226 }
1227};
1228
1056static int dw2102_probe(struct usb_interface *intf, 1229static int dw2102_probe(struct usb_interface *intf,
1057 const struct usb_device_id *id) 1230 const struct usb_device_id *id)
1058{ 1231{
@@ -1061,6 +1234,8 @@ static int dw2102_probe(struct usb_interface *intf,
1061 0 == dvb_usb_device_init(intf, &dw2104_properties, 1234 0 == dvb_usb_device_init(intf, &dw2104_properties,
1062 THIS_MODULE, NULL, adapter_nr) || 1235 THIS_MODULE, NULL, adapter_nr) ||
1063 0 == dvb_usb_device_init(intf, &dw3101_properties, 1236 0 == dvb_usb_device_init(intf, &dw3101_properties,
1237 THIS_MODULE, NULL, adapter_nr) ||
1238 0 == dvb_usb_device_init(intf, &s630_properties,
1064 THIS_MODULE, NULL, adapter_nr)) { 1239 THIS_MODULE, NULL, adapter_nr)) {
1065 return 0; 1240 return 0;
1066 } 1241 }
@@ -1094,6 +1269,6 @@ module_exit(dw2102_module_exit);
1094MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); 1269MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
1095MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 1270MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
1096 " DVB-C 3101 USB2.0," 1271 " DVB-C 3101 USB2.0,"
1097 " TeVii S600, S650 USB2.0 devices"); 1272 " TeVii S600, S630, S650 USB2.0 devices");
1098MODULE_VERSION("0.1"); 1273MODULE_VERSION("0.1");
1099MODULE_LICENSE("GPL"); 1274MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 54626a0dbf68..aec7a1943b66 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -140,7 +140,7 @@ static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
140 goto unlock; 140 goto unlock;
141 141
142 for (i = 0; i < d->props.rc_key_map_size; i++) 142 for (i = 0; i < d->props.rc_key_map_size; i++)
143 if (d->props.rc_key_map[i].data == rc_state[1]) { 143 if (rc5_data(&d->props.rc_key_map[i]) == rc_state[1]) {
144 *event = d->props.rc_key_map[i].event; 144 *event = d->props.rc_key_map[i].event;
145 145
146 switch(rc_state[0]) { 146 switch(rc_state[0]) {
@@ -562,42 +562,42 @@ static struct m920x_inits tvwalkertwin_rc_init [] = {
562 562
563/* ir keymaps */ 563/* ir keymaps */
564static struct dvb_usb_rc_key megasky_rc_keys [] = { 564static struct dvb_usb_rc_key megasky_rc_keys [] = {
565 { 0x0, 0x12, KEY_POWER }, 565 { 0x0012, KEY_POWER },
566 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */ 566 { 0x001e, KEY_CYCLEWINDOWS }, /* min/max */
567 { 0x0, 0x02, KEY_CHANNELUP }, 567 { 0x0002, KEY_CHANNELUP },
568 { 0x0, 0x05, KEY_CHANNELDOWN }, 568 { 0x0005, KEY_CHANNELDOWN },
569 { 0x0, 0x03, KEY_VOLUMEUP }, 569 { 0x0003, KEY_VOLUMEUP },
570 { 0x0, 0x06, KEY_VOLUMEDOWN }, 570 { 0x0006, KEY_VOLUMEDOWN },
571 { 0x0, 0x04, KEY_MUTE }, 571 { 0x0004, KEY_MUTE },
572 { 0x0, 0x07, KEY_OK }, /* TS */ 572 { 0x0007, KEY_OK }, /* TS */
573 { 0x0, 0x08, KEY_STOP }, 573 { 0x0008, KEY_STOP },
574 { 0x0, 0x09, KEY_MENU }, /* swap */ 574 { 0x0009, KEY_MENU }, /* swap */
575 { 0x0, 0x0a, KEY_REWIND }, 575 { 0x000a, KEY_REWIND },
576 { 0x0, 0x1b, KEY_PAUSE }, 576 { 0x001b, KEY_PAUSE },
577 { 0x0, 0x1f, KEY_FASTFORWARD }, 577 { 0x001f, KEY_FASTFORWARD },
578 { 0x0, 0x0c, KEY_RECORD }, 578 { 0x000c, KEY_RECORD },
579 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */ 579 { 0x000d, KEY_CAMERA }, /* screenshot */
580 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */ 580 { 0x000e, KEY_COFFEE }, /* "MTS" */
581}; 581};
582 582
583static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = { 583static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
584 { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */ 584 { 0x0001, KEY_ZOOM }, /* Full Screen */
585 { 0x0, 0x02, KEY_CAMERA }, /* snapshot */ 585 { 0x0002, KEY_CAMERA }, /* snapshot */
586 { 0x0, 0x03, KEY_MUTE }, 586 { 0x0003, KEY_MUTE },
587 { 0x0, 0x04, KEY_REWIND }, 587 { 0x0004, KEY_REWIND },
588 { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */ 588 { 0x0005, KEY_PLAYPAUSE }, /* Play/Pause */
589 { 0x0, 0x06, KEY_FASTFORWARD }, 589 { 0x0006, KEY_FASTFORWARD },
590 { 0x0, 0x07, KEY_RECORD }, 590 { 0x0007, KEY_RECORD },
591 { 0x0, 0x08, KEY_STOP }, 591 { 0x0008, KEY_STOP },
592 { 0x0, 0x09, KEY_TIME }, /* Timeshift */ 592 { 0x0009, KEY_TIME }, /* Timeshift */
593 { 0x0, 0x0c, KEY_COFFEE }, /* Recall */ 593 { 0x000c, KEY_COFFEE }, /* Recall */
594 { 0x0, 0x0e, KEY_CHANNELUP }, 594 { 0x000e, KEY_CHANNELUP },
595 { 0x0, 0x12, KEY_POWER }, 595 { 0x0012, KEY_POWER },
596 { 0x0, 0x15, KEY_MENU }, /* source */ 596 { 0x0015, KEY_MENU }, /* source */
597 { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */ 597 { 0x0018, KEY_CYCLEWINDOWS }, /* TWIN PIP */
598 { 0x0, 0x1a, KEY_CHANNELDOWN }, 598 { 0x001a, KEY_CHANNELDOWN },
599 { 0x0, 0x1b, KEY_VOLUMEDOWN }, 599 { 0x001b, KEY_VOLUMEDOWN },
600 { 0x0, 0x1e, KEY_VOLUMEUP }, 600 { 0x001e, KEY_VOLUMEUP },
601}; 601};
602 602
603/* DVB USB Driver stuff */ 603/* DVB USB Driver stuff */
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index 07fb843c7c2b..b41d66ef8325 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -22,51 +22,51 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
22 22
23/* Hauppauge NOVA-T USB2 keys */ 23/* Hauppauge NOVA-T USB2 keys */
24static struct dvb_usb_rc_key haupp_rc_keys [] = { 24static struct dvb_usb_rc_key haupp_rc_keys [] = {
25 { 0x1e, 0x00, KEY_0 }, 25 { 0x1e00, KEY_0 },
26 { 0x1e, 0x01, KEY_1 }, 26 { 0x1e01, KEY_1 },
27 { 0x1e, 0x02, KEY_2 }, 27 { 0x1e02, KEY_2 },
28 { 0x1e, 0x03, KEY_3 }, 28 { 0x1e03, KEY_3 },
29 { 0x1e, 0x04, KEY_4 }, 29 { 0x1e04, KEY_4 },
30 { 0x1e, 0x05, KEY_5 }, 30 { 0x1e05, KEY_5 },
31 { 0x1e, 0x06, KEY_6 }, 31 { 0x1e06, KEY_6 },
32 { 0x1e, 0x07, KEY_7 }, 32 { 0x1e07, KEY_7 },
33 { 0x1e, 0x08, KEY_8 }, 33 { 0x1e08, KEY_8 },
34 { 0x1e, 0x09, KEY_9 }, 34 { 0x1e09, KEY_9 },
35 { 0x1e, 0x0a, KEY_KPASTERISK }, 35 { 0x1e0a, KEY_KPASTERISK },
36 { 0x1e, 0x0b, KEY_RED }, 36 { 0x1e0b, KEY_RED },
37 { 0x1e, 0x0c, KEY_RADIO }, 37 { 0x1e0c, KEY_RADIO },
38 { 0x1e, 0x0d, KEY_MENU }, 38 { 0x1e0d, KEY_MENU },
39 { 0x1e, 0x0e, KEY_GRAVE }, /* # */ 39 { 0x1e0e, KEY_GRAVE }, /* # */
40 { 0x1e, 0x0f, KEY_MUTE }, 40 { 0x1e0f, KEY_MUTE },
41 { 0x1e, 0x10, KEY_VOLUMEUP }, 41 { 0x1e10, KEY_VOLUMEUP },
42 { 0x1e, 0x11, KEY_VOLUMEDOWN }, 42 { 0x1e11, KEY_VOLUMEDOWN },
43 { 0x1e, 0x12, KEY_CHANNEL }, 43 { 0x1e12, KEY_CHANNEL },
44 { 0x1e, 0x14, KEY_UP }, 44 { 0x1e14, KEY_UP },
45 { 0x1e, 0x15, KEY_DOWN }, 45 { 0x1e15, KEY_DOWN },
46 { 0x1e, 0x16, KEY_LEFT }, 46 { 0x1e16, KEY_LEFT },
47 { 0x1e, 0x17, KEY_RIGHT }, 47 { 0x1e17, KEY_RIGHT },
48 { 0x1e, 0x18, KEY_VIDEO }, 48 { 0x1e18, KEY_VIDEO },
49 { 0x1e, 0x19, KEY_AUDIO }, 49 { 0x1e19, KEY_AUDIO },
50 { 0x1e, 0x1a, KEY_MEDIA }, 50 { 0x1e1a, KEY_MEDIA },
51 { 0x1e, 0x1b, KEY_EPG }, 51 { 0x1e1b, KEY_EPG },
52 { 0x1e, 0x1c, KEY_TV }, 52 { 0x1e1c, KEY_TV },
53 { 0x1e, 0x1e, KEY_NEXT }, 53 { 0x1e1e, KEY_NEXT },
54 { 0x1e, 0x1f, KEY_BACK }, 54 { 0x1e1f, KEY_BACK },
55 { 0x1e, 0x20, KEY_CHANNELUP }, 55 { 0x1e20, KEY_CHANNELUP },
56 { 0x1e, 0x21, KEY_CHANNELDOWN }, 56 { 0x1e21, KEY_CHANNELDOWN },
57 { 0x1e, 0x24, KEY_LAST }, /* Skip backwards */ 57 { 0x1e24, KEY_LAST }, /* Skip backwards */
58 { 0x1e, 0x25, KEY_OK }, 58 { 0x1e25, KEY_OK },
59 { 0x1e, 0x29, KEY_BLUE}, 59 { 0x1e29, KEY_BLUE},
60 { 0x1e, 0x2e, KEY_GREEN }, 60 { 0x1e2e, KEY_GREEN },
61 { 0x1e, 0x30, KEY_PAUSE }, 61 { 0x1e30, KEY_PAUSE },
62 { 0x1e, 0x32, KEY_REWIND }, 62 { 0x1e32, KEY_REWIND },
63 { 0x1e, 0x34, KEY_FASTFORWARD }, 63 { 0x1e34, KEY_FASTFORWARD },
64 { 0x1e, 0x35, KEY_PLAY }, 64 { 0x1e35, KEY_PLAY },
65 { 0x1e, 0x36, KEY_STOP }, 65 { 0x1e36, KEY_STOP },
66 { 0x1e, 0x37, KEY_RECORD }, 66 { 0x1e37, KEY_RECORD },
67 { 0x1e, 0x38, KEY_YELLOW }, 67 { 0x1e38, KEY_YELLOW },
68 { 0x1e, 0x3b, KEY_GOTO }, 68 { 0x1e3b, KEY_GOTO },
69 { 0x1e, 0x3d, KEY_POWER }, 69 { 0x1e3d, KEY_POWER },
70}; 70};
71 71
72/* Firmware bug? sometimes, when a new key is pressed, the previous pressed key 72/* Firmware bug? sometimes, when a new key is pressed, the previous pressed key
@@ -92,10 +92,11 @@ static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
92 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle); 92 deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle);
93 93
94 for (i = 0; i < ARRAY_SIZE(haupp_rc_keys); i++) { 94 for (i = 0; i < ARRAY_SIZE(haupp_rc_keys); i++) {
95 if (haupp_rc_keys[i].data == data && 95 if (rc5_data(&haupp_rc_keys[i]) == data &&
96 haupp_rc_keys[i].custom == custom) { 96 rc5_custom(&haupp_rc_keys[i]) == custom) {
97 97
98 deb_rc("c: %x, d: %x\n",haupp_rc_keys[i].data,haupp_rc_keys[i].custom); 98 deb_rc("c: %x, d: %x\n", rc5_data(&haupp_rc_keys[i]),
99 rc5_custom(&haupp_rc_keys[i]));
99 100
100 *event = haupp_rc_keys[i].event; 101 *event = haupp_rc_keys[i].event;
101 *state = REMOTE_KEY_PRESSED; 102 *state = REMOTE_KEY_PRESSED;
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c
index 7e32d11f32b0..d4e230941679 100644
--- a/drivers/media/dvb/dvb-usb/opera1.c
+++ b/drivers/media/dvb/dvb-usb/opera1.c
@@ -332,32 +332,32 @@ static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
332} 332}
333 333
334static struct dvb_usb_rc_key opera1_rc_keys[] = { 334static struct dvb_usb_rc_key opera1_rc_keys[] = {
335 {0x5f, 0xa0, KEY_1}, 335 {0x5fa0, KEY_1},
336 {0x51, 0xaf, KEY_2}, 336 {0x51af, KEY_2},
337 {0x5d, 0xa2, KEY_3}, 337 {0x5da2, KEY_3},
338 {0x41, 0xbe, KEY_4}, 338 {0x41be, KEY_4},
339 {0x0b, 0xf5, KEY_5}, 339 {0x0bf5, KEY_5},
340 {0x43, 0xbd, KEY_6}, 340 {0x43bd, KEY_6},
341 {0x47, 0xb8, KEY_7}, 341 {0x47b8, KEY_7},
342 {0x49, 0xb6, KEY_8}, 342 {0x49b6, KEY_8},
343 {0x05, 0xfa, KEY_9}, 343 {0x05fa, KEY_9},
344 {0x45, 0xba, KEY_0}, 344 {0x45ba, KEY_0},
345 {0x09, 0xf6, KEY_UP}, /*chanup */ 345 {0x09f6, KEY_UP}, /*chanup */
346 {0x1b, 0xe5, KEY_DOWN}, /*chandown */ 346 {0x1be5, KEY_DOWN}, /*chandown */
347 {0x5d, 0xa3, KEY_LEFT}, /*voldown */ 347 {0x5da3, KEY_LEFT}, /*voldown */
348 {0x5f, 0xa1, KEY_RIGHT}, /*volup */ 348 {0x5fa1, KEY_RIGHT}, /*volup */
349 {0x07, 0xf8, KEY_SPACE}, /*tab */ 349 {0x07f8, KEY_SPACE}, /*tab */
350 {0x1f, 0xe1, KEY_ENTER}, /*play ok */ 350 {0x1fe1, KEY_ENTER}, /*play ok */
351 {0x1b, 0xe4, KEY_Z}, /*zoom */ 351 {0x1be4, KEY_Z}, /*zoom */
352 {0x59, 0xa6, KEY_M}, /*mute */ 352 {0x59a6, KEY_M}, /*mute */
353 {0x5b, 0xa5, KEY_F}, /*tv/f */ 353 {0x5ba5, KEY_F}, /*tv/f */
354 {0x19, 0xe7, KEY_R}, /*rec */ 354 {0x19e7, KEY_R}, /*rec */
355 {0x01, 0xfe, KEY_S}, /*Stop */ 355 {0x01fe, KEY_S}, /*Stop */
356 {0x03, 0xfd, KEY_P}, /*pause */ 356 {0x03fd, KEY_P}, /*pause */
357 {0x03, 0xfc, KEY_W}, /*<- -> */ 357 {0x03fc, KEY_W}, /*<- -> */
358 {0x07, 0xf9, KEY_C}, /*capture */ 358 {0x07f9, KEY_C}, /*capture */
359 {0x47, 0xb9, KEY_Q}, /*exit */ 359 {0x47b9, KEY_Q}, /*exit */
360 {0x43, 0xbc, KEY_O}, /*power */ 360 {0x43bc, KEY_O}, /*power */
361 361
362}; 362};
363 363
@@ -405,8 +405,7 @@ static int opera1_rc_query(struct dvb_usb_device *dev, u32 * event, int *state)
405 send_key = (send_key & 0xffff) | 0x0100; 405 send_key = (send_key & 0xffff) | 0x0100;
406 406
407 for (i = 0; i < ARRAY_SIZE(opera1_rc_keys); i++) { 407 for (i = 0; i < ARRAY_SIZE(opera1_rc_keys); i++) {
408 if ((opera1_rc_keys[i].custom * 256 + 408 if (rc5_scan(&opera1_rc_keys[i]) == (send_key & 0xffff)) {
409 opera1_rc_keys[i].data) == (send_key & 0xffff)) {
410 *state = REMOTE_KEY_PRESSED; 409 *state = REMOTE_KEY_PRESSED;
411 *event = opera1_rc_keys[i].event; 410 *event = opera1_rc_keys[i].event;
412 opst->last_key_pressed = 411 opst->last_key_pressed =
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index 986fff9a5ba8..ef4e37d9c5ff 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -175,8 +175,8 @@ static int vp702x_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
175 175
176/* keys for the enclosed remote control */ 176/* keys for the enclosed remote control */
177static struct dvb_usb_rc_key vp702x_rc_keys[] = { 177static struct dvb_usb_rc_key vp702x_rc_keys[] = {
178 { 0x00, 0x01, KEY_1 }, 178 { 0x0001, KEY_1 },
179 { 0x00, 0x02, KEY_2 }, 179 { 0x0002, KEY_2 },
180}; 180};
181 181
182/* remote control stuff (does not work with my box) */ 182/* remote control stuff (does not work with my box) */
@@ -198,7 +198,7 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
198 } 198 }
199 199
200 for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++) 200 for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++)
201 if (vp702x_rc_keys[i].custom == key[1]) { 201 if (rc5_custom(&vp702x_rc_keys[i]) == key[1]) {
202 *state = REMOTE_KEY_PRESSED; 202 *state = REMOTE_KEY_PRESSED;
203 *event = vp702x_rc_keys[i].event; 203 *event = vp702x_rc_keys[i].event;
204 break; 204 break;
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index acb345504e0d..a59faa27912a 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -100,56 +100,56 @@ static int vp7045_power_ctrl(struct dvb_usb_device *d, int onoff)
100/* The keymapping struct. Somehow this should be loaded to the driver, but 100/* The keymapping struct. Somehow this should be loaded to the driver, but
101 * currently it is hardcoded. */ 101 * currently it is hardcoded. */
102static struct dvb_usb_rc_key vp7045_rc_keys[] = { 102static struct dvb_usb_rc_key vp7045_rc_keys[] = {
103 { 0x00, 0x16, KEY_POWER }, 103 { 0x0016, KEY_POWER },
104 { 0x00, 0x10, KEY_MUTE }, 104 { 0x0010, KEY_MUTE },
105 { 0x00, 0x03, KEY_1 }, 105 { 0x0003, KEY_1 },
106 { 0x00, 0x01, KEY_2 }, 106 { 0x0001, KEY_2 },
107 { 0x00, 0x06, KEY_3 }, 107 { 0x0006, KEY_3 },
108 { 0x00, 0x09, KEY_4 }, 108 { 0x0009, KEY_4 },
109 { 0x00, 0x1d, KEY_5 }, 109 { 0x001d, KEY_5 },
110 { 0x00, 0x1f, KEY_6 }, 110 { 0x001f, KEY_6 },
111 { 0x00, 0x0d, KEY_7 }, 111 { 0x000d, KEY_7 },
112 { 0x00, 0x19, KEY_8 }, 112 { 0x0019, KEY_8 },
113 { 0x00, 0x1b, KEY_9 }, 113 { 0x001b, KEY_9 },
114 { 0x00, 0x15, KEY_0 }, 114 { 0x0015, KEY_0 },
115 { 0x00, 0x05, KEY_CHANNELUP }, 115 { 0x0005, KEY_CHANNELUP },
116 { 0x00, 0x02, KEY_CHANNELDOWN }, 116 { 0x0002, KEY_CHANNELDOWN },
117 { 0x00, 0x1e, KEY_VOLUMEUP }, 117 { 0x001e, KEY_VOLUMEUP },
118 { 0x00, 0x0a, KEY_VOLUMEDOWN }, 118 { 0x000a, KEY_VOLUMEDOWN },
119 { 0x00, 0x11, KEY_RECORD }, 119 { 0x0011, KEY_RECORD },
120 { 0x00, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */ 120 { 0x0017, KEY_FAVORITES }, /* Heart symbol - Channel list. */
121 { 0x00, 0x14, KEY_PLAY }, 121 { 0x0014, KEY_PLAY },
122 { 0x00, 0x1a, KEY_STOP }, 122 { 0x001a, KEY_STOP },
123 { 0x00, 0x40, KEY_REWIND }, 123 { 0x0040, KEY_REWIND },
124 { 0x00, 0x12, KEY_FASTFORWARD }, 124 { 0x0012, KEY_FASTFORWARD },
125 { 0x00, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */ 125 { 0x000e, KEY_PREVIOUS }, /* Recall - Previous channel. */
126 { 0x00, 0x4c, KEY_PAUSE }, 126 { 0x004c, KEY_PAUSE },
127 { 0x00, 0x4d, KEY_SCREEN }, /* Full screen mode. */ 127 { 0x004d, KEY_SCREEN }, /* Full screen mode. */
128 { 0x00, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */ 128 { 0x0054, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
129 { 0x00, 0x0c, KEY_CANCEL }, /* Cancel */ 129 { 0x000c, KEY_CANCEL }, /* Cancel */
130 { 0x00, 0x1c, KEY_EPG }, /* EPG */ 130 { 0x001c, KEY_EPG }, /* EPG */
131 { 0x00, 0x00, KEY_TAB }, /* Tab */ 131 { 0x0000, KEY_TAB }, /* Tab */
132 { 0x00, 0x48, KEY_INFO }, /* Preview */ 132 { 0x0048, KEY_INFO }, /* Preview */
133 { 0x00, 0x04, KEY_LIST }, /* RecordList */ 133 { 0x0004, KEY_LIST }, /* RecordList */
134 { 0x00, 0x0f, KEY_TEXT }, /* Teletext */ 134 { 0x000f, KEY_TEXT }, /* Teletext */
135 { 0x00, 0x41, KEY_PREVIOUSSONG }, 135 { 0x0041, KEY_PREVIOUSSONG },
136 { 0x00, 0x42, KEY_NEXTSONG }, 136 { 0x0042, KEY_NEXTSONG },
137 { 0x00, 0x4b, KEY_UP }, 137 { 0x004b, KEY_UP },
138 { 0x00, 0x51, KEY_DOWN }, 138 { 0x0051, KEY_DOWN },
139 { 0x00, 0x4e, KEY_LEFT }, 139 { 0x004e, KEY_LEFT },
140 { 0x00, 0x52, KEY_RIGHT }, 140 { 0x0052, KEY_RIGHT },
141 { 0x00, 0x4f, KEY_ENTER }, 141 { 0x004f, KEY_ENTER },
142 { 0x00, 0x13, KEY_CANCEL }, 142 { 0x0013, KEY_CANCEL },
143 { 0x00, 0x4a, KEY_CLEAR }, 143 { 0x004a, KEY_CLEAR },
144 { 0x00, 0x54, KEY_PRINT }, /* Capture */ 144 { 0x0054, KEY_PRINT }, /* Capture */
145 { 0x00, 0x43, KEY_SUBTITLE }, /* Subtitle/CC */ 145 { 0x0043, KEY_SUBTITLE }, /* Subtitle/CC */
146 { 0x00, 0x08, KEY_VIDEO }, /* A/V */ 146 { 0x0008, KEY_VIDEO }, /* A/V */
147 { 0x00, 0x07, KEY_SLEEP }, /* Hibernate */ 147 { 0x0007, KEY_SLEEP }, /* Hibernate */
148 { 0x00, 0x45, KEY_ZOOM }, /* Zoom+ */ 148 { 0x0045, KEY_ZOOM }, /* Zoom+ */
149 { 0x00, 0x18, KEY_RED}, 149 { 0x0018, KEY_RED},
150 { 0x00, 0x53, KEY_GREEN}, 150 { 0x0053, KEY_GREEN},
151 { 0x00, 0x5e, KEY_YELLOW}, 151 { 0x005e, KEY_YELLOW},
152 { 0x00, 0x5f, KEY_BLUE} 152 { 0x005f, KEY_BLUE}
153}; 153};
154 154
155static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 155static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
@@ -166,7 +166,7 @@ static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
166 } 166 }
167 167
168 for (i = 0; i < ARRAY_SIZE(vp7045_rc_keys); i++) 168 for (i = 0; i < ARRAY_SIZE(vp7045_rc_keys); i++)
169 if (vp7045_rc_keys[i].data == key) { 169 if (rc5_data(&vp7045_rc_keys[i]) == key) {
170 *state = REMOTE_KEY_PRESSED; 170 *state = REMOTE_KEY_PRESSED;
171 *event = vp7045_rc_keys[i].event; 171 *event = vp7045_rc_keys[i].event;
172 break; 172 break;
diff --git a/drivers/media/dvb/firewire/firedtv-avc.c b/drivers/media/dvb/firewire/firedtv-avc.c
index 32526f103b59..d1b67fe0f011 100644
--- a/drivers/media/dvb/firewire/firedtv-avc.c
+++ b/drivers/media/dvb/firewire/firedtv-avc.c
@@ -89,15 +89,33 @@ struct avc_response_frame {
89 u8 operand[509]; 89 u8 operand[509];
90}; 90};
91 91
92#define AVC_DEBUG_FCP_SUBACTIONS 1 92#define AVC_DEBUG_READ_DESCRIPTOR 0x0001
93#define AVC_DEBUG_FCP_PAYLOADS 2 93#define AVC_DEBUG_DSIT 0x0002
94#define AVC_DEBUG_DSD 0x0004
95#define AVC_DEBUG_REGISTER_REMOTE_CONTROL 0x0008
96#define AVC_DEBUG_LNB_CONTROL 0x0010
97#define AVC_DEBUG_TUNE_QPSK 0x0020
98#define AVC_DEBUG_TUNE_QPSK2 0x0040
99#define AVC_DEBUG_HOST2CA 0x0080
100#define AVC_DEBUG_CA2HOST 0x0100
101#define AVC_DEBUG_APPLICATION_PMT 0x4000
102#define AVC_DEBUG_FCP_PAYLOADS 0x8000
94 103
95static int avc_debug; 104static int avc_debug;
96module_param_named(debug, avc_debug, int, 0644); 105module_param_named(debug, avc_debug, int, 0644);
97MODULE_PARM_DESC(debug, "Verbose logging (default = 0" 106MODULE_PARM_DESC(debug, "Verbose logging (none = 0"
98 ", FCP subactions = " __stringify(AVC_DEBUG_FCP_SUBACTIONS) 107 ", FCP subactions"
99 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS) 108 ": READ DESCRIPTOR = " __stringify(AVC_DEBUG_READ_DESCRIPTOR)
100 ", or all = -1)"); 109 ", DSIT = " __stringify(AVC_DEBUG_DSIT)
110 ", REGISTER_REMOTE_CONTROL = " __stringify(AVC_DEBUG_REGISTER_REMOTE_CONTROL)
111 ", LNB CONTROL = " __stringify(AVC_DEBUG_LNB_CONTROL)
112 ", TUNE QPSK = " __stringify(AVC_DEBUG_TUNE_QPSK)
113 ", TUNE QPSK2 = " __stringify(AVC_DEBUG_TUNE_QPSK2)
114 ", HOST2CA = " __stringify(AVC_DEBUG_HOST2CA)
115 ", CA2HOST = " __stringify(AVC_DEBUG_CA2HOST)
116 "; Application sent PMT = " __stringify(AVC_DEBUG_APPLICATION_PMT)
117 ", FCP payloads = " __stringify(AVC_DEBUG_FCP_PAYLOADS)
118 ", or a combination, or all = -1)");
101 119
102static const char *debug_fcp_ctype(unsigned int ctype) 120static const char *debug_fcp_ctype(unsigned int ctype)
103{ 121{
@@ -118,48 +136,70 @@ static const char *debug_fcp_opcode(unsigned int opcode,
118 const u8 *data, int length) 136 const u8 *data, int length)
119{ 137{
120 switch (opcode) { 138 switch (opcode) {
121 case AVC_OPCODE_VENDOR: break; 139 case AVC_OPCODE_VENDOR:
122 case AVC_OPCODE_READ_DESCRIPTOR: return "ReadDescriptor"; 140 break;
123 case AVC_OPCODE_DSIT: return "DirectSelectInfo.Type"; 141 case AVC_OPCODE_READ_DESCRIPTOR:
124 case AVC_OPCODE_DSD: return "DirectSelectData"; 142 return avc_debug & AVC_DEBUG_READ_DESCRIPTOR ?
125 default: return "?"; 143 "ReadDescriptor" : NULL;
144 case AVC_OPCODE_DSIT:
145 return avc_debug & AVC_DEBUG_DSIT ?
146 "DirectSelectInfo.Type" : NULL;
147 case AVC_OPCODE_DSD:
148 return avc_debug & AVC_DEBUG_DSD ? "DirectSelectData" : NULL;
149 default:
150 return "Unknown";
126 } 151 }
127 152
128 if (length < 7 || 153 if (length < 7 ||
129 data[3] != SFE_VENDOR_DE_COMPANYID_0 || 154 data[3] != SFE_VENDOR_DE_COMPANYID_0 ||
130 data[4] != SFE_VENDOR_DE_COMPANYID_1 || 155 data[4] != SFE_VENDOR_DE_COMPANYID_1 ||
131 data[5] != SFE_VENDOR_DE_COMPANYID_2) 156 data[5] != SFE_VENDOR_DE_COMPANYID_2)
132 return "Vendor"; 157 return "Vendor/Unknown";
133 158
134 switch (data[6]) { 159 switch (data[6]) {
135 case SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL: return "RegisterRC"; 160 case SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL:
136 case SFE_VENDOR_OPCODE_LNB_CONTROL: return "LNBControl"; 161 return avc_debug & AVC_DEBUG_REGISTER_REMOTE_CONTROL ?
137 case SFE_VENDOR_OPCODE_TUNE_QPSK: return "TuneQPSK"; 162 "RegisterRC" : NULL;
138 case SFE_VENDOR_OPCODE_TUNE_QPSK2: return "TuneQPSK2"; 163 case SFE_VENDOR_OPCODE_LNB_CONTROL:
139 case SFE_VENDOR_OPCODE_HOST2CA: return "Host2CA"; 164 return avc_debug & AVC_DEBUG_LNB_CONTROL ? "LNBControl" : NULL;
140 case SFE_VENDOR_OPCODE_CA2HOST: return "CA2Host"; 165 case SFE_VENDOR_OPCODE_TUNE_QPSK:
166 return avc_debug & AVC_DEBUG_TUNE_QPSK ? "TuneQPSK" : NULL;
167 case SFE_VENDOR_OPCODE_TUNE_QPSK2:
168 return avc_debug & AVC_DEBUG_TUNE_QPSK2 ? "TuneQPSK2" : NULL;
169 case SFE_VENDOR_OPCODE_HOST2CA:
170 return avc_debug & AVC_DEBUG_HOST2CA ? "Host2CA" : NULL;
171 case SFE_VENDOR_OPCODE_CA2HOST:
172 return avc_debug & AVC_DEBUG_CA2HOST ? "CA2Host" : NULL;
141 } 173 }
142 return "Vendor"; 174 return "Vendor/Unknown";
143} 175}
144 176
145static void debug_fcp(const u8 *data, int length) 177static void debug_fcp(const u8 *data, int length)
146{ 178{
147 unsigned int subunit_type, subunit_id, op; 179 unsigned int subunit_type, subunit_id, opcode;
148 const char *prefix = data[0] > 7 ? "FCP <- " : "FCP -> "; 180 const char *op, *prefix;
181
182 prefix = data[0] > 7 ? "FCP <- " : "FCP -> ";
183 subunit_type = data[1] >> 3;
184 subunit_id = data[1] & 7;
185 opcode = subunit_type == 0x1e || subunit_id == 5 ? ~0 : data[2];
186 op = debug_fcp_opcode(opcode, data, length);
149 187
150 if (avc_debug & AVC_DEBUG_FCP_SUBACTIONS) { 188 if (op) {
151 subunit_type = data[1] >> 3;
152 subunit_id = data[1] & 7;
153 op = subunit_type == 0x1e || subunit_id == 5 ? ~0 : data[2];
154 printk(KERN_INFO "%ssu=%x.%x l=%d: %-8s - %s\n", 189 printk(KERN_INFO "%ssu=%x.%x l=%d: %-8s - %s\n",
155 prefix, subunit_type, subunit_id, length, 190 prefix, subunit_type, subunit_id, length,
156 debug_fcp_ctype(data[0]), 191 debug_fcp_ctype(data[0]), op);
157 debug_fcp_opcode(op, data, length)); 192 if (avc_debug & AVC_DEBUG_FCP_PAYLOADS)
193 print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_NONE,
194 16, 1, data, length, false);
158 } 195 }
196}
159 197
160 if (avc_debug & AVC_DEBUG_FCP_PAYLOADS) 198static void debug_pmt(char *msg, int length)
161 print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_NONE, 16, 1, 199{
162 data, length, false); 200 printk(KERN_INFO "APP PMT -> l=%d\n", length);
201 print_hex_dump(KERN_INFO, "APP PMT -> ", DUMP_PREFIX_NONE,
202 16, 1, msg, length, false);
163} 203}
164 204
165static int __avc_write(struct firedtv *fdtv, 205static int __avc_write(struct firedtv *fdtv,
@@ -254,6 +294,26 @@ int avc_recv(struct firedtv *fdtv, void *data, size_t length)
254 return 0; 294 return 0;
255} 295}
256 296
297static int add_pid_filter(struct firedtv *fdtv, u8 *operand)
298{
299 int i, n, pos = 1;
300
301 for (i = 0, n = 0; i < 16; i++) {
302 if (test_bit(i, &fdtv->channel_active)) {
303 operand[pos++] = 0x13; /* flowfunction relay */
304 operand[pos++] = 0x80; /* dsd_sel_spec_valid_flags -> PID */
305 operand[pos++] = (fdtv->channel_pid[i] >> 8) & 0x1f;
306 operand[pos++] = fdtv->channel_pid[i] & 0xff;
307 operand[pos++] = 0x00; /* tableID */
308 operand[pos++] = 0x00; /* filter_length */
309 n++;
310 }
311 }
312 operand[0] = n;
313
314 return pos;
315}
316
257/* 317/*
258 * tuning command for setting the relative LNB frequency 318 * tuning command for setting the relative LNB frequency
259 * (not supported by the AVC standard) 319 * (not supported by the AVC standard)
@@ -316,7 +376,8 @@ static void avc_tuner_tuneqpsk(struct firedtv *fdtv,
316 } 376 }
317} 377}
318 378
319static void avc_tuner_dsd_dvb_c(struct dvb_frontend_parameters *params, 379static void avc_tuner_dsd_dvb_c(struct firedtv *fdtv,
380 struct dvb_frontend_parameters *params,
320 struct avc_command_frame *c) 381 struct avc_command_frame *c)
321{ 382{
322 c->opcode = AVC_OPCODE_DSD; 383 c->opcode = AVC_OPCODE_DSD;
@@ -378,13 +439,13 @@ static void avc_tuner_dsd_dvb_c(struct dvb_frontend_parameters *params,
378 439
379 c->operand[20] = 0x00; 440 c->operand[20] = 0x00;
380 c->operand[21] = 0x00; 441 c->operand[21] = 0x00;
381 /* Nr_of_dsd_sel_specs = 0 -> no PIDs are transmitted */
382 c->operand[22] = 0x00;
383 442
384 c->length = 28; 443 /* Add PIDs to filter */
444 c->length = ALIGN(22 + add_pid_filter(fdtv, &c->operand[22]) + 3, 4);
385} 445}
386 446
387static void avc_tuner_dsd_dvb_t(struct dvb_frontend_parameters *params, 447static void avc_tuner_dsd_dvb_t(struct firedtv *fdtv,
448 struct dvb_frontend_parameters *params,
388 struct avc_command_frame *c) 449 struct avc_command_frame *c)
389{ 450{
390 struct dvb_ofdm_parameters *ofdm = &params->u.ofdm; 451 struct dvb_ofdm_parameters *ofdm = &params->u.ofdm;
@@ -481,10 +542,9 @@ static void avc_tuner_dsd_dvb_t(struct dvb_frontend_parameters *params,
481 542
482 c->operand[15] = 0x00; /* network_ID[0] */ 543 c->operand[15] = 0x00; /* network_ID[0] */
483 c->operand[16] = 0x00; /* network_ID[1] */ 544 c->operand[16] = 0x00; /* network_ID[1] */
484 /* Nr_of_dsd_sel_specs = 0 -> no PIDs are transmitted */
485 c->operand[17] = 0x00;
486 545
487 c->length = 24; 546 /* Add PIDs to filter */
547 c->length = ALIGN(17 + add_pid_filter(fdtv, &c->operand[17]) + 3, 4);
488} 548}
489 549
490int avc_tuner_dsd(struct firedtv *fdtv, 550int avc_tuner_dsd(struct firedtv *fdtv,
@@ -502,8 +562,8 @@ int avc_tuner_dsd(struct firedtv *fdtv,
502 switch (fdtv->type) { 562 switch (fdtv->type) {
503 case FIREDTV_DVB_S: 563 case FIREDTV_DVB_S:
504 case FIREDTV_DVB_S2: avc_tuner_tuneqpsk(fdtv, params, c); break; 564 case FIREDTV_DVB_S2: avc_tuner_tuneqpsk(fdtv, params, c); break;
505 case FIREDTV_DVB_C: avc_tuner_dsd_dvb_c(params, c); break; 565 case FIREDTV_DVB_C: avc_tuner_dsd_dvb_c(fdtv, params, c); break;
506 case FIREDTV_DVB_T: avc_tuner_dsd_dvb_t(params, c); break; 566 case FIREDTV_DVB_T: avc_tuner_dsd_dvb_t(fdtv, params, c); break;
507 default: 567 default:
508 BUG(); 568 BUG();
509 } 569 }
@@ -963,6 +1023,9 @@ int avc_ca_pmt(struct firedtv *fdtv, char *msg, int length)
963 int es_info_length; 1023 int es_info_length;
964 int crc32_csum; 1024 int crc32_csum;
965 1025
1026 if (unlikely(avc_debug & AVC_DEBUG_APPLICATION_PMT))
1027 debug_pmt(msg, length);
1028
966 memset(c, 0, sizeof(*c)); 1029 memset(c, 0, sizeof(*c));
967 1030
968 c->ctype = AVC_CTYPE_CONTROL; 1031 c->ctype = AVC_CTYPE_CONTROL;
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index be967ac09a39..b794e860b4e2 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -81,6 +81,13 @@ config DVB_ZL10036
81 help 81 help
82 A DVB-S tuner module. Say Y when you want to support this frontend. 82 A DVB-S tuner module. Say Y when you want to support this frontend.
83 83
84config DVB_ZL10039
85 tristate "Zarlink ZL10039 silicon tuner"
86 depends on DVB_CORE && I2C
87 default m if DVB_FE_CUSTOMISE
88 help
89 A DVB-S tuner module. Say Y when you want to support this frontend.
90
84config DVB_S5H1420 91config DVB_S5H1420
85 tristate "Samsung S5H1420 based" 92 tristate "Samsung S5H1420 based"
86 depends on DVB_CORE && I2C 93 depends on DVB_CORE && I2C
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
index 832473c1e512..3b49d37ab5fa 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_DVB_SP887X) += sp887x.o
31obj-$(CONFIG_DVB_NXT6000) += nxt6000.o 31obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
32obj-$(CONFIG_DVB_MT352) += mt352.o 32obj-$(CONFIG_DVB_MT352) += mt352.o
33obj-$(CONFIG_DVB_ZL10036) += zl10036.o 33obj-$(CONFIG_DVB_ZL10036) += zl10036.o
34obj-$(CONFIG_DVB_ZL10039) += zl10039.o
34obj-$(CONFIG_DVB_ZL10353) += zl10353.o 35obj-$(CONFIG_DVB_ZL10353) += zl10353.o
35obj-$(CONFIG_DVB_CX22702) += cx22702.o 36obj-$(CONFIG_DVB_CX22702) += cx22702.o
36obj-$(CONFIG_DVB_DRX397XD) += drx397xD.o 37obj-$(CONFIG_DVB_DRX397XD) += drx397xD.o
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
index fbd838eca268..5fbc0fc37ecd 100644
--- a/drivers/media/dvb/frontends/cx22700.c
+++ b/drivers/media/dvb/frontends/cx22700.c
@@ -155,7 +155,7 @@ static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_paramet
155 p->hierarchy_information > HIERARCHY_4) 155 p->hierarchy_information > HIERARCHY_4)
156 return -EINVAL; 156 return -EINVAL;
157 157
158 if (p->bandwidth < BANDWIDTH_8_MHZ && p->bandwidth > BANDWIDTH_6_MHZ) 158 if (p->bandwidth < BANDWIDTH_8_MHZ || p->bandwidth > BANDWIDTH_6_MHZ)
159 return -EINVAL; 159 return -EINVAL;
160 160
161 if (p->bandwidth == BANDWIDTH_7_MHZ) 161 if (p->bandwidth == BANDWIDTH_7_MHZ)
diff --git a/drivers/media/dvb/frontends/cx24113.c b/drivers/media/dvb/frontends/cx24113.c
index e4fd533a427c..075b2b57cf09 100644
--- a/drivers/media/dvb/frontends/cx24113.c
+++ b/drivers/media/dvb/frontends/cx24113.c
@@ -303,6 +303,7 @@ static void cx24113_calc_pll_nf(struct cx24113_state *state, u16 *n, s32 *f)
303{ 303{
304 s32 N; 304 s32 N;
305 s64 F; 305 s64 F;
306 u64 dividend;
306 u8 R, r; 307 u8 R, r;
307 u8 vcodiv; 308 u8 vcodiv;
308 u8 factor; 309 u8 factor;
@@ -346,7 +347,10 @@ static void cx24113_calc_pll_nf(struct cx24113_state *state, u16 *n, s32 *f)
346 F = freq_hz; 347 F = freq_hz;
347 F *= (u64) (R * vcodiv * 262144); 348 F *= (u64) (R * vcodiv * 262144);
348 dprintk("1 N: %d, F: %lld, R: %d\n", N, (long long)F, R); 349 dprintk("1 N: %d, F: %lld, R: %d\n", N, (long long)F, R);
349 do_div(F, state->config->xtal_khz*1000 * factor * 2); 350 /* do_div needs an u64 as first argument */
351 dividend = F;
352 do_div(dividend, state->config->xtal_khz * 1000 * factor * 2);
353 F = dividend;
350 dprintk("2 N: %d, F: %lld, R: %d\n", N, (long long)F, R); 354 dprintk("2 N: %d, F: %lld, R: %d\n", N, (long long)F, R);
351 F -= (N + 32) * 262144; 355 F -= (N + 32) * 262144;
352 356
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index 0592f043ea64..d8f921b6fafd 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -458,7 +458,7 @@ static int cx24123_set_symbolrate(struct cx24123_state *state, u32 srate)
458 /* check if symbol rate is within limits */ 458 /* check if symbol rate is within limits */
459 if ((srate > state->frontend.ops.info.symbol_rate_max) || 459 if ((srate > state->frontend.ops.info.symbol_rate_max) ||
460 (srate < state->frontend.ops.info.symbol_rate_min)) 460 (srate < state->frontend.ops.info.symbol_rate_min))
461 return -EOPNOTSUPP;; 461 return -EOPNOTSUPP;
462 462
463 /* choose the sampling rate high enough for the required operation, 463 /* choose the sampling rate high enough for the required operation,
464 while optimizing the power consumed by the demodulator */ 464 while optimizing the power consumed by the demodulator */
diff --git a/drivers/media/dvb/frontends/dib0070.c b/drivers/media/dvb/frontends/dib0070.c
index fe895bf7b18f..da92cbe1b8ea 100644
--- a/drivers/media/dvb/frontends/dib0070.c
+++ b/drivers/media/dvb/frontends/dib0070.c
@@ -167,7 +167,7 @@ static int dib0070_tune_digital(struct dvb_frontend *fe, struct dvb_frontend_par
167 break; 167 break;
168 case BAND_SBAND: 168 case BAND_SBAND:
169 LO4_SET_VCO_HFDIV(lo4, 0, 0); 169 LO4_SET_VCO_HFDIV(lo4, 0, 0);
170 LO4_SET_CTRIM(lo4, 1);; 170 LO4_SET_CTRIM(lo4, 1);
171 c = 1; 171 c = 1;
172 break; 172 break;
173 case BAND_UHF: 173 case BAND_UHF:
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
index 8217e5b38f47..fc96fbf03d6d 100644
--- a/drivers/media/dvb/frontends/dib7000p.c
+++ b/drivers/media/dvb/frontends/dib7000p.c
@@ -883,7 +883,7 @@ static void dib7000p_spur_protect(struct dib7000p_state *state, u32 rf_khz, u32
883 255, 255, 255, 255, 255, 255}; 883 255, 255, 255, 255, 255, 255};
884 884
885 u32 xtal = state->cfg.bw->xtal_hz / 1000; 885 u32 xtal = state->cfg.bw->xtal_hz / 1000;
886 int f_rel = ( (rf_khz + xtal/2) / xtal) * xtal - rf_khz; 886 int f_rel = DIV_ROUND_CLOSEST(rf_khz, xtal) * xtal - rf_khz;
887 int k; 887 int k;
888 int coef_re[8],coef_im[8]; 888 int coef_re[8],coef_im[8];
889 int bw_khz = bw; 889 int bw_khz = bw;
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 9f6349964cda..6d865d6161d7 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -389,6 +389,77 @@ static struct dvb_pll_desc dvb_pll_samsung_dtos403ih102a = {
389 } 389 }
390}; 390};
391 391
392/* Samsung TDTC9251DH0 DVB-T NIM, as used on AirStar 2 */
393static struct dvb_pll_desc dvb_pll_samsung_tdtc9251dh0 = {
394 .name = "Samsung TDTC9251DH0",
395 .min = 48000000,
396 .max = 863000000,
397 .iffreq = 36166667,
398 .count = 3,
399 .entries = {
400 { 157500000, 166667, 0xcc, 0x09 },
401 { 443000000, 166667, 0xcc, 0x0a },
402 { 863000000, 166667, 0xcc, 0x08 },
403 }
404};
405
406/* Samsung TBDU18132 DVB-S NIM with TSA5059 PLL, used in SkyStar2 DVB-S 2.3 */
407static struct dvb_pll_desc dvb_pll_samsung_tbdu18132 = {
408 .name = "Samsung TBDU18132",
409 .min = 950000,
410 .max = 2150000, /* guesses */
411 .iffreq = 0,
412 .count = 2,
413 .entries = {
414 { 1550000, 125, 0x84, 0x82 },
415 { 4095937, 125, 0x84, 0x80 },
416 }
417 /* TSA5059 PLL has a 17 bit divisor rather than the 15 bits supported
418 * by this driver. The two extra bits are 0x60 in the third byte. 15
419 * bits is enough for over 4 GHz, which is enough to cover the range
420 * of this tuner. We could use the additional divisor bits by adding
421 * more entries, e.g.
422 { 0x0ffff * 125 + 125/2, 125, 0x84 | 0x20, },
423 { 0x17fff * 125 + 125/2, 125, 0x84 | 0x40, },
424 { 0x1ffff * 125 + 125/2, 125, 0x84 | 0x60, }, */
425};
426
427/* Samsung TBMU24112 DVB-S NIM with SL1935 zero-IF tuner */
428static struct dvb_pll_desc dvb_pll_samsung_tbmu24112 = {
429 .name = "Samsung TBMU24112",
430 .min = 950000,
431 .max = 2150000, /* guesses */
432 .iffreq = 0,
433 .count = 2,
434 .entries = {
435 { 1500000, 125, 0x84, 0x18 },
436 { 9999999, 125, 0x84, 0x08 },
437 }
438};
439
440/* Alps TDEE4 DVB-C NIM, used on Cablestar 2 */
441/* byte 4 : 1 * * AGD R3 R2 R1 R0
442 * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
443 * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95
444 * Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
445 * 47 - 153 0 * 0 0 0 0 0 1 0x01
446 * 153 - 430 0 * 0 0 0 0 1 0 0x02
447 * 430 - 822 0 * 0 0 1 0 0 0 0x08
448 * 822 - 862 1 * 0 0 1 0 0 0 0x88 */
449static struct dvb_pll_desc dvb_pll_alps_tdee4 = {
450 .name = "ALPS TDEE4",
451 .min = 47000000,
452 .max = 862000000,
453 .iffreq = 36125000,
454 .count = 4,
455 .entries = {
456 { 153000000, 62500, 0x95, 0x01 },
457 { 430000000, 62500, 0x95, 0x02 },
458 { 822000000, 62500, 0x95, 0x08 },
459 { 999999999, 62500, 0x95, 0x88 },
460 }
461};
462
392/* ----------------------------------------------------------- */ 463/* ----------------------------------------------------------- */
393 464
394static struct dvb_pll_desc *pll_list[] = { 465static struct dvb_pll_desc *pll_list[] = {
@@ -402,11 +473,15 @@ static struct dvb_pll_desc *pll_list[] = {
402 [DVB_PLL_TUA6034] = &dvb_pll_tua6034, 473 [DVB_PLL_TUA6034] = &dvb_pll_tua6034,
403 [DVB_PLL_TDA665X] = &dvb_pll_tda665x, 474 [DVB_PLL_TDA665X] = &dvb_pll_tda665x,
404 [DVB_PLL_TDED4] = &dvb_pll_tded4, 475 [DVB_PLL_TDED4] = &dvb_pll_tded4,
476 [DVB_PLL_TDEE4] = &dvb_pll_alps_tdee4,
405 [DVB_PLL_TDHU2] = &dvb_pll_tdhu2, 477 [DVB_PLL_TDHU2] = &dvb_pll_tdhu2,
406 [DVB_PLL_SAMSUNG_TBMV] = &dvb_pll_samsung_tbmv, 478 [DVB_PLL_SAMSUNG_TBMV] = &dvb_pll_samsung_tbmv,
407 [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261, 479 [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261,
408 [DVB_PLL_OPERA1] = &dvb_pll_opera1, 480 [DVB_PLL_OPERA1] = &dvb_pll_opera1,
409 [DVB_PLL_SAMSUNG_DTOS403IH102A] = &dvb_pll_samsung_dtos403ih102a, 481 [DVB_PLL_SAMSUNG_DTOS403IH102A] = &dvb_pll_samsung_dtos403ih102a,
482 [DVB_PLL_SAMSUNG_TDTC9251DH0] = &dvb_pll_samsung_tdtc9251dh0,
483 [DVB_PLL_SAMSUNG_TBDU18132] = &dvb_pll_samsung_tbdu18132,
484 [DVB_PLL_SAMSUNG_TBMU24112] = &dvb_pll_samsung_tbmu24112,
410}; 485};
411 486
412/* ----------------------------------------------------------- */ 487/* ----------------------------------------------------------- */
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index 05239f579ccf..086964344c38 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -23,6 +23,10 @@
23#define DVB_PLL_PHILIPS_SD1878_TDA8261 12 23#define DVB_PLL_PHILIPS_SD1878_TDA8261 12
24#define DVB_PLL_OPERA1 13 24#define DVB_PLL_OPERA1 13
25#define DVB_PLL_SAMSUNG_DTOS403IH102A 14 25#define DVB_PLL_SAMSUNG_DTOS403IH102A 14
26#define DVB_PLL_SAMSUNG_TDTC9251DH0 15
27#define DVB_PLL_SAMSUNG_TBDU18132 16
28#define DVB_PLL_SAMSUNG_TBMU24112 17
29#define DVB_PLL_TDEE4 18
26 30
27/** 31/**
28 * Attach a dvb-pll to the supplied frontend structure. 32 * Attach a dvb-pll to the supplied frontend structure.
diff --git a/drivers/media/dvb/frontends/lgs8gxx.c b/drivers/media/dvb/frontends/lgs8gxx.c
index fde27645bbed..eabcadc425d5 100644
--- a/drivers/media/dvb/frontends/lgs8gxx.c
+++ b/drivers/media/dvb/frontends/lgs8gxx.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * Support for Legend Silicon DMB-TH demodulator 2 * Support for Legend Silicon GB20600 (a.k.a DMB-TH) demodulator
3 * LGS8913, LGS8GL5 3 * LGS8913, LGS8GL5, LGS8G75
4 * experimental support LGS8G42, LGS8G52 4 * experimental support LGS8G42, LGS8G52
5 * 5 *
6 * Copyright (C) 2007,2008 David T.L. Wong <davidtlwong@gmail.com> 6 * Copyright (C) 2007-2009 David T.L. Wong <davidtlwong@gmail.com>
7 * Copyright (C) 2008 Sirius International (Hong Kong) Limited 7 * Copyright (C) 2008 Sirius International (Hong Kong) Limited
8 * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5) 8 * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5)
9 * 9 *
@@ -46,6 +46,42 @@ module_param(fake_signal_str, int, 0644);
46MODULE_PARM_DESC(fake_signal_str, "fake signal strength for LGS8913." 46MODULE_PARM_DESC(fake_signal_str, "fake signal strength for LGS8913."
47"Signal strength calculation is slow.(default:on)."); 47"Signal strength calculation is slow.(default:on).");
48 48
49static const u8 lgs8g75_initdat[] = {
50 0x01, 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
51 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
52 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
53 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
54 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
55 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
56 0xE4, 0xF5, 0xA8, 0xF5, 0xB8, 0xF5, 0x88, 0xF5,
57 0x89, 0xF5, 0x87, 0x75, 0xD0, 0x00, 0x11, 0x50,
58 0x11, 0x50, 0xF4, 0xF5, 0x80, 0xF5, 0x90, 0xF5,
59 0xA0, 0xF5, 0xB0, 0x75, 0x81, 0x30, 0x80, 0x01,
60 0x32, 0x90, 0x80, 0x12, 0x74, 0xFF, 0xF0, 0x90,
61 0x80, 0x13, 0x74, 0x1F, 0xF0, 0x90, 0x80, 0x23,
62 0x74, 0x01, 0xF0, 0x90, 0x80, 0x22, 0xF0, 0x90,
63 0x00, 0x48, 0x74, 0x00, 0xF0, 0x90, 0x80, 0x4D,
64 0x74, 0x05, 0xF0, 0x90, 0x80, 0x09, 0xE0, 0x60,
65 0x21, 0x12, 0x00, 0xDD, 0x14, 0x60, 0x1B, 0x12,
66 0x00, 0xDD, 0x14, 0x60, 0x15, 0x12, 0x00, 0xDD,
67 0x14, 0x60, 0x0F, 0x12, 0x00, 0xDD, 0x14, 0x60,
68 0x09, 0x12, 0x00, 0xDD, 0x14, 0x60, 0x03, 0x12,
69 0x00, 0xDD, 0x90, 0x80, 0x42, 0xE0, 0x60, 0x0B,
70 0x14, 0x60, 0x0C, 0x14, 0x60, 0x0D, 0x14, 0x60,
71 0x0E, 0x01, 0xB3, 0x74, 0x04, 0x01, 0xB9, 0x74,
72 0x05, 0x01, 0xB9, 0x74, 0x07, 0x01, 0xB9, 0x74,
73 0x0A, 0xC0, 0xE0, 0x74, 0xC8, 0x12, 0x00, 0xE2,
74 0xD0, 0xE0, 0x14, 0x70, 0xF4, 0x90, 0x80, 0x09,
75 0xE0, 0x70, 0xAE, 0x12, 0x00, 0xF6, 0x12, 0x00,
76 0xFE, 0x90, 0x00, 0x48, 0xE0, 0x04, 0xF0, 0x90,
77 0x80, 0x4E, 0xF0, 0x01, 0x73, 0x90, 0x80, 0x08,
78 0xF0, 0x22, 0xF8, 0x7A, 0x0C, 0x79, 0xFD, 0x00,
79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9,
80 0xF6, 0xDA, 0xF2, 0xD8, 0xEE, 0x22, 0x90, 0x80,
81 0x65, 0xE0, 0x54, 0xFD, 0xF0, 0x22, 0x90, 0x80,
82 0x65, 0xE0, 0x44, 0xC2, 0xF0, 0x22
83};
84
49/* LGS8GXX internal helper functions */ 85/* LGS8GXX internal helper functions */
50 86
51static int lgs8gxx_write_reg(struct lgs8gxx_state *priv, u8 reg, u8 data) 87static int lgs8gxx_write_reg(struct lgs8gxx_state *priv, u8 reg, u8 data)
@@ -55,7 +91,7 @@ static int lgs8gxx_write_reg(struct lgs8gxx_state *priv, u8 reg, u8 data)
55 struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 }; 91 struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 };
56 92
57 msg.addr = priv->config->demod_address; 93 msg.addr = priv->config->demod_address;
58 if (reg >= 0xC0) 94 if (priv->config->prod != LGS8GXX_PROD_LGS8G75 && reg >= 0xC0)
59 msg.addr += 0x02; 95 msg.addr += 0x02;
60 96
61 if (debug >= 2) 97 if (debug >= 2)
@@ -84,7 +120,7 @@ static int lgs8gxx_read_reg(struct lgs8gxx_state *priv, u8 reg, u8 *p_data)
84 }; 120 };
85 121
86 dev_addr = priv->config->demod_address; 122 dev_addr = priv->config->demod_address;
87 if (reg >= 0xC0) 123 if (priv->config->prod != LGS8GXX_PROD_LGS8G75 && reg >= 0xC0)
88 dev_addr += 0x02; 124 dev_addr += 0x02;
89 msg[1].addr = msg[0].addr = dev_addr; 125 msg[1].addr = msg[0].addr = dev_addr;
90 126
@@ -112,19 +148,36 @@ static int lgs8gxx_soft_reset(struct lgs8gxx_state *priv)
112 return 0; 148 return 0;
113} 149}
114 150
151static int wait_reg_mask(struct lgs8gxx_state *priv, u8 reg, u8 mask,
152 u8 val, u8 delay, u8 tries)
153{
154 u8 t;
155 int i;
156
157 for (i = 0; i < tries; i++) {
158 lgs8gxx_read_reg(priv, reg, &t);
159
160 if ((t & mask) == val)
161 return 0;
162 msleep(delay);
163 }
164
165 return 1;
166}
167
115static int lgs8gxx_set_ad_mode(struct lgs8gxx_state *priv) 168static int lgs8gxx_set_ad_mode(struct lgs8gxx_state *priv)
116{ 169{
117 const struct lgs8gxx_config *config = priv->config; 170 const struct lgs8gxx_config *config = priv->config;
118 u8 if_conf; 171 u8 if_conf;
119 172
120 if_conf = 0x10; /* AGC output on; */ 173 if_conf = 0x10; /* AGC output on, RF_AGC output off; */
121 174
122 if_conf |= 175 if_conf |=
123 ((config->ext_adc) ? 0x80 : 0x00) | 176 ((config->ext_adc) ? 0x80 : 0x00) |
124 ((config->if_neg_center) ? 0x04 : 0x00) | 177 ((config->if_neg_center) ? 0x04 : 0x00) |
125 ((config->if_freq == 0) ? 0x08 : 0x00) | /* Baseband */ 178 ((config->if_freq == 0) ? 0x08 : 0x00) | /* Baseband */
126 ((config->ext_adc && config->adc_signed) ? 0x02 : 0x00) | 179 ((config->adc_signed) ? 0x02 : 0x00) |
127 ((config->ext_adc && config->if_neg_edge) ? 0x01 : 0x00); 180 ((config->if_neg_edge) ? 0x01 : 0x00);
128 181
129 if (config->ext_adc && 182 if (config->ext_adc &&
130 (config->prod == LGS8GXX_PROD_LGS8G52)) { 183 (config->prod == LGS8GXX_PROD_LGS8G52)) {
@@ -157,39 +210,82 @@ static int lgs8gxx_set_if_freq(struct lgs8gxx_state *priv, u32 freq /*in kHz*/)
157 } 210 }
158 dprintk("AFC_INIT_FREQ = 0x%08X\n", v32); 211 dprintk("AFC_INIT_FREQ = 0x%08X\n", v32);
159 212
160 lgs8gxx_write_reg(priv, 0x09, 0xFF & (v32)); 213 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
161 lgs8gxx_write_reg(priv, 0x0A, 0xFF & (v32 >> 8)); 214 lgs8gxx_write_reg(priv, 0x08, 0xFF & (v32));
162 lgs8gxx_write_reg(priv, 0x0B, 0xFF & (v32 >> 16)); 215 lgs8gxx_write_reg(priv, 0x09, 0xFF & (v32 >> 8));
163 lgs8gxx_write_reg(priv, 0x0C, 0xFF & (v32 >> 24)); 216 lgs8gxx_write_reg(priv, 0x0A, 0xFF & (v32 >> 16));
217 lgs8gxx_write_reg(priv, 0x0B, 0xFF & (v32 >> 24));
218 } else {
219 lgs8gxx_write_reg(priv, 0x09, 0xFF & (v32));
220 lgs8gxx_write_reg(priv, 0x0A, 0xFF & (v32 >> 8));
221 lgs8gxx_write_reg(priv, 0x0B, 0xFF & (v32 >> 16));
222 lgs8gxx_write_reg(priv, 0x0C, 0xFF & (v32 >> 24));
223 }
224
225 return 0;
226}
227
228static int lgs8gxx_get_afc_phase(struct lgs8gxx_state *priv)
229{
230 u64 val;
231 u32 v32 = 0;
232 u8 reg_addr, t;
233 int i;
234
235 if (priv->config->prod == LGS8GXX_PROD_LGS8G75)
236 reg_addr = 0x23;
237 else
238 reg_addr = 0x48;
239
240 for (i = 0; i < 4; i++) {
241 lgs8gxx_read_reg(priv, reg_addr, &t);
242 v32 <<= 8;
243 v32 |= t;
244 reg_addr--;
245 }
164 246
247 val = v32;
248 val *= priv->config->if_clk_freq;
249 val /= (u64)1 << 32;
250 dprintk("AFC = %u kHz\n", (u32)val);
165 return 0; 251 return 0;
166} 252}
167 253
168static int lgs8gxx_set_mode_auto(struct lgs8gxx_state *priv) 254static int lgs8gxx_set_mode_auto(struct lgs8gxx_state *priv)
169{ 255{
170 u8 t; 256 u8 t;
257 u8 prod = priv->config->prod;
171 258
172 if (priv->config->prod == LGS8GXX_PROD_LGS8913) 259 if (prod == LGS8GXX_PROD_LGS8913)
173 lgs8gxx_write_reg(priv, 0xC6, 0x01); 260 lgs8gxx_write_reg(priv, 0xC6, 0x01);
174 261
175 lgs8gxx_read_reg(priv, 0x7E, &t); 262 if (prod == LGS8GXX_PROD_LGS8G75) {
176 lgs8gxx_write_reg(priv, 0x7E, t | 0x01); 263 lgs8gxx_read_reg(priv, 0x0C, &t);
177 264 t &= (~0x04);
178 /* clear FEC self reset */ 265 lgs8gxx_write_reg(priv, 0x0C, t | 0x80);
179 lgs8gxx_read_reg(priv, 0xC5, &t); 266 lgs8gxx_write_reg(priv, 0x39, 0x00);
180 lgs8gxx_write_reg(priv, 0xC5, t & 0xE0); 267 lgs8gxx_write_reg(priv, 0x3D, 0x04);
268 } else if (prod == LGS8GXX_PROD_LGS8913 ||
269 prod == LGS8GXX_PROD_LGS8GL5 ||
270 prod == LGS8GXX_PROD_LGS8G42 ||
271 prod == LGS8GXX_PROD_LGS8G52 ||
272 prod == LGS8GXX_PROD_LGS8G54) {
273 lgs8gxx_read_reg(priv, 0x7E, &t);
274 lgs8gxx_write_reg(priv, 0x7E, t | 0x01);
275
276 /* clear FEC self reset */
277 lgs8gxx_read_reg(priv, 0xC5, &t);
278 lgs8gxx_write_reg(priv, 0xC5, t & 0xE0);
279 }
181 280
182 if (priv->config->prod == LGS8GXX_PROD_LGS8913) { 281 if (prod == LGS8GXX_PROD_LGS8913) {
183 /* FEC auto detect */ 282 /* FEC auto detect */
184 lgs8gxx_write_reg(priv, 0xC1, 0x03); 283 lgs8gxx_write_reg(priv, 0xC1, 0x03);
185 284
186 lgs8gxx_read_reg(priv, 0x7C, &t); 285 lgs8gxx_read_reg(priv, 0x7C, &t);
187 t = (t & 0x8C) | 0x03; 286 t = (t & 0x8C) | 0x03;
188 lgs8gxx_write_reg(priv, 0x7C, t); 287 lgs8gxx_write_reg(priv, 0x7C, t);
189 }
190
191 288
192 if (priv->config->prod == LGS8GXX_PROD_LGS8913) {
193 /* BER test mode */ 289 /* BER test mode */
194 lgs8gxx_read_reg(priv, 0xC3, &t); 290 lgs8gxx_read_reg(priv, 0xC3, &t);
195 t = (t & 0xEF) | 0x10; 291 t = (t & 0xEF) | 0x10;
@@ -207,6 +303,32 @@ static int lgs8gxx_set_mode_manual(struct lgs8gxx_state *priv)
207 int ret = 0; 303 int ret = 0;
208 u8 t; 304 u8 t;
209 305
306 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
307 u8 t2;
308 lgs8gxx_read_reg(priv, 0x0C, &t);
309 t &= (~0x80);
310 lgs8gxx_write_reg(priv, 0x0C, t);
311
312 lgs8gxx_read_reg(priv, 0x0C, &t);
313 lgs8gxx_read_reg(priv, 0x19, &t2);
314
315 if (((t&0x03) == 0x01) && (t2&0x01)) {
316 lgs8gxx_write_reg(priv, 0x6E, 0x05);
317 lgs8gxx_write_reg(priv, 0x39, 0x02);
318 lgs8gxx_write_reg(priv, 0x39, 0x03);
319 lgs8gxx_write_reg(priv, 0x3D, 0x05);
320 lgs8gxx_write_reg(priv, 0x3E, 0x28);
321 lgs8gxx_write_reg(priv, 0x53, 0x80);
322 } else {
323 lgs8gxx_write_reg(priv, 0x6E, 0x3F);
324 lgs8gxx_write_reg(priv, 0x39, 0x00);
325 lgs8gxx_write_reg(priv, 0x3D, 0x04);
326 }
327
328 lgs8gxx_soft_reset(priv);
329 return 0;
330 }
331
210 /* turn off auto-detect; manual settings */ 332 /* turn off auto-detect; manual settings */
211 lgs8gxx_write_reg(priv, 0x7E, 0); 333 lgs8gxx_write_reg(priv, 0x7E, 0);
212 if (priv->config->prod == LGS8GXX_PROD_LGS8913) 334 if (priv->config->prod == LGS8GXX_PROD_LGS8913)
@@ -226,11 +348,39 @@ static int lgs8gxx_is_locked(struct lgs8gxx_state *priv, u8 *locked)
226 int ret = 0; 348 int ret = 0;
227 u8 t; 349 u8 t;
228 350
229 ret = lgs8gxx_read_reg(priv, 0x4B, &t); 351 if (priv->config->prod == LGS8GXX_PROD_LGS8G75)
352 ret = lgs8gxx_read_reg(priv, 0x13, &t);
353 else
354 ret = lgs8gxx_read_reg(priv, 0x4B, &t);
230 if (ret != 0) 355 if (ret != 0)
231 return ret; 356 return ret;
232 357
233 *locked = ((t & 0xC0) == 0xC0) ? 1 : 0; 358 if (priv->config->prod == LGS8GXX_PROD_LGS8G75)
359 *locked = ((t & 0x80) == 0x80) ? 1 : 0;
360 else
361 *locked = ((t & 0xC0) == 0xC0) ? 1 : 0;
362 return 0;
363}
364
365/* Wait for Code Acquisition Lock */
366static int lgs8gxx_wait_ca_lock(struct lgs8gxx_state *priv, u8 *locked)
367{
368 int ret = 0;
369 u8 reg, mask, val;
370
371 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
372 reg = 0x13;
373 mask = 0x80;
374 val = 0x80;
375 } else {
376 reg = 0x4B;
377 mask = 0xC0;
378 val = 0xC0;
379 }
380
381 ret = wait_reg_mask(priv, reg, mask, val, 50, 40);
382 *locked = (ret == 0) ? 1 : 0;
383
234 return 0; 384 return 0;
235} 385}
236 386
@@ -238,21 +388,30 @@ static int lgs8gxx_is_autodetect_finished(struct lgs8gxx_state *priv,
238 u8 *finished) 388 u8 *finished)
239{ 389{
240 int ret = 0; 390 int ret = 0;
241 u8 t; 391 u8 reg, mask, val;
242 392
243 ret = lgs8gxx_read_reg(priv, 0xA4, &t); 393 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
244 if (ret != 0) 394 reg = 0x1f;
245 return ret; 395 mask = 0xC0;
396 val = 0x80;
397 } else {
398 reg = 0xA4;
399 mask = 0x03;
400 val = 0x01;
401 }
246 402
247 *finished = ((t & 0x3) == 0x1) ? 1 : 0; 403 ret = wait_reg_mask(priv, reg, mask, val, 10, 20);
404 *finished = (ret == 0) ? 1 : 0;
248 405
249 return 0; 406 return 0;
250} 407}
251 408
252static int lgs8gxx_autolock_gi(struct lgs8gxx_state *priv, u8 gi, u8 *locked) 409static int lgs8gxx_autolock_gi(struct lgs8gxx_state *priv, u8 gi, u8 cpn,
410 u8 *locked)
253{ 411{
254 int err; 412 int err = 0;
255 u8 ad_fini = 0; 413 u8 ad_fini = 0;
414 u8 t1, t2;
256 415
257 if (gi == GI_945) 416 if (gi == GI_945)
258 dprintk("try GI 945\n"); 417 dprintk("try GI 945\n");
@@ -260,17 +419,29 @@ static int lgs8gxx_autolock_gi(struct lgs8gxx_state *priv, u8 gi, u8 *locked)
260 dprintk("try GI 595\n"); 419 dprintk("try GI 595\n");
261 else if (gi == GI_420) 420 else if (gi == GI_420)
262 dprintk("try GI 420\n"); 421 dprintk("try GI 420\n");
263 lgs8gxx_write_reg(priv, 0x04, gi); 422 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
423 lgs8gxx_read_reg(priv, 0x0C, &t1);
424 lgs8gxx_read_reg(priv, 0x18, &t2);
425 t1 &= ~(GI_MASK);
426 t1 |= gi;
427 t2 &= 0xFE;
428 t2 |= cpn ? 0x01 : 0x00;
429 lgs8gxx_write_reg(priv, 0x0C, t1);
430 lgs8gxx_write_reg(priv, 0x18, t2);
431 } else {
432 lgs8gxx_write_reg(priv, 0x04, gi);
433 }
264 lgs8gxx_soft_reset(priv); 434 lgs8gxx_soft_reset(priv);
265 msleep(50); 435 err = lgs8gxx_wait_ca_lock(priv, locked);
436 if (err || !(*locked))
437 return err;
266 err = lgs8gxx_is_autodetect_finished(priv, &ad_fini); 438 err = lgs8gxx_is_autodetect_finished(priv, &ad_fini);
267 if (err != 0) 439 if (err != 0)
268 return err; 440 return err;
269 if (ad_fini) { 441 if (ad_fini) {
270 err = lgs8gxx_is_locked(priv, locked); 442 dprintk("auto detect finished\n");
271 if (err != 0) 443 } else
272 return err; 444 *locked = 0;
273 }
274 445
275 return 0; 446 return 0;
276} 447}
@@ -285,13 +456,18 @@ static int lgs8gxx_auto_detect(struct lgs8gxx_state *priv,
285 dprintk("%s\n", __func__); 456 dprintk("%s\n", __func__);
286 457
287 lgs8gxx_set_mode_auto(priv); 458 lgs8gxx_set_mode_auto(priv);
288 /* Guard Interval */ 459 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
289 lgs8gxx_write_reg(priv, 0x03, 00); 460 lgs8gxx_write_reg(priv, 0x67, 0xAA);
461 lgs8gxx_write_reg(priv, 0x6E, 0x3F);
462 } else {
463 /* Guard Interval */
464 lgs8gxx_write_reg(priv, 0x03, 00);
465 }
290 466
291 for (i = 0; i < 2; i++) { 467 for (i = 0; i < 2; i++) {
292 for (j = 0; j < 2; j++) { 468 for (j = 0; j < 2; j++) {
293 tmp_gi = GI_945; 469 tmp_gi = GI_945;
294 err = lgs8gxx_autolock_gi(priv, GI_945, &locked); 470 err = lgs8gxx_autolock_gi(priv, GI_945, j, &locked);
295 if (err) 471 if (err)
296 goto out; 472 goto out;
297 if (locked) 473 if (locked)
@@ -299,14 +475,14 @@ static int lgs8gxx_auto_detect(struct lgs8gxx_state *priv,
299 } 475 }
300 for (j = 0; j < 2; j++) { 476 for (j = 0; j < 2; j++) {
301 tmp_gi = GI_420; 477 tmp_gi = GI_420;
302 err = lgs8gxx_autolock_gi(priv, GI_420, &locked); 478 err = lgs8gxx_autolock_gi(priv, GI_420, j, &locked);
303 if (err) 479 if (err)
304 goto out; 480 goto out;
305 if (locked) 481 if (locked)
306 goto locked; 482 goto locked;
307 } 483 }
308 tmp_gi = GI_595; 484 tmp_gi = GI_595;
309 err = lgs8gxx_autolock_gi(priv, GI_595, &locked); 485 err = lgs8gxx_autolock_gi(priv, GI_595, 1, &locked);
310 if (err) 486 if (err)
311 goto out; 487 goto out;
312 if (locked) 488 if (locked)
@@ -317,8 +493,13 @@ locked:
317 if ((err == 0) && (locked == 1)) { 493 if ((err == 0) && (locked == 1)) {
318 u8 t; 494 u8 t;
319 495
320 lgs8gxx_read_reg(priv, 0xA2, &t); 496 if (priv->config->prod != LGS8GXX_PROD_LGS8G75) {
321 *detected_param = t; 497 lgs8gxx_read_reg(priv, 0xA2, &t);
498 *detected_param = t;
499 } else {
500 lgs8gxx_read_reg(priv, 0x1F, &t);
501 *detected_param = t & 0x3F;
502 }
322 503
323 if (tmp_gi == GI_945) 504 if (tmp_gi == GI_945)
324 dprintk("GI 945 locked\n"); 505 dprintk("GI 945 locked\n");
@@ -345,18 +526,28 @@ static void lgs8gxx_auto_lock(struct lgs8gxx_state *priv)
345 526
346 if (err != 0) { 527 if (err != 0) {
347 dprintk("lgs8gxx_auto_detect failed\n"); 528 dprintk("lgs8gxx_auto_detect failed\n");
348 } 529 } else
530 dprintk("detected param = 0x%02X\n", detected_param);
349 531
350 /* Apply detected parameters */ 532 /* Apply detected parameters */
351 if (priv->config->prod == LGS8GXX_PROD_LGS8913) { 533 if (priv->config->prod == LGS8GXX_PROD_LGS8913) {
352 u8 inter_leave_len = detected_param & TIM_MASK ; 534 u8 inter_leave_len = detected_param & TIM_MASK ;
353 inter_leave_len = (inter_leave_len == TIM_LONG) ? 0x60 : 0x40; 535 /* Fix 8913 time interleaver detection bug */
536 inter_leave_len = (inter_leave_len == TIM_MIDDLE) ? 0x60 : 0x40;
354 detected_param &= CF_MASK | SC_MASK | LGS_FEC_MASK; 537 detected_param &= CF_MASK | SC_MASK | LGS_FEC_MASK;
355 detected_param |= inter_leave_len; 538 detected_param |= inter_leave_len;
356 } 539 }
357 lgs8gxx_write_reg(priv, 0x7D, detected_param); 540 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
358 if (priv->config->prod == LGS8GXX_PROD_LGS8913) 541 u8 t;
359 lgs8gxx_write_reg(priv, 0xC0, detected_param); 542 lgs8gxx_read_reg(priv, 0x19, &t);
543 t &= 0x81;
544 t |= detected_param << 1;
545 lgs8gxx_write_reg(priv, 0x19, t);
546 } else {
547 lgs8gxx_write_reg(priv, 0x7D, detected_param);
548 if (priv->config->prod == LGS8GXX_PROD_LGS8913)
549 lgs8gxx_write_reg(priv, 0xC0, detected_param);
550 }
360 /* lgs8gxx_soft_reset(priv); */ 551 /* lgs8gxx_soft_reset(priv); */
361 552
362 /* Enter manual mode */ 553 /* Enter manual mode */
@@ -378,9 +569,10 @@ static int lgs8gxx_set_mpeg_mode(struct lgs8gxx_state *priv,
378 u8 serial, u8 clk_pol, u8 clk_gated) 569 u8 serial, u8 clk_pol, u8 clk_gated)
379{ 570{
380 int ret = 0; 571 int ret = 0;
381 u8 t; 572 u8 t, reg_addr;
382 573
383 ret = lgs8gxx_read_reg(priv, 0xC2, &t); 574 reg_addr = (priv->config->prod == LGS8GXX_PROD_LGS8G75) ? 0x30 : 0xC2;
575 ret = lgs8gxx_read_reg(priv, reg_addr, &t);
384 if (ret != 0) 576 if (ret != 0)
385 return ret; 577 return ret;
386 578
@@ -389,13 +581,29 @@ static int lgs8gxx_set_mpeg_mode(struct lgs8gxx_state *priv,
389 t |= clk_pol ? TS_CLK_INVERTED : TS_CLK_NORMAL; 581 t |= clk_pol ? TS_CLK_INVERTED : TS_CLK_NORMAL;
390 t |= clk_gated ? TS_CLK_GATED : TS_CLK_FREERUN; 582 t |= clk_gated ? TS_CLK_GATED : TS_CLK_FREERUN;
391 583
392 ret = lgs8gxx_write_reg(priv, 0xC2, t); 584 ret = lgs8gxx_write_reg(priv, reg_addr, t);
393 if (ret != 0) 585 if (ret != 0)
394 return ret; 586 return ret;
395 587
396 return 0; 588 return 0;
397} 589}
398 590
591/* A/D input peak-to-peak voltage range */
592static int lgs8g75_set_adc_vpp(struct lgs8gxx_state *priv,
593 u8 sel)
594{
595 u8 r26 = 0x73, r27 = 0x90;
596
597 if (priv->config->prod != LGS8GXX_PROD_LGS8G75)
598 return 0;
599
600 r26 |= (sel & 0x01) << 7;
601 r27 |= (sel & 0x02) >> 1;
602 lgs8gxx_write_reg(priv, 0x26, r26);
603 lgs8gxx_write_reg(priv, 0x27, r27);
604
605 return 0;
606}
399 607
400/* LGS8913 demod frontend functions */ 608/* LGS8913 demod frontend functions */
401 609
@@ -417,6 +625,34 @@ static int lgs8913_init(struct lgs8gxx_state *priv)
417 return 0; 625 return 0;
418} 626}
419 627
628static int lgs8g75_init_data(struct lgs8gxx_state *priv)
629{
630 const u8 *p = lgs8g75_initdat;
631 int i;
632
633 lgs8gxx_write_reg(priv, 0xC6, 0x40);
634
635 lgs8gxx_write_reg(priv, 0x3D, 0x04);
636 lgs8gxx_write_reg(priv, 0x39, 0x00);
637
638 lgs8gxx_write_reg(priv, 0x3A, 0x00);
639 lgs8gxx_write_reg(priv, 0x38, 0x00);
640 lgs8gxx_write_reg(priv, 0x3B, 0x00);
641 lgs8gxx_write_reg(priv, 0x38, 0x00);
642
643 for (i = 0; i < sizeof(lgs8g75_initdat); i++) {
644 lgs8gxx_write_reg(priv, 0x38, 0x00);
645 lgs8gxx_write_reg(priv, 0x3A, (u8)(i&0xff));
646 lgs8gxx_write_reg(priv, 0x3B, (u8)(i>>8));
647 lgs8gxx_write_reg(priv, 0x3C, *p);
648 p++;
649 }
650
651 lgs8gxx_write_reg(priv, 0x38, 0x00);
652
653 return 0;
654}
655
420static int lgs8gxx_init(struct dvb_frontend *fe) 656static int lgs8gxx_init(struct dvb_frontend *fe)
421{ 657{
422 struct lgs8gxx_state *priv = 658 struct lgs8gxx_state *priv =
@@ -429,6 +665,9 @@ static int lgs8gxx_init(struct dvb_frontend *fe)
429 lgs8gxx_read_reg(priv, 0, &data); 665 lgs8gxx_read_reg(priv, 0, &data);
430 dprintk("reg 0 = 0x%02X\n", data); 666 dprintk("reg 0 = 0x%02X\n", data);
431 667
668 if (config->prod == LGS8GXX_PROD_LGS8G75)
669 lgs8g75_set_adc_vpp(priv, config->adc_vpp);
670
432 /* Setup MPEG output format */ 671 /* Setup MPEG output format */
433 err = lgs8gxx_set_mpeg_mode(priv, config->serial_ts, 672 err = lgs8gxx_set_mpeg_mode(priv, config->serial_ts,
434 config->ts_clk_pol, 673 config->ts_clk_pol,
@@ -439,8 +678,7 @@ static int lgs8gxx_init(struct dvb_frontend *fe)
439 if (config->prod == LGS8GXX_PROD_LGS8913) 678 if (config->prod == LGS8GXX_PROD_LGS8913)
440 lgs8913_init(priv); 679 lgs8913_init(priv);
441 lgs8gxx_set_if_freq(priv, priv->config->if_freq); 680 lgs8gxx_set_if_freq(priv, priv->config->if_freq);
442 if (config->prod != LGS8GXX_PROD_LGS8913) 681 lgs8gxx_set_ad_mode(priv);
443 lgs8gxx_set_ad_mode(priv);
444 682
445 return 0; 683 return 0;
446} 684}
@@ -489,9 +727,6 @@ static int lgs8gxx_set_fe(struct dvb_frontend *fe,
489static int lgs8gxx_get_fe(struct dvb_frontend *fe, 727static int lgs8gxx_get_fe(struct dvb_frontend *fe,
490 struct dvb_frontend_parameters *fe_params) 728 struct dvb_frontend_parameters *fe_params)
491{ 729{
492 struct lgs8gxx_state *priv = fe->demodulator_priv;
493 u8 t;
494
495 dprintk("%s\n", __func__); 730 dprintk("%s\n", __func__);
496 731
497 /* TODO: get real readings from device */ 732 /* TODO: get real readings from device */
@@ -501,29 +736,10 @@ static int lgs8gxx_get_fe(struct dvb_frontend *fe,
501 /* bandwidth */ 736 /* bandwidth */
502 fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ; 737 fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
503 738
504
505 lgs8gxx_read_reg(priv, 0x7D, &t);
506 fe_params->u.ofdm.code_rate_HP = FEC_AUTO; 739 fe_params->u.ofdm.code_rate_HP = FEC_AUTO;
507 fe_params->u.ofdm.code_rate_LP = FEC_AUTO; 740 fe_params->u.ofdm.code_rate_LP = FEC_AUTO;
508 741
509 /* constellation */ 742 fe_params->u.ofdm.constellation = QAM_AUTO;
510 switch (t & SC_MASK) {
511 case SC_QAM64:
512 fe_params->u.ofdm.constellation = QAM_64;
513 break;
514 case SC_QAM32:
515 fe_params->u.ofdm.constellation = QAM_32;
516 break;
517 case SC_QAM16:
518 fe_params->u.ofdm.constellation = QAM_16;
519 break;
520 case SC_QAM4:
521 case SC_QAM4NR:
522 fe_params->u.ofdm.constellation = QPSK;
523 break;
524 default:
525 fe_params->u.ofdm.constellation = QAM_64;
526 }
527 743
528 /* transmission mode */ 744 /* transmission mode */
529 fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO; 745 fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
@@ -552,9 +768,19 @@ static int lgs8gxx_read_status(struct dvb_frontend *fe, fe_status_t *fe_status)
552{ 768{
553 struct lgs8gxx_state *priv = fe->demodulator_priv; 769 struct lgs8gxx_state *priv = fe->demodulator_priv;
554 s8 ret; 770 s8 ret;
555 u8 t; 771 u8 t, locked = 0;
556 772
557 dprintk("%s\n", __func__); 773 dprintk("%s\n", __func__);
774 *fe_status = 0;
775
776 lgs8gxx_get_afc_phase(priv);
777 lgs8gxx_is_locked(priv, &locked);
778 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
779 if (locked)
780 *fe_status |= FE_HAS_SIGNAL | FE_HAS_CARRIER |
781 FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
782 return 0;
783 }
558 784
559 ret = lgs8gxx_read_reg(priv, 0x4B, &t); 785 ret = lgs8gxx_read_reg(priv, 0x4B, &t);
560 if (ret != 0) 786 if (ret != 0)
@@ -658,12 +884,33 @@ static int lgs8913_read_signal_strength(struct lgs8gxx_state *priv, u16 *signal)
658 return 0; 884 return 0;
659} 885}
660 886
887static int lgs8g75_read_signal_strength(struct lgs8gxx_state *priv, u16 *signal)
888{
889 u8 t;
890 s16 v = 0;
891
892 dprintk("%s\n", __func__);
893
894 lgs8gxx_read_reg(priv, 0xB1, &t);
895 v |= t;
896 v <<= 8;
897 lgs8gxx_read_reg(priv, 0xB0, &t);
898 v |= t;
899
900 *signal = v;
901 dprintk("%s: signal=0x%02X\n", __func__, *signal);
902
903 return 0;
904}
905
661static int lgs8gxx_read_signal_strength(struct dvb_frontend *fe, u16 *signal) 906static int lgs8gxx_read_signal_strength(struct dvb_frontend *fe, u16 *signal)
662{ 907{
663 struct lgs8gxx_state *priv = fe->demodulator_priv; 908 struct lgs8gxx_state *priv = fe->demodulator_priv;
664 909
665 if (priv->config->prod == LGS8GXX_PROD_LGS8913) 910 if (priv->config->prod == LGS8GXX_PROD_LGS8913)
666 return lgs8913_read_signal_strength(priv, signal); 911 return lgs8913_read_signal_strength(priv, signal);
912 else if (priv->config->prod == LGS8GXX_PROD_LGS8G75)
913 return lgs8g75_read_signal_strength(priv, signal);
667 else 914 else
668 return lgs8gxx_read_signal_agc(priv, signal); 915 return lgs8gxx_read_signal_agc(priv, signal);
669} 916}
@@ -674,7 +921,10 @@ static int lgs8gxx_read_snr(struct dvb_frontend *fe, u16 *snr)
674 u8 t; 921 u8 t;
675 *snr = 0; 922 *snr = 0;
676 923
677 lgs8gxx_read_reg(priv, 0x95, &t); 924 if (priv->config->prod == LGS8GXX_PROD_LGS8G75)
925 lgs8gxx_read_reg(priv, 0x34, &t);
926 else
927 lgs8gxx_read_reg(priv, 0x95, &t);
678 dprintk("AVG Noise=0x%02X\n", t); 928 dprintk("AVG Noise=0x%02X\n", t);
679 *snr = 256 - t; 929 *snr = 256 - t;
680 *snr <<= 8; 930 *snr <<= 8;
@@ -690,31 +940,68 @@ static int lgs8gxx_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
690 return 0; 940 return 0;
691} 941}
692 942
943static void packet_counter_start(struct lgs8gxx_state *priv)
944{
945 u8 orig, t;
946
947 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
948 lgs8gxx_read_reg(priv, 0x30, &orig);
949 orig &= 0xE7;
950 t = orig | 0x10;
951 lgs8gxx_write_reg(priv, 0x30, t);
952 t = orig | 0x18;
953 lgs8gxx_write_reg(priv, 0x30, t);
954 t = orig | 0x10;
955 lgs8gxx_write_reg(priv, 0x30, t);
956 } else {
957 lgs8gxx_write_reg(priv, 0xC6, 0x01);
958 lgs8gxx_write_reg(priv, 0xC6, 0x41);
959 lgs8gxx_write_reg(priv, 0xC6, 0x01);
960 }
961}
962
963static void packet_counter_stop(struct lgs8gxx_state *priv)
964{
965 u8 t;
966
967 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
968 lgs8gxx_read_reg(priv, 0x30, &t);
969 t &= 0xE7;
970 lgs8gxx_write_reg(priv, 0x30, t);
971 } else {
972 lgs8gxx_write_reg(priv, 0xC6, 0x81);
973 }
974}
975
693static int lgs8gxx_read_ber(struct dvb_frontend *fe, u32 *ber) 976static int lgs8gxx_read_ber(struct dvb_frontend *fe, u32 *ber)
694{ 977{
695 struct lgs8gxx_state *priv = fe->demodulator_priv; 978 struct lgs8gxx_state *priv = fe->demodulator_priv;
696 u8 r0, r1, r2, r3; 979 u8 reg_err, reg_total, t;
697 u32 total_cnt, err_cnt; 980 u32 total_cnt = 0, err_cnt = 0;
981 int i;
698 982
699 dprintk("%s\n", __func__); 983 dprintk("%s\n", __func__);
700 984
701 lgs8gxx_write_reg(priv, 0xc6, 0x01); 985 packet_counter_start(priv);
702 lgs8gxx_write_reg(priv, 0xc6, 0x41);
703 lgs8gxx_write_reg(priv, 0xc6, 0x01);
704
705 msleep(200); 986 msleep(200);
987 packet_counter_stop(priv);
988
989 if (priv->config->prod == LGS8GXX_PROD_LGS8G75) {
990 reg_total = 0x28; reg_err = 0x2C;
991 } else {
992 reg_total = 0xD0; reg_err = 0xD4;
993 }
706 994
707 lgs8gxx_write_reg(priv, 0xc6, 0x81); 995 for (i = 0; i < 4; i++) {
708 lgs8gxx_read_reg(priv, 0xd0, &r0); 996 total_cnt <<= 8;
709 lgs8gxx_read_reg(priv, 0xd1, &r1); 997 lgs8gxx_read_reg(priv, reg_total+3-i, &t);
710 lgs8gxx_read_reg(priv, 0xd2, &r2); 998 total_cnt |= t;
711 lgs8gxx_read_reg(priv, 0xd3, &r3); 999 }
712 total_cnt = (r3 << 24) | (r2 << 16) | (r1 << 8) | (r0); 1000 for (i = 0; i < 4; i++) {
713 lgs8gxx_read_reg(priv, 0xd4, &r0); 1001 err_cnt <<= 8;
714 lgs8gxx_read_reg(priv, 0xd5, &r1); 1002 lgs8gxx_read_reg(priv, reg_err+3-i, &t);
715 lgs8gxx_read_reg(priv, 0xd6, &r2); 1003 err_cnt |= t;
716 lgs8gxx_read_reg(priv, 0xd7, &r3); 1004 }
717 err_cnt = (r3 << 24) | (r2 << 16) | (r1 << 8) | (r0);
718 dprintk("error=%d total=%d\n", err_cnt, total_cnt); 1005 dprintk("error=%d total=%d\n", err_cnt, total_cnt);
719 1006
720 if (total_cnt == 0) 1007 if (total_cnt == 0)
@@ -801,6 +1088,9 @@ struct dvb_frontend *lgs8gxx_attach(const struct lgs8gxx_config *config,
801 sizeof(struct dvb_frontend_ops)); 1088 sizeof(struct dvb_frontend_ops));
802 priv->frontend.demodulator_priv = priv; 1089 priv->frontend.demodulator_priv = priv;
803 1090
1091 if (config->prod == LGS8GXX_PROD_LGS8G75)
1092 lgs8g75_init_data(priv);
1093
804 return &priv->frontend; 1094 return &priv->frontend;
805 1095
806error_out: 1096error_out:
diff --git a/drivers/media/dvb/frontends/lgs8gxx.h b/drivers/media/dvb/frontends/lgs8gxx.h
index 321d366a8307..33c3c5e162fa 100644
--- a/drivers/media/dvb/frontends/lgs8gxx.h
+++ b/drivers/media/dvb/frontends/lgs8gxx.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * Support for Legend Silicon DMB-TH demodulator 2 * Support for Legend Silicon GB20600 (a.k.a DMB-TH) demodulator
3 * LGS8913, LGS8GL5 3 * LGS8913, LGS8GL5, LGS8G75
4 * experimental support LGS8G42, LGS8G52 4 * experimental support LGS8G42, LGS8G52
5 * 5 *
6 * Copyright (C) 2007,2008 David T.L. Wong <davidtlwong@gmail.com> 6 * Copyright (C) 2007-2009 David T.L. Wong <davidtlwong@gmail.com>
7 * Copyright (C) 2008 Sirius International (Hong Kong) Limited 7 * Copyright (C) 2008 Sirius International (Hong Kong) Limited
8 * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5) 8 * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5)
9 * 9 *
@@ -34,6 +34,7 @@
34#define LGS8GXX_PROD_LGS8G42 3 34#define LGS8GXX_PROD_LGS8G42 3
35#define LGS8GXX_PROD_LGS8G52 4 35#define LGS8GXX_PROD_LGS8G52 4
36#define LGS8GXX_PROD_LGS8G54 5 36#define LGS8GXX_PROD_LGS8G54 5
37#define LGS8GXX_PROD_LGS8G75 6
37 38
38struct lgs8gxx_config { 39struct lgs8gxx_config {
39 40
@@ -70,6 +71,10 @@ struct lgs8gxx_config {
70 /*IF use Negative center frequency*/ 71 /*IF use Negative center frequency*/
71 u8 if_neg_center; 72 u8 if_neg_center;
72 73
74 /*8G75 internal ADC input range selection*/
75 /*0: 0.8Vpp, 1: 1.0Vpp, 2: 1.6Vpp, 3: 2.0Vpp*/
76 u8 adc_vpp;
77
73 /* slave address and configuration of the tuner */ 78 /* slave address and configuration of the tuner */
74 u8 tuner_address; 79 u8 tuner_address;
75}; 80};
diff --git a/drivers/media/dvb/frontends/lgs8gxx_priv.h b/drivers/media/dvb/frontends/lgs8gxx_priv.h
index 9776d30686dc..8ef376f1414d 100644
--- a/drivers/media/dvb/frontends/lgs8gxx_priv.h
+++ b/drivers/media/dvb/frontends/lgs8gxx_priv.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * Support for Legend Silicon DMB-TH demodulator 2 * Support for Legend Silicon GB20600 (a.k.a DMB-TH) demodulator
3 * LGS8913, LGS8GL5 3 * LGS8913, LGS8GL5, LGS8G75
4 * experimental support LGS8G42, LGS8G52 4 * experimental support LGS8G42, LGS8G52
5 * 5 *
6 * Copyright (C) 2007,2008 David T.L. Wong <davidtlwong@gmail.com> 6 * Copyright (C) 2007-2009 David T.L. Wong <davidtlwong@gmail.com>
7 * Copyright (C) 2008 Sirius International (Hong Kong) Limited 7 * Copyright (C) 2008 Sirius International (Hong Kong) Limited
8 * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5) 8 * Timothy Lee <timothy.lee@siriushk.com> (for initial work on LGS8GL5)
9 * 9 *
@@ -38,7 +38,7 @@ struct lgs8gxx_state {
38#define SC_QAM64 0x10 /* 64QAM modulation */ 38#define SC_QAM64 0x10 /* 64QAM modulation */
39#define SC_QAM32 0x0C /* 32QAM modulation */ 39#define SC_QAM32 0x0C /* 32QAM modulation */
40#define SC_QAM16 0x08 /* 16QAM modulation */ 40#define SC_QAM16 0x08 /* 16QAM modulation */
41#define SC_QAM4NR 0x04 /* 4QAM modulation */ 41#define SC_QAM4NR 0x04 /* 4QAM-NR modulation */
42#define SC_QAM4 0x00 /* 4QAM modulation */ 42#define SC_QAM4 0x00 /* 4QAM modulation */
43 43
44#define LGS_FEC_MASK 0x03 /* FEC Rate Mask */ 44#define LGS_FEC_MASK 0x03 /* FEC Rate Mask */
@@ -47,8 +47,8 @@ struct lgs8gxx_state {
47#define LGS_FEC_0_8 0x02 /* FEC Rate 0.8 */ 47#define LGS_FEC_0_8 0x02 /* FEC Rate 0.8 */
48 48
49#define TIM_MASK 0x20 /* Time Interleave Length Mask */ 49#define TIM_MASK 0x20 /* Time Interleave Length Mask */
50#define TIM_LONG 0x00 /* Time Interleave Length = 720 */ 50#define TIM_LONG 0x20 /* Time Interleave Length = 720 */
51#define TIM_MIDDLE 0x20 /* Time Interleave Length = 240 */ 51#define TIM_MIDDLE 0x00 /* Time Interleave Length = 240 */
52 52
53#define CF_MASK 0x80 /* Control Frame Mask */ 53#define CF_MASK 0x80 /* Control Frame Mask */
54#define CF_EN 0x80 /* Control Frame On */ 54#define CF_EN 0x80 /* Control Frame On */
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index f69daaac78c9..472907d43460 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -85,7 +85,7 @@ static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg,
85 int i; 85 int i;
86 dprintk("R(%d):", reg & 0x7f); 86 dprintk("R(%d):", reg & 0x7f);
87 for (i = 0; i < count; i++) 87 for (i = 0; i < count; i++)
88 printk(" %02x", buf[i]); 88 printk(KERN_CONT " %02x", buf[i]);
89 printk("\n"); 89 printk("\n");
90 } 90 }
91 91
@@ -103,7 +103,7 @@ static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg,
103 int i; 103 int i;
104 dprintk("W(%d):", reg & 0x7f); 104 dprintk("W(%d):", reg & 0x7f);
105 for (i = 0; i < count; i++) 105 for (i = 0; i < count; i++)
106 printk(" %02x", src[i]); 106 printk(KERN_CONT " %02x", src[i]);
107 printk("\n"); 107 printk("\n");
108 } 108 }
109 109
@@ -744,7 +744,8 @@ static struct dvb_frontend_ops mt312_ops = {
744 .type = FE_QPSK, 744 .type = FE_QPSK,
745 .frequency_min = 950000, 745 .frequency_min = 950000,
746 .frequency_max = 2150000, 746 .frequency_max = 2150000,
747 .frequency_stepsize = (MT312_PLL_CLK / 1000) / 128, /* FIXME: adjust freq to real used xtal */ 747 /* FIXME: adjust freq to real used xtal */
748 .frequency_stepsize = (MT312_PLL_CLK / 1000) / 128,
748 .symbol_rate_min = MT312_SYS_CLK / 128, /* FIXME as above */ 749 .symbol_rate_min = MT312_SYS_CLK / 128, /* FIXME as above */
749 .symbol_rate_max = MT312_SYS_CLK / 2, 750 .symbol_rate_max = MT312_SYS_CLK / 2,
750 .caps = 751 .caps =
diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c
index 1ed5a7db4c5e..60ee18a94f43 100644
--- a/drivers/media/dvb/frontends/stb6100.c
+++ b/drivers/media/dvb/frontends/stb6100.c
@@ -367,7 +367,9 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
367 /* N(I) = floor(f(VCO) / (f(XTAL) * (PSD2 ? 2 : 1))) */ 367 /* N(I) = floor(f(VCO) / (f(XTAL) * (PSD2 ? 2 : 1))) */
368 nint = fvco / (state->reference << psd2); 368 nint = fvco / (state->reference << psd2);
369 /* N(F) = round(f(VCO) / f(XTAL) * (PSD2 ? 2 : 1) - N(I)) * 2 ^ 9 */ 369 /* N(F) = round(f(VCO) / f(XTAL) * (PSD2 ? 2 : 1) - N(I)) * 2 ^ 9 */
370 nfrac = (((fvco - (nint * state->reference << psd2)) << (9 - psd2)) + state->reference / 2) / state->reference; 370 nfrac = DIV_ROUND_CLOSEST((fvco - (nint * state->reference << psd2))
371 << (9 - psd2),
372 state->reference);
371 dprintk(verbose, FE_DEBUG, 1, 373 dprintk(verbose, FE_DEBUG, 1,
372 "frequency = %u, srate = %u, g = %u, odiv = %u, psd2 = %u, fxtal = %u, osm = %u, fvco = %u, N(I) = %u, N(F) = %u", 374 "frequency = %u, srate = %u, g = %u, odiv = %u, psd2 = %u, fxtal = %u, osm = %u, fvco = %u, N(I) = %u, N(F) = %u",
373 frequency, srate, (unsigned int)g, (unsigned int)odiv, 375 frequency, srate, (unsigned int)g, (unsigned int)odiv,
diff --git a/drivers/media/dvb/frontends/stv0900_core.c b/drivers/media/dvb/frontends/stv0900_core.c
index 1da045fbb4ef..3bde3324a032 100644
--- a/drivers/media/dvb/frontends/stv0900_core.c
+++ b/drivers/media/dvb/frontends/stv0900_core.c
@@ -230,8 +230,8 @@ enum fe_stv0900_error stv0900_initialize(struct stv0900_internal *i_params)
230 stv0900_write_reg(i_params, R0900_P2_DMDISTATE, 0x5c); 230 stv0900_write_reg(i_params, R0900_P2_DMDISTATE, 0x5c);
231 stv0900_write_reg(i_params, R0900_P1_TNRCFG, 0x6c); 231 stv0900_write_reg(i_params, R0900_P1_TNRCFG, 0x6c);
232 stv0900_write_reg(i_params, R0900_P2_TNRCFG, 0x6f); 232 stv0900_write_reg(i_params, R0900_P2_TNRCFG, 0x6f);
233 stv0900_write_reg(i_params, R0900_P1_I2CRPT, 0x24); 233 stv0900_write_reg(i_params, R0900_P1_I2CRPT, 0x20);
234 stv0900_write_reg(i_params, R0900_P2_I2CRPT, 0x24); 234 stv0900_write_reg(i_params, R0900_P2_I2CRPT, 0x20);
235 stv0900_write_reg(i_params, R0900_NCOARSE, 0x13); 235 stv0900_write_reg(i_params, R0900_NCOARSE, 0x13);
236 msleep(3); 236 msleep(3);
237 stv0900_write_reg(i_params, R0900_I2CCFG, 0x08); 237 stv0900_write_reg(i_params, R0900_I2CCFG, 0x08);
@@ -370,8 +370,8 @@ static int stv0900_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
370 u32 fi2c; 370 u32 fi2c;
371 371
372 dmd_reg(fi2c, F0900_P1_I2CT_ON, F0900_P2_I2CT_ON); 372 dmd_reg(fi2c, F0900_P1_I2CT_ON, F0900_P2_I2CT_ON);
373 if (enable) 373
374 stv0900_write_bits(i_params, fi2c, 1); 374 stv0900_write_bits(i_params, fi2c, enable);
375 375
376 return 0; 376 return 0;
377} 377}
diff --git a/drivers/media/dvb/frontends/stv0900_sw.c b/drivers/media/dvb/frontends/stv0900_sw.c
index a5a31536cbcb..962fde1437ce 100644
--- a/drivers/media/dvb/frontends/stv0900_sw.c
+++ b/drivers/media/dvb/frontends/stv0900_sw.c
@@ -1721,7 +1721,7 @@ static enum fe_stv0900_signal_type stv0900_dvbs1_acq_workaround(struct dvb_front
1721 1721
1722 s32 srate, demod_timeout, 1722 s32 srate, demod_timeout,
1723 fec_timeout, freq1, freq0; 1723 fec_timeout, freq1, freq0;
1724 enum fe_stv0900_signal_type signal_type = STV0900_NODATA;; 1724 enum fe_stv0900_signal_type signal_type = STV0900_NODATA;
1725 1725
1726 switch (demod) { 1726 switch (demod) {
1727 case STV0900_DEMOD_1: 1727 case STV0900_DEMOD_1:
diff --git a/drivers/media/dvb/frontends/stv6110.c b/drivers/media/dvb/frontends/stv6110.c
index 70efac869d28..dcf1b21ea974 100644
--- a/drivers/media/dvb/frontends/stv6110.c
+++ b/drivers/media/dvb/frontends/stv6110.c
@@ -36,6 +36,7 @@ struct stv6110_priv {
36 struct i2c_adapter *i2c; 36 struct i2c_adapter *i2c;
37 37
38 u32 mclk; 38 u32 mclk;
39 u8 clk_div;
39 u8 regs[8]; 40 u8 regs[8];
40}; 41};
41 42
@@ -100,35 +101,25 @@ static int stv6110_read_regs(struct dvb_frontend *fe, u8 regs[],
100 struct stv6110_priv *priv = fe->tuner_priv; 101 struct stv6110_priv *priv = fe->tuner_priv;
101 int rc; 102 int rc;
102 u8 reg[] = { start }; 103 u8 reg[] = { start };
103 struct i2c_msg msg_wr = { 104 struct i2c_msg msg[] = {
104 .addr = priv->i2c_address, 105 {
105 .flags = 0, 106 .addr = priv->i2c_address,
106 .buf = reg, 107 .flags = 0,
107 .len = 1, 108 .buf = reg,
109 .len = 1,
110 }, {
111 .addr = priv->i2c_address,
112 .flags = I2C_M_RD,
113 .buf = regs,
114 .len = len,
115 },
108 }; 116 };
109 117
110 struct i2c_msg msg_rd = {
111 .addr = priv->i2c_address,
112 .flags = I2C_M_RD,
113 .buf = regs,
114 .len = len,
115 };
116 /* write subaddr */
117 if (fe->ops.i2c_gate_ctrl) 118 if (fe->ops.i2c_gate_ctrl)
118 fe->ops.i2c_gate_ctrl(fe, 1); 119 fe->ops.i2c_gate_ctrl(fe, 1);
119 120
120 rc = i2c_transfer(priv->i2c, &msg_wr, 1); 121 rc = i2c_transfer(priv->i2c, msg, 2);
121 if (rc != 1) 122 if (rc != 2)
122 dprintk("%s: i2c error\n", __func__);
123
124 if (fe->ops.i2c_gate_ctrl)
125 fe->ops.i2c_gate_ctrl(fe, 0);
126 /* read registers */
127 if (fe->ops.i2c_gate_ctrl)
128 fe->ops.i2c_gate_ctrl(fe, 1);
129
130 rc = i2c_transfer(priv->i2c, &msg_rd, 1);
131 if (rc != 1)
132 dprintk("%s: i2c error\n", __func__); 123 dprintk("%s: i2c error\n", __func__);
133 124
134 if (fe->ops.i2c_gate_ctrl) 125 if (fe->ops.i2c_gate_ctrl)
@@ -221,6 +212,10 @@ static int stv6110_init(struct dvb_frontend *fe)
221 priv->regs[RSTV6110_CTRL1] |= 212 priv->regs[RSTV6110_CTRL1] |=
222 ((((priv->mclk / 1000000) - 16) & 0x1f) << 3); 213 ((((priv->mclk / 1000000) - 16) & 0x1f) << 3);
223 214
215 /* divisor value for the output clock */
216 priv->regs[RSTV6110_CTRL2] &= ~0xc0;
217 priv->regs[RSTV6110_CTRL2] |= (priv->clk_div << 6);
218
224 stv6110_write_regs(fe, &priv->regs[RSTV6110_CTRL1], RSTV6110_CTRL1, 8); 219 stv6110_write_regs(fe, &priv->regs[RSTV6110_CTRL1], RSTV6110_CTRL1, 8);
225 msleep(1); 220 msleep(1);
226 stv6110_set_bandwidth(fe, 72000000); 221 stv6110_set_bandwidth(fe, 72000000);
@@ -418,6 +413,10 @@ struct dvb_frontend *stv6110_attach(struct dvb_frontend *fe,
418 }; 413 };
419 int ret; 414 int ret;
420 415
416 /* divisor value for the output clock */
417 reg0[2] &= ~0xc0;
418 reg0[2] |= (config->clk_div << 6);
419
421 if (fe->ops.i2c_gate_ctrl) 420 if (fe->ops.i2c_gate_ctrl)
422 fe->ops.i2c_gate_ctrl(fe, 1); 421 fe->ops.i2c_gate_ctrl(fe, 1);
423 422
@@ -436,6 +435,7 @@ struct dvb_frontend *stv6110_attach(struct dvb_frontend *fe,
436 priv->i2c_address = config->i2c_address; 435 priv->i2c_address = config->i2c_address;
437 priv->i2c = i2c; 436 priv->i2c = i2c;
438 priv->mclk = config->mclk; 437 priv->mclk = config->mclk;
438 priv->clk_div = config->clk_div;
439 439
440 memcpy(&priv->regs, &reg0[1], 8); 440 memcpy(&priv->regs, &reg0[1], 8);
441 441
diff --git a/drivers/media/dvb/frontends/stv6110.h b/drivers/media/dvb/frontends/stv6110.h
index 1c0314d6aa55..9db2402410f6 100644
--- a/drivers/media/dvb/frontends/stv6110.h
+++ b/drivers/media/dvb/frontends/stv6110.h
@@ -41,7 +41,7 @@
41struct stv6110_config { 41struct stv6110_config {
42 u8 i2c_address; 42 u8 i2c_address;
43 u32 mclk; 43 u32 mclk;
44 int iq_wiring; 44 u8 clk_div; /* divisor value for the output clock */
45}; 45};
46 46
47#if defined(CONFIG_DVB_STV6110) || (defined(CONFIG_DVB_STV6110_MODULE) \ 47#if defined(CONFIG_DVB_STV6110) || (defined(CONFIG_DVB_STV6110_MODULE) \
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index f5d7b3277a2f..6c1dbf9288d8 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -176,7 +176,7 @@ static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate
176 tmp = ((symbolrate << 4) % FIN) << 8; 176 tmp = ((symbolrate << 4) % FIN) << 8;
177 ratio = (ratio << 8) + tmp / FIN; 177 ratio = (ratio << 8) + tmp / FIN;
178 tmp = (tmp % FIN) << 8; 178 tmp = (tmp % FIN) << 8;
179 ratio = (ratio << 8) + (tmp + FIN/2) / FIN; 179 ratio = (ratio << 8) + DIV_ROUND_CLOSEST(tmp, FIN);
180 180
181 BDR = ratio; 181 BDR = ratio;
182 BDRI = (((XIN << 5) / symbolrate) + 1) / 2; 182 BDRI = (((XIN << 5) / symbolrate) + 1) / 2;
diff --git a/drivers/media/dvb/frontends/tda8261.c b/drivers/media/dvb/frontends/tda8261.c
index b6d177799104..320c3c36d8b2 100644
--- a/drivers/media/dvb/frontends/tda8261.c
+++ b/drivers/media/dvb/frontends/tda8261.c
@@ -136,9 +136,9 @@ static int tda8261_set_state(struct dvb_frontend *fe,
136 136
137 if (frequency < 1450000) 137 if (frequency < 1450000)
138 buf[3] = 0x00; 138 buf[3] = 0x00;
139 if (frequency < 2000000) 139 else if (frequency < 2000000)
140 buf[3] = 0x40; 140 buf[3] = 0x40;
141 if (frequency < 2150000) 141 else if (frequency < 2150000)
142 buf[3] = 0x80; 142 buf[3] = 0x80;
143 143
144 /* Set params */ 144 /* Set params */
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
index 6e78e4865515..550a07a8a997 100644
--- a/drivers/media/dvb/frontends/ves1820.c
+++ b/drivers/media/dvb/frontends/ves1820.c
@@ -165,7 +165,7 @@ static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
165 tmp = ((symbolrate << 4) % fin) << 8; 165 tmp = ((symbolrate << 4) % fin) << 8;
166 ratio = (ratio << 8) + tmp / fin; 166 ratio = (ratio << 8) + tmp / fin;
167 tmp = (tmp % fin) << 8; 167 tmp = (tmp % fin) << 8;
168 ratio = (ratio << 8) + (tmp + fin / 2) / fin; 168 ratio = (ratio << 8) + DIV_ROUND_CLOSEST(tmp, fin);
169 169
170 BDR = ratio; 170 BDR = ratio;
171 BDRI = (((state->config->xin << 5) / symbolrate) + 1) / 2; 171 BDRI = (((state->config->xin << 5) / symbolrate) + 1) / 2;
diff --git a/drivers/media/dvb/frontends/zl10036.c b/drivers/media/dvb/frontends/zl10036.c
index e22a0b381dc4..4e814ff22b23 100644
--- a/drivers/media/dvb/frontends/zl10036.c
+++ b/drivers/media/dvb/frontends/zl10036.c
@@ -29,7 +29,7 @@
29 29
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/dvb/frontend.h> 31#include <linux/dvb/frontend.h>
32#include <asm/types.h> 32#include <linux/types.h>
33 33
34#include "zl10036.h" 34#include "zl10036.h"
35 35
diff --git a/drivers/media/dvb/frontends/zl10039.c b/drivers/media/dvb/frontends/zl10039.c
new file mode 100644
index 000000000000..11b29cb883e6
--- /dev/null
+++ b/drivers/media/dvb/frontends/zl10039.c
@@ -0,0 +1,308 @@
1/*
2 * Driver for Zarlink ZL10039 DVB-S tuner
3 *
4 * Copyright 2007 Jan D. Louw <jd.louw@mweb.co.za>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/string.h>
25#include <linux/slab.h>
26#include <linux/dvb/frontend.h>
27
28#include "dvb_frontend.h"
29#include "zl10039.h"
30
31static int debug;
32
33#define dprintk(args...) \
34 do { \
35 if (debug) \
36 printk(KERN_DEBUG args); \
37 } while (0)
38
39enum zl10039_model_id {
40 ID_ZL10039 = 1
41};
42
43struct zl10039_state {
44 struct i2c_adapter *i2c;
45 u8 i2c_addr;
46 u8 id;
47};
48
49enum zl10039_reg_addr {
50 PLL0 = 0,
51 PLL1,
52 PLL2,
53 PLL3,
54 RFFE,
55 BASE0,
56 BASE1,
57 BASE2,
58 LO0,
59 LO1,
60 LO2,
61 LO3,
62 LO4,
63 LO5,
64 LO6,
65 GENERAL
66};
67
68static int zl10039_read(const struct zl10039_state *state,
69 const enum zl10039_reg_addr reg, u8 *buf,
70 const size_t count)
71{
72 u8 regbuf[] = { reg };
73 struct i2c_msg msg[] = {
74 {/* Write register address */
75 .addr = state->i2c_addr,
76 .flags = 0,
77 .buf = regbuf,
78 .len = 1,
79 }, {/* Read count bytes */
80 .addr = state->i2c_addr,
81 .flags = I2C_M_RD,
82 .buf = buf,
83 .len = count,
84 },
85 };
86
87 dprintk("%s\n", __func__);
88
89 if (i2c_transfer(state->i2c, msg, 2) != 2) {
90 dprintk("%s: i2c read error\n", __func__);
91 return -EREMOTEIO;
92 }
93
94 return 0; /* Success */
95}
96
97static int zl10039_write(struct zl10039_state *state,
98 const enum zl10039_reg_addr reg, const u8 *src,
99 const size_t count)
100{
101 u8 buf[count + 1];
102 struct i2c_msg msg = {
103 .addr = state->i2c_addr,
104 .flags = 0,
105 .buf = buf,
106 .len = count + 1,
107 };
108
109 dprintk("%s\n", __func__);
110 /* Write register address and data in one go */
111 buf[0] = reg;
112 memcpy(&buf[1], src, count);
113 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
114 dprintk("%s: i2c write error\n", __func__);
115 return -EREMOTEIO;
116 }
117
118 return 0; /* Success */
119}
120
121static inline int zl10039_readreg(struct zl10039_state *state,
122 const enum zl10039_reg_addr reg, u8 *val)
123{
124 return zl10039_read(state, reg, val, 1);
125}
126
127static inline int zl10039_writereg(struct zl10039_state *state,
128 const enum zl10039_reg_addr reg,
129 const u8 val)
130{
131 return zl10039_write(state, reg, &val, 1);
132}
133
134static int zl10039_init(struct dvb_frontend *fe)
135{
136 struct zl10039_state *state = fe->tuner_priv;
137 int ret;
138
139 dprintk("%s\n", __func__);
140 if (fe->ops.i2c_gate_ctrl)
141 fe->ops.i2c_gate_ctrl(fe, 1);
142 /* Reset logic */
143 ret = zl10039_writereg(state, GENERAL, 0x40);
144 if (ret < 0) {
145 dprintk("Note: i2c write error normal when resetting the "
146 "tuner\n");
147 }
148 /* Wake up */
149 ret = zl10039_writereg(state, GENERAL, 0x01);
150 if (ret < 0) {
151 dprintk("Tuner power up failed\n");
152 return ret;
153 }
154 if (fe->ops.i2c_gate_ctrl)
155 fe->ops.i2c_gate_ctrl(fe, 0);
156
157 return 0;
158}
159
160static int zl10039_sleep(struct dvb_frontend *fe)
161{
162 struct zl10039_state *state = fe->tuner_priv;
163 int ret;
164
165 dprintk("%s\n", __func__);
166 if (fe->ops.i2c_gate_ctrl)
167 fe->ops.i2c_gate_ctrl(fe, 1);
168 ret = zl10039_writereg(state, GENERAL, 0x80);
169 if (ret < 0) {
170 dprintk("Tuner sleep failed\n");
171 return ret;
172 }
173 if (fe->ops.i2c_gate_ctrl)
174 fe->ops.i2c_gate_ctrl(fe, 0);
175
176 return 0;
177}
178
179static int zl10039_set_params(struct dvb_frontend *fe,
180 struct dvb_frontend_parameters *params)
181{
182 struct zl10039_state *state = fe->tuner_priv;
183 u8 buf[6];
184 u8 bf;
185 u32 fbw;
186 u32 div;
187 int ret;
188
189 dprintk("%s\n", __func__);
190 dprintk("Set frequency = %d, symbol rate = %d\n",
191 params->frequency, params->u.qpsk.symbol_rate);
192
193 /* Assumed 10.111 MHz crystal oscillator */
194 /* Cancelled num/den 80 to prevent overflow */
195 div = (params->frequency * 1000) / 126387;
196 fbw = (params->u.qpsk.symbol_rate * 27) / 32000;
197 /* Cancelled num/den 10 to prevent overflow */
198 bf = ((fbw * 5088) / 1011100) - 1;
199
200 /*PLL divider*/
201 buf[0] = (div >> 8) & 0x7f;
202 buf[1] = (div >> 0) & 0xff;
203 /*Reference divider*/
204 /* Select reference ratio of 80 */
205 buf[2] = 0x1D;
206 /*PLL test modes*/
207 buf[3] = 0x40;
208 /*RF Control register*/
209 buf[4] = 0x6E; /* Bypass enable */
210 /*Baseband filter cutoff */
211 buf[5] = bf;
212
213 /* Open i2c gate */
214 if (fe->ops.i2c_gate_ctrl)
215 fe->ops.i2c_gate_ctrl(fe, 1);
216 /* BR = 10, Enable filter adjustment */
217 ret = zl10039_writereg(state, BASE1, 0x0A);
218 if (ret < 0)
219 goto error;
220 /* Write new config values */
221 ret = zl10039_write(state, PLL0, buf, sizeof(buf));
222 if (ret < 0)
223 goto error;
224 /* BR = 10, Disable filter adjustment */
225 ret = zl10039_writereg(state, BASE1, 0x6A);
226 if (ret < 0)
227 goto error;
228
229 /* Close i2c gate */
230 if (fe->ops.i2c_gate_ctrl)
231 fe->ops.i2c_gate_ctrl(fe, 0);
232 return 0;
233error:
234 dprintk("Error setting tuner\n");
235 return ret;
236}
237
238static int zl10039_release(struct dvb_frontend *fe)
239{
240 struct zl10039_state *state = fe->tuner_priv;
241
242 dprintk("%s\n", __func__);
243 kfree(state);
244 fe->tuner_priv = NULL;
245 return 0;
246}
247
248static struct dvb_tuner_ops zl10039_ops = {
249 .release = zl10039_release,
250 .init = zl10039_init,
251 .sleep = zl10039_sleep,
252 .set_params = zl10039_set_params,
253};
254
255struct dvb_frontend *zl10039_attach(struct dvb_frontend *fe,
256 u8 i2c_addr, struct i2c_adapter *i2c)
257{
258 struct zl10039_state *state = NULL;
259
260 dprintk("%s\n", __func__);
261 state = kmalloc(sizeof(struct zl10039_state), GFP_KERNEL);
262 if (state == NULL)
263 goto error;
264
265 state->i2c = i2c;
266 state->i2c_addr = i2c_addr;
267
268 /* Open i2c gate */
269 if (fe->ops.i2c_gate_ctrl)
270 fe->ops.i2c_gate_ctrl(fe, 1);
271 /* check if this is a valid tuner */
272 if (zl10039_readreg(state, GENERAL, &state->id) < 0) {
273 /* Close i2c gate */
274 if (fe->ops.i2c_gate_ctrl)
275 fe->ops.i2c_gate_ctrl(fe, 0);
276 goto error;
277 }
278 /* Close i2c gate */
279 if (fe->ops.i2c_gate_ctrl)
280 fe->ops.i2c_gate_ctrl(fe, 0);
281
282 state->id = state->id & 0x0f;
283 switch (state->id) {
284 case ID_ZL10039:
285 strcpy(fe->ops.tuner_ops.info.name,
286 "Zarlink ZL10039 DVB-S tuner");
287 break;
288 default:
289 dprintk("Chip ID=%x does not match a known type\n", state->id);
290 break;
291 goto error;
292 }
293
294 memcpy(&fe->ops.tuner_ops, &zl10039_ops, sizeof(struct dvb_tuner_ops));
295 fe->tuner_priv = state;
296 dprintk("Tuner attached @ i2c address 0x%02x\n", i2c_addr);
297 return fe;
298error:
299 kfree(state);
300 return NULL;
301}
302EXPORT_SYMBOL(zl10039_attach);
303
304module_param(debug, int, 0644);
305MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
306MODULE_DESCRIPTION("Zarlink ZL10039 DVB-S tuner driver");
307MODULE_AUTHOR("Jan D. Louw <jd.louw@mweb.co.za>");
308MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/zl10039.h b/drivers/media/dvb/frontends/zl10039.h
new file mode 100644
index 000000000000..5eee7ea162a1
--- /dev/null
+++ b/drivers/media/dvb/frontends/zl10039.h
@@ -0,0 +1,40 @@
1/*
2 Driver for Zarlink ZL10039 DVB-S tuner
3
4 Copyright (C) 2007 Jan D. Louw <jd.louw@mweb.co.za>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
15 GNU 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., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef ZL10039_H
23#define ZL10039_H
24
25#if defined(CONFIG_DVB_ZL10039) || (defined(CONFIG_DVB_ZL10039_MODULE) \
26 && defined(MODULE))
27struct dvb_frontend *zl10039_attach(struct dvb_frontend *fe,
28 u8 i2c_addr,
29 struct i2c_adapter *i2c);
30#else
31static inline struct dvb_frontend *zl10039_attach(struct dvb_frontend *fe,
32 u8 i2c_addr,
33 struct i2c_adapter *i2c)
34{
35 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
36 return NULL;
37}
38#endif /* CONFIG_DVB_ZL10039 */
39
40#endif /* ZL10039_H */
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 66f5c1fb3074..8c612719adfc 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -38,6 +38,8 @@ struct zl10353_state {
38 struct zl10353_config config; 38 struct zl10353_config config;
39 39
40 enum fe_bandwidth bandwidth; 40 enum fe_bandwidth bandwidth;
41 u32 ucblocks;
42 u32 frequency;
41}; 43};
42 44
43static int debug; 45static int debug;
@@ -199,6 +201,8 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
199 u16 tps = 0; 201 u16 tps = 0;
200 struct dvb_ofdm_parameters *op = &param->u.ofdm; 202 struct dvb_ofdm_parameters *op = &param->u.ofdm;
201 203
204 state->frequency = param->frequency;
205
202 zl10353_single_write(fe, RESET, 0x80); 206 zl10353_single_write(fe, RESET, 0x80);
203 udelay(200); 207 udelay(200);
204 zl10353_single_write(fe, 0xEA, 0x01); 208 zl10353_single_write(fe, 0xEA, 0x01);
@@ -464,7 +468,7 @@ static int zl10353_get_parameters(struct dvb_frontend *fe,
464 break; 468 break;
465 } 469 }
466 470
467 param->frequency = 0; 471 param->frequency = state->frequency;
468 op->bandwidth = state->bandwidth; 472 op->bandwidth = state->bandwidth;
469 param->inversion = INVERSION_AUTO; 473 param->inversion = INVERSION_AUTO;
470 474
@@ -542,9 +546,13 @@ static int zl10353_read_snr(struct dvb_frontend *fe, u16 *snr)
542static int zl10353_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) 546static int zl10353_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
543{ 547{
544 struct zl10353_state *state = fe->demodulator_priv; 548 struct zl10353_state *state = fe->demodulator_priv;
549 u32 ubl = 0;
550
551 ubl = zl10353_read_register(state, RS_UBC_1) << 8 |
552 zl10353_read_register(state, RS_UBC_0);
545 553
546 *ucblocks = zl10353_read_register(state, RS_UBC_1) << 8 | 554 state->ucblocks += ubl;
547 zl10353_read_register(state, RS_UBC_0); 555 *ucblocks = state->ucblocks;
548 556
549 return 0; 557 return 0;
550} 558}
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 598eaf8acc6e..80d14a065bad 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -439,7 +439,7 @@ static inline u32 divide(u32 numerator, u32 denominator)
439 if (denominator == 0) 439 if (denominator == 0)
440 return ~0; 440 return ~0;
441 441
442 return (numerator + denominator / 2) / denominator; 442 return DIV_ROUND_CLOSEST(numerator, denominator);
443} 443}
444 444
445/* LG Innotek TDTE-E001P (Infineon TUA6034) */ 445/* LG Innotek TDTE-E001P (Infineon TUA6034) */
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index ce64c6214cc4..8986d967d2f4 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -490,7 +490,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
490 if (!av7110->analog_tuner_flags) 490 if (!av7110->analog_tuner_flags)
491 return 0; 491 return 0;
492 492
493 if (input < 0 || input >= 4) 493 if (input >= 4)
494 return -EINVAL; 494 return -EINVAL;
495 495
496 av7110->current_input = input; 496 av7110->current_input = input;
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 371a71616810..b5c681372b6c 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -225,7 +225,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
225 case 0x1012: 225 case 0x1012:
226 /* The hauppauge keymap is a superset of these remotes */ 226 /* The hauppauge keymap is a superset of these remotes */
227 ir_input_init(input_dev, &budget_ci->ir.state, 227 ir_input_init(input_dev, &budget_ci->ir.state,
228 IR_TYPE_RC5, ir_codes_hauppauge_new); 228 IR_TYPE_RC5, &ir_codes_hauppauge_new_table);
229 229
230 if (rc5_device < 0) 230 if (rc5_device < 0)
231 budget_ci->ir.rc5_device = 0x1f; 231 budget_ci->ir.rc5_device = 0x1f;
@@ -237,7 +237,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
237 case 0x101a: 237 case 0x101a:
238 /* for the Technotrend 1500 bundled remote */ 238 /* for the Technotrend 1500 bundled remote */
239 ir_input_init(input_dev, &budget_ci->ir.state, 239 ir_input_init(input_dev, &budget_ci->ir.state,
240 IR_TYPE_RC5, ir_codes_tt_1500); 240 IR_TYPE_RC5, &ir_codes_tt_1500_table);
241 241
242 if (rc5_device < 0) 242 if (rc5_device < 0)
243 budget_ci->ir.rc5_device = IR_DEVICE_ANY; 243 budget_ci->ir.rc5_device = IR_DEVICE_ANY;
@@ -247,7 +247,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
247 default: 247 default:
248 /* unknown remote */ 248 /* unknown remote */
249 ir_input_init(input_dev, &budget_ci->ir.state, 249 ir_input_init(input_dev, &budget_ci->ir.state,
250 IR_TYPE_RC5, ir_codes_budget_ci_old); 250 IR_TYPE_RC5, &ir_codes_budget_ci_old_table);
251 251
252 if (rc5_device < 0) 252 if (rc5_device < 0)
253 budget_ci->ir.rc5_device = IR_DEVICE_ANY; 253 budget_ci->ir.rc5_device = IR_DEVICE_ANY;
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 3315cac875e5..25a36ad60c5e 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -288,16 +288,6 @@ config RADIO_TYPHOON
288 To compile this driver as a module, choose M here: the 288 To compile this driver as a module, choose M here: the
289 module will be called radio-typhoon. 289 module will be called radio-typhoon.
290 290
291config RADIO_TYPHOON_PROC_FS
292 bool "Support for /proc/radio-typhoon"
293 depends on PROC_FS && RADIO_TYPHOON
294 help
295 Say Y here if you want the typhoon radio card driver to write
296 status information (frequency, volume, muted, mute frequency,
297 base address) to /proc/radio-typhoon. The file can be viewed with
298 your favorite pager (i.e. use "more /proc/radio-typhoon" or "less
299 /proc/radio-typhoon" or simply "cat /proc/radio-typhoon").
300
301config RADIO_TYPHOON_PORT 291config RADIO_TYPHOON_PORT
302 hex "Typhoon I/O port (0x316 or 0x336)" 292 hex "Typhoon I/O port (0x316 or 0x336)"
303 depends on RADIO_TYPHOON=y 293 depends on RADIO_TYPHOON=y
@@ -339,6 +329,29 @@ config RADIO_ZOLTRIX_PORT
339 help 329 help
340 Enter the I/O port of your Zoltrix radio card. 330 Enter the I/O port of your Zoltrix radio card.
341 331
332config I2C_SI4713
333 tristate "I2C driver for Silicon Labs Si4713 device"
334 depends on I2C && VIDEO_V4L2
335 ---help---
336 Say Y here if you want support to Si4713 I2C device.
337 This device driver supports only i2c bus.
338
339 To compile this driver as a module, choose M here: the
340 module will be called si4713.
341
342config RADIO_SI4713
343 tristate "Silicon Labs Si4713 FM Radio Transmitter support"
344 depends on I2C && VIDEO_V4L2
345 select I2C_SI4713
346 ---help---
347 Say Y here if you want support to Si4713 FM Radio Transmitter.
348 This device can transmit audio through FM. It can transmit
349 EDS and EBDS signals as well. This module is the v4l2 radio
350 interface for the i2c driver of this device.
351
352 To compile this driver as a module, choose M here: the
353 module will be called radio-si4713.
354
342config USB_DSBR 355config USB_DSBR
343 tristate "D-Link/GemTek USB FM radio support" 356 tristate "D-Link/GemTek USB FM radio support"
344 depends on USB && VIDEO_V4L2 357 depends on USB && VIDEO_V4L2
@@ -351,29 +364,11 @@ config USB_DSBR
351 To compile this driver as a module, choose M here: the 364 To compile this driver as a module, choose M here: the
352 module will be called dsbr100. 365 module will be called dsbr100.
353 366
354config USB_SI470X 367config RADIO_SI470X
355 tristate "Silicon Labs Si470x FM Radio Receiver support" 368 bool "Silicon Labs Si470x FM Radio Receiver support"
356 depends on USB && VIDEO_V4L2 369 depends on VIDEO_V4L2
357 ---help---
358 This is a driver for USB devices with the Silicon Labs SI470x
359 chip. Currently these devices are known to work:
360 - 10c4:818a: Silicon Labs USB FM Radio Reference Design
361 - 06e1:a155: ADS/Tech FM Radio Receiver (formerly Instant FM Music)
362 - 1b80:d700: KWorld USB FM Radio SnapMusic Mobile 700 (FM700)
363
364 Sound is provided by the ALSA USB Audio/MIDI driver. Therefore
365 if you don't want to use the device solely for RDS receiving,
366 it is recommended to also select SND_USB_AUDIO.
367
368 Please have a look at the documentation, especially on how
369 to redirect the audio stream from the radio to your sound device:
370 Documentation/video4linux/si470x.txt
371
372 Say Y here if you want to connect this type of radio to your
373 computer's USB port.
374 370
375 To compile this driver as a module, choose M here: the 371source "drivers/media/radio/si470x/Kconfig"
376 module will be called radio-si470x.
377 372
378config USB_MR800 373config USB_MR800
379 tristate "AverMedia MR 800 USB FM radio support" 374 tristate "AverMedia MR 800 USB FM radio support"
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 0f2b35b3e560..2a1be3bf4f7c 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -15,9 +15,11 @@ obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o
15obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o 15obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
16obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o 16obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o
17obj-$(CONFIG_RADIO_TRUST) += radio-trust.o 17obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
18obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
19obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
18obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o 20obj-$(CONFIG_RADIO_MAESTRO) += radio-maestro.o
19obj-$(CONFIG_USB_DSBR) += dsbr100.o 21obj-$(CONFIG_USB_DSBR) += dsbr100.o
20obj-$(CONFIG_USB_SI470X) += radio-si470x.o 22obj-$(CONFIG_RADIO_SI470X) += si470x/
21obj-$(CONFIG_USB_MR800) += radio-mr800.o 23obj-$(CONFIG_USB_MR800) += radio-mr800.o
22obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o 24obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
23 25
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index d30fc0ce82c0..8b1440136c45 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -359,7 +359,8 @@ static int vidioc_querycap(struct file *file, void *priv,
359 strlcpy(v->card, "ADS Cadet", sizeof(v->card)); 359 strlcpy(v->card, "ADS Cadet", sizeof(v->card));
360 strlcpy(v->bus_info, "ISA", sizeof(v->bus_info)); 360 strlcpy(v->bus_info, "ISA", sizeof(v->bus_info));
361 v->version = CADET_VERSION; 361 v->version = CADET_VERSION;
362 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_READWRITE; 362 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO |
363 V4L2_CAP_READWRITE | V4L2_CAP_RDS_CAPTURE;
363 return 0; 364 return 0;
364} 365}
365 366
@@ -372,7 +373,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
372 switch (v->index) { 373 switch (v->index) {
373 case 0: 374 case 0:
374 strlcpy(v->name, "FM", sizeof(v->name)); 375 strlcpy(v->name, "FM", sizeof(v->name));
375 v->capability = V4L2_TUNER_CAP_STEREO; 376 v->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS;
376 v->rangelow = 1400; /* 87.5 MHz */ 377 v->rangelow = 1400; /* 87.5 MHz */
377 v->rangehigh = 1728; /* 108.0 MHz */ 378 v->rangehigh = 1728; /* 108.0 MHz */
378 v->rxsubchans = cadet_getstereo(dev); 379 v->rxsubchans = cadet_getstereo(dev);
@@ -386,6 +387,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
386 default: 387 default:
387 break; 388 break;
388 } 389 }
390 v->rxsubchans |= V4L2_TUNER_SUB_RDS;
389 break; 391 break;
390 case 1: 392 case 1:
391 strlcpy(v->name, "AM", sizeof(v->name)); 393 strlcpy(v->name, "AM", sizeof(v->name));
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c
deleted file mode 100644
index e85f318b4d2b..000000000000
--- a/drivers/media/radio/radio-si470x.c
+++ /dev/null
@@ -1,1863 +0,0 @@
1/*
2 * drivers/media/radio/radio-si470x.c
3 *
4 * Driver for USB radios for the Silicon Labs Si470x FM Radio Receivers:
5 * - Silicon Labs USB FM Radio Reference Design
6 * - ADS/Tech FM Radio Receiver (formerly Instant FM Music) (RDX-155-EF)
7 * - KWorld USB FM Radio SnapMusic Mobile 700 (FM700)
8 * - Sanei Electric, Inc. FM USB Radio (sold as DealExtreme.com PCear)
9 *
10 * Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27
28/*
29 * History:
30 * 2008-01-12 Tobias Lorenz <tobias.lorenz@gmx.net>
31 * Version 1.0.0
32 * - First working version
33 * 2008-01-13 Tobias Lorenz <tobias.lorenz@gmx.net>
34 * Version 1.0.1
35 * - Improved error handling, every function now returns errno
36 * - Improved multi user access (start/mute/stop)
37 * - Channel doesn't get lost anymore after start/mute/stop
38 * - RDS support added (polling mode via interrupt EP 1)
39 * - marked default module parameters with *value*
40 * - switched from bit structs to bit masks
41 * - header file cleaned and integrated
42 * 2008-01-14 Tobias Lorenz <tobias.lorenz@gmx.net>
43 * Version 1.0.2
44 * - hex values are now lower case
45 * - commented USB ID for ADS/Tech moved on todo list
46 * - blacklisted si470x in hid-quirks.c
47 * - rds buffer handling functions integrated into *_work, *_read
48 * - rds_command in si470x_poll exchanged against simple retval
49 * - check for firmware version 15
50 * - code order and prototypes still remain the same
51 * - spacing and bottom of band codes remain the same
52 * 2008-01-16 Tobias Lorenz <tobias.lorenz@gmx.net>
53 * Version 1.0.3
54 * - code reordered to avoid function prototypes
55 * - switch/case defaults are now more user-friendly
56 * - unified comment style
57 * - applied all checkpatch.pl v1.12 suggestions
58 * except the warning about the too long lines with bit comments
59 * - renamed FMRADIO to RADIO to cut line length (checkpatch.pl)
60 * 2008-01-22 Tobias Lorenz <tobias.lorenz@gmx.net>
61 * Version 1.0.4
62 * - avoid poss. locking when doing copy_to_user which may sleep
63 * - RDS is automatically activated on read now
64 * - code cleaned of unnecessary rds_commands
65 * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified
66 * (thanks to Guillaume RAMOUSSE)
67 * 2008-01-27 Tobias Lorenz <tobias.lorenz@gmx.net>
68 * Version 1.0.5
69 * - number of seek_retries changed to tune_timeout
70 * - fixed problem with incomplete tune operations by own buffers
71 * - optimization of variables and printf types
72 * - improved error logging
73 * 2008-01-31 Tobias Lorenz <tobias.lorenz@gmx.net>
74 * Oliver Neukum <oliver@neukum.org>
75 * Version 1.0.6
76 * - fixed coverity checker warnings in *_usb_driver_disconnect
77 * - probe()/open() race by correct ordering in probe()
78 * - DMA coherency rules by separate allocation of all buffers
79 * - use of endianness macros
80 * - abuse of spinlock, replaced by mutex
81 * - racy handling of timer in disconnect,
82 * replaced by delayed_work
83 * - racy interruptible_sleep_on(),
84 * replaced with wait_event_interruptible()
85 * - handle signals in read()
86 * 2008-02-08 Tobias Lorenz <tobias.lorenz@gmx.net>
87 * Oliver Neukum <oliver@neukum.org>
88 * Version 1.0.7
89 * - usb autosuspend support
90 * - unplugging fixed
91 * 2008-05-07 Tobias Lorenz <tobias.lorenz@gmx.net>
92 * Version 1.0.8
93 * - hardware frequency seek support
94 * - afc indication
95 * - more safety checks, let si470x_get_freq return errno
96 * - vidioc behavior corrected according to v4l2 spec
97 * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com>
98 * - add support for KWorld USB FM Radio FM700
99 * - blacklisted KWorld radio in hid-core.c and hid-ids.h
100 * 2008-12-03 Mark Lord <mlord@pobox.com>
101 * - add support for DealExtreme USB Radio
102 * 2009-01-31 Bob Ross <pigiron@gmx.com>
103 * - correction of stereo detection/setting
104 * - correction of signal strength indicator scaling
105 * 2009-01-31 Rick Bronson <rick@efn.org>
106 * Tobias Lorenz <tobias.lorenz@gmx.net>
107 * - add LED status output
108 * - get HW/SW version from scratchpad
109 *
110 * ToDo:
111 * - add firmware download/update support
112 * - RDS support: interrupt mode, instead of polling
113 */
114
115
116/* driver definitions */
117#define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>"
118#define DRIVER_NAME "radio-si470x"
119#define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 9)
120#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
121#define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"
122#define DRIVER_VERSION "1.0.9"
123
124
125/* kernel includes */
126#include <linux/kernel.h>
127#include <linux/module.h>
128#include <linux/init.h>
129#include <linux/slab.h>
130#include <linux/smp_lock.h>
131#include <linux/input.h>
132#include <linux/usb.h>
133#include <linux/hid.h>
134#include <linux/version.h>
135#include <linux/videodev2.h>
136#include <linux/mutex.h>
137#include <media/v4l2-common.h>
138#include <media/v4l2-ioctl.h>
139#include <media/rds.h>
140#include <asm/unaligned.h>
141
142
143/* USB Device ID List */
144static struct usb_device_id si470x_usb_driver_id_table[] = {
145 /* Silicon Labs USB FM Radio Reference Design */
146 { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) },
147 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */
148 { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) },
149 /* KWorld USB FM Radio SnapMusic Mobile 700 (FM700) */
150 { USB_DEVICE_AND_INTERFACE_INFO(0x1b80, 0xd700, USB_CLASS_HID, 0, 0) },
151 /* Sanei Electric, Inc. FM USB Radio (sold as DealExtreme.com PCear) */
152 { USB_DEVICE_AND_INTERFACE_INFO(0x10c5, 0x819a, USB_CLASS_HID, 0, 0) },
153 /* Terminating entry */
154 { }
155};
156MODULE_DEVICE_TABLE(usb, si470x_usb_driver_id_table);
157
158
159
160/**************************************************************************
161 * Module Parameters
162 **************************************************************************/
163
164/* Radio Nr */
165static int radio_nr = -1;
166module_param(radio_nr, int, 0444);
167MODULE_PARM_DESC(radio_nr, "Radio Nr");
168
169/* Spacing (kHz) */
170/* 0: 200 kHz (USA, Australia) */
171/* 1: 100 kHz (Europe, Japan) */
172/* 2: 50 kHz */
173static unsigned short space = 2;
174module_param(space, ushort, 0444);
175MODULE_PARM_DESC(space, "Spacing: 0=200kHz 1=100kHz *2=50kHz*");
176
177/* Bottom of Band (MHz) */
178/* 0: 87.5 - 108 MHz (USA, Europe)*/
179/* 1: 76 - 108 MHz (Japan wide band) */
180/* 2: 76 - 90 MHz (Japan) */
181static unsigned short band = 1;
182module_param(band, ushort, 0444);
183MODULE_PARM_DESC(band, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz");
184
185/* De-emphasis */
186/* 0: 75 us (USA) */
187/* 1: 50 us (Europe, Australia, Japan) */
188static unsigned short de = 1;
189module_param(de, ushort, 0444);
190MODULE_PARM_DESC(de, "De-emphasis: 0=75us *1=50us*");
191
192/* USB timeout */
193static unsigned int usb_timeout = 500;
194module_param(usb_timeout, uint, 0644);
195MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*");
196
197/* Tune timeout */
198static unsigned int tune_timeout = 3000;
199module_param(tune_timeout, uint, 0644);
200MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*");
201
202/* Seek timeout */
203static unsigned int seek_timeout = 5000;
204module_param(seek_timeout, uint, 0644);
205MODULE_PARM_DESC(seek_timeout, "Seek timeout: *5000*");
206
207/* RDS buffer blocks */
208static unsigned int rds_buf = 100;
209module_param(rds_buf, uint, 0444);
210MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*");
211
212/* RDS maximum block errors */
213static unsigned short max_rds_errors = 1;
214/* 0 means 0 errors requiring correction */
215/* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */
216/* 2 means 3-5 errors requiring correction */
217/* 3 means 6+ errors or errors in checkword, correction not possible */
218module_param(max_rds_errors, ushort, 0644);
219MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*");
220
221/* RDS poll frequency */
222static unsigned int rds_poll_time = 40;
223/* 40 is used by the original USBRadio.exe */
224/* 50 is used by radio-cadet */
225/* 75 should be okay */
226/* 80 is the usual RDS receive interval */
227module_param(rds_poll_time, uint, 0644);
228MODULE_PARM_DESC(rds_poll_time, "RDS poll time (ms): *40*");
229
230
231
232/**************************************************************************
233 * Register Definitions
234 **************************************************************************/
235#define RADIO_REGISTER_SIZE 2 /* 16 register bit width */
236#define RADIO_REGISTER_NUM 16 /* DEVICEID ... RDSD */
237#define RDS_REGISTER_NUM 6 /* STATUSRSSI ... RDSD */
238
239#define DEVICEID 0 /* Device ID */
240#define DEVICEID_PN 0xf000 /* bits 15..12: Part Number */
241#define DEVICEID_MFGID 0x0fff /* bits 11..00: Manufacturer ID */
242
243#define CHIPID 1 /* Chip ID */
244#define CHIPID_REV 0xfc00 /* bits 15..10: Chip Version */
245#define CHIPID_DEV 0x0200 /* bits 09..09: Device */
246#define CHIPID_FIRMWARE 0x01ff /* bits 08..00: Firmware Version */
247
248#define POWERCFG 2 /* Power Configuration */
249#define POWERCFG_DSMUTE 0x8000 /* bits 15..15: Softmute Disable */
250#define POWERCFG_DMUTE 0x4000 /* bits 14..14: Mute Disable */
251#define POWERCFG_MONO 0x2000 /* bits 13..13: Mono Select */
252#define POWERCFG_RDSM 0x0800 /* bits 11..11: RDS Mode (Si4701 only) */
253#define POWERCFG_SKMODE 0x0400 /* bits 10..10: Seek Mode */
254#define POWERCFG_SEEKUP 0x0200 /* bits 09..09: Seek Direction */
255#define POWERCFG_SEEK 0x0100 /* bits 08..08: Seek */
256#define POWERCFG_DISABLE 0x0040 /* bits 06..06: Powerup Disable */
257#define POWERCFG_ENABLE 0x0001 /* bits 00..00: Powerup Enable */
258
259#define CHANNEL 3 /* Channel */
260#define CHANNEL_TUNE 0x8000 /* bits 15..15: Tune */
261#define CHANNEL_CHAN 0x03ff /* bits 09..00: Channel Select */
262
263#define SYSCONFIG1 4 /* System Configuration 1 */
264#define SYSCONFIG1_RDSIEN 0x8000 /* bits 15..15: RDS Interrupt Enable (Si4701 only) */
265#define SYSCONFIG1_STCIEN 0x4000 /* bits 14..14: Seek/Tune Complete Interrupt Enable */
266#define SYSCONFIG1_RDS 0x1000 /* bits 12..12: RDS Enable (Si4701 only) */
267#define SYSCONFIG1_DE 0x0800 /* bits 11..11: De-emphasis (0=75us 1=50us) */
268#define SYSCONFIG1_AGCD 0x0400 /* bits 10..10: AGC Disable */
269#define SYSCONFIG1_BLNDADJ 0x00c0 /* bits 07..06: Stereo/Mono Blend Level Adjustment */
270#define SYSCONFIG1_GPIO3 0x0030 /* bits 05..04: General Purpose I/O 3 */
271#define SYSCONFIG1_GPIO2 0x000c /* bits 03..02: General Purpose I/O 2 */
272#define SYSCONFIG1_GPIO1 0x0003 /* bits 01..00: General Purpose I/O 1 */
273
274#define SYSCONFIG2 5 /* System Configuration 2 */
275#define SYSCONFIG2_SEEKTH 0xff00 /* bits 15..08: RSSI Seek Threshold */
276#define SYSCONFIG2_BAND 0x0080 /* bits 07..06: Band Select */
277#define SYSCONFIG2_SPACE 0x0030 /* bits 05..04: Channel Spacing */
278#define SYSCONFIG2_VOLUME 0x000f /* bits 03..00: Volume */
279
280#define SYSCONFIG3 6 /* System Configuration 3 */
281#define SYSCONFIG3_SMUTER 0xc000 /* bits 15..14: Softmute Attack/Recover Rate */
282#define SYSCONFIG3_SMUTEA 0x3000 /* bits 13..12: Softmute Attenuation */
283#define SYSCONFIG3_SKSNR 0x00f0 /* bits 07..04: Seek SNR Threshold */
284#define SYSCONFIG3_SKCNT 0x000f /* bits 03..00: Seek FM Impulse Detection Threshold */
285
286#define TEST1 7 /* Test 1 */
287#define TEST1_AHIZEN 0x4000 /* bits 14..14: Audio High-Z Enable */
288
289#define TEST2 8 /* Test 2 */
290/* TEST2 only contains reserved bits */
291
292#define BOOTCONFIG 9 /* Boot Configuration */
293/* BOOTCONFIG only contains reserved bits */
294
295#define STATUSRSSI 10 /* Status RSSI */
296#define STATUSRSSI_RDSR 0x8000 /* bits 15..15: RDS Ready (Si4701 only) */
297#define STATUSRSSI_STC 0x4000 /* bits 14..14: Seek/Tune Complete */
298#define STATUSRSSI_SF 0x2000 /* bits 13..13: Seek Fail/Band Limit */
299#define STATUSRSSI_AFCRL 0x1000 /* bits 12..12: AFC Rail */
300#define STATUSRSSI_RDSS 0x0800 /* bits 11..11: RDS Synchronized (Si4701 only) */
301#define STATUSRSSI_BLERA 0x0600 /* bits 10..09: RDS Block A Errors (Si4701 only) */
302#define STATUSRSSI_ST 0x0100 /* bits 08..08: Stereo Indicator */
303#define STATUSRSSI_RSSI 0x00ff /* bits 07..00: RSSI (Received Signal Strength Indicator) */
304
305#define READCHAN 11 /* Read Channel */
306#define READCHAN_BLERB 0xc000 /* bits 15..14: RDS Block D Errors (Si4701 only) */
307#define READCHAN_BLERC 0x3000 /* bits 13..12: RDS Block C Errors (Si4701 only) */
308#define READCHAN_BLERD 0x0c00 /* bits 11..10: RDS Block B Errors (Si4701 only) */
309#define READCHAN_READCHAN 0x03ff /* bits 09..00: Read Channel */
310
311#define RDSA 12 /* RDSA */
312#define RDSA_RDSA 0xffff /* bits 15..00: RDS Block A Data (Si4701 only) */
313
314#define RDSB 13 /* RDSB */
315#define RDSB_RDSB 0xffff /* bits 15..00: RDS Block B Data (Si4701 only) */
316
317#define RDSC 14 /* RDSC */
318#define RDSC_RDSC 0xffff /* bits 15..00: RDS Block C Data (Si4701 only) */
319
320#define RDSD 15 /* RDSD */
321#define RDSD_RDSD 0xffff /* bits 15..00: RDS Block D Data (Si4701 only) */
322
323
324
325/**************************************************************************
326 * USB HID Reports
327 **************************************************************************/
328
329/* Reports 1-16 give direct read/write access to the 16 Si470x registers */
330/* with the (REPORT_ID - 1) corresponding to the register address across USB */
331/* endpoint 0 using GET_REPORT and SET_REPORT */
332#define REGISTER_REPORT_SIZE (RADIO_REGISTER_SIZE + 1)
333#define REGISTER_REPORT(reg) ((reg) + 1)
334
335/* Report 17 gives direct read/write access to the entire Si470x register */
336/* map across endpoint 0 using GET_REPORT and SET_REPORT */
337#define ENTIRE_REPORT_SIZE (RADIO_REGISTER_NUM * RADIO_REGISTER_SIZE + 1)
338#define ENTIRE_REPORT 17
339
340/* Report 18 is used to send the lowest 6 Si470x registers up the HID */
341/* interrupt endpoint 1 to Windows every 20 milliseconds for status */
342#define RDS_REPORT_SIZE (RDS_REGISTER_NUM * RADIO_REGISTER_SIZE + 1)
343#define RDS_REPORT 18
344
345/* Report 19: LED state */
346#define LED_REPORT_SIZE 3
347#define LED_REPORT 19
348
349/* Report 19: stream */
350#define STREAM_REPORT_SIZE 3
351#define STREAM_REPORT 19
352
353/* Report 20: scratch */
354#define SCRATCH_PAGE_SIZE 63
355#define SCRATCH_REPORT_SIZE (SCRATCH_PAGE_SIZE + 1)
356#define SCRATCH_REPORT 20
357
358/* Reports 19-22: flash upgrade of the C8051F321 */
359#define WRITE_REPORT_SIZE 4
360#define WRITE_REPORT 19
361#define FLASH_REPORT_SIZE 64
362#define FLASH_REPORT 20
363#define CRC_REPORT_SIZE 3
364#define CRC_REPORT 21
365#define RESPONSE_REPORT_SIZE 2
366#define RESPONSE_REPORT 22
367
368/* Report 23: currently unused, but can accept 60 byte reports on the HID */
369/* interrupt out endpoint 2 every 1 millisecond */
370#define UNUSED_REPORT 23
371
372
373
374/**************************************************************************
375 * Software/Hardware Versions
376 **************************************************************************/
377#define RADIO_SW_VERSION_NOT_BOOTLOADABLE 6
378#define RADIO_SW_VERSION 7
379#define RADIO_SW_VERSION_CURRENT 15
380#define RADIO_HW_VERSION 1
381
382#define SCRATCH_PAGE_SW_VERSION 1
383#define SCRATCH_PAGE_HW_VERSION 2
384
385
386
387/**************************************************************************
388 * LED State Definitions
389 **************************************************************************/
390#define LED_COMMAND 0x35
391
392#define NO_CHANGE_LED 0x00
393#define ALL_COLOR_LED 0x01 /* streaming state */
394#define BLINK_GREEN_LED 0x02 /* connect state */
395#define BLINK_RED_LED 0x04
396#define BLINK_ORANGE_LED 0x10 /* disconnect state */
397#define SOLID_GREEN_LED 0x20 /* tuning/seeking state */
398#define SOLID_RED_LED 0x40 /* bootload state */
399#define SOLID_ORANGE_LED 0x80
400
401
402
403/**************************************************************************
404 * Stream State Definitions
405 **************************************************************************/
406#define STREAM_COMMAND 0x36
407#define STREAM_VIDPID 0x00
408#define STREAM_AUDIO 0xff
409
410
411
412/**************************************************************************
413 * Bootloader / Flash Commands
414 **************************************************************************/
415
416/* unique id sent to bootloader and required to put into a bootload state */
417#define UNIQUE_BL_ID 0x34
418
419/* mask for the flash data */
420#define FLASH_DATA_MASK 0x55
421
422/* bootloader commands */
423#define GET_SW_VERSION_COMMAND 0x00
424#define SET_PAGE_COMMAND 0x01
425#define ERASE_PAGE_COMMAND 0x02
426#define WRITE_PAGE_COMMAND 0x03
427#define CRC_ON_PAGE_COMMAND 0x04
428#define READ_FLASH_BYTE_COMMAND 0x05
429#define RESET_DEVICE_COMMAND 0x06
430#define GET_HW_VERSION_COMMAND 0x07
431#define BLANK 0xff
432
433/* bootloader command responses */
434#define COMMAND_OK 0x01
435#define COMMAND_FAILED 0x02
436#define COMMAND_PENDING 0x03
437
438
439
440/**************************************************************************
441 * General Driver Definitions
442 **************************************************************************/
443
444/*
445 * si470x_device - private data
446 */
447struct si470x_device {
448 /* reference to USB and video device */
449 struct usb_device *usbdev;
450 struct usb_interface *intf;
451 struct video_device *videodev;
452
453 /* driver management */
454 unsigned int users;
455 unsigned char disconnected;
456 struct mutex disconnect_lock;
457
458 /* Silabs internal registers (0..15) */
459 unsigned short registers[RADIO_REGISTER_NUM];
460
461 /* RDS receive buffer */
462 struct delayed_work work;
463 wait_queue_head_t read_queue;
464 struct mutex lock; /* buffer locking */
465 unsigned char *buffer; /* size is always multiple of three */
466 unsigned int buf_size;
467 unsigned int rd_index;
468 unsigned int wr_index;
469
470 /* scratch page */
471 unsigned char software_version;
472 unsigned char hardware_version;
473};
474
475
476/*
477 * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW,
478 * 62.5 kHz otherwise.
479 * The tuner is able to have a channel spacing of 50, 100 or 200 kHz.
480 * tuner->capability is therefore set to V4L2_TUNER_CAP_LOW
481 * The FREQ_MUL is then: 1 MHz / 62.5 Hz = 16000
482 */
483#define FREQ_MUL (1000000 / 62.5)
484
485
486
487/**************************************************************************
488 * General Driver Functions - REGISTER_REPORTs
489 **************************************************************************/
490
491/*
492 * si470x_get_report - receive a HID report
493 */
494static int si470x_get_report(struct si470x_device *radio, void *buf, int size)
495{
496 unsigned char *report = (unsigned char *) buf;
497 int retval;
498
499 retval = usb_control_msg(radio->usbdev,
500 usb_rcvctrlpipe(radio->usbdev, 0),
501 HID_REQ_GET_REPORT,
502 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
503 report[0], 2,
504 buf, size, usb_timeout);
505
506 if (retval < 0)
507 printk(KERN_WARNING DRIVER_NAME
508 ": si470x_get_report: usb_control_msg returned %d\n",
509 retval);
510 return retval;
511}
512
513
514/*
515 * si470x_set_report - send a HID report
516 */
517static int si470x_set_report(struct si470x_device *radio, void *buf, int size)
518{
519 unsigned char *report = (unsigned char *) buf;
520 int retval;
521
522 retval = usb_control_msg(radio->usbdev,
523 usb_sndctrlpipe(radio->usbdev, 0),
524 HID_REQ_SET_REPORT,
525 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
526 report[0], 2,
527 buf, size, usb_timeout);
528
529 if (retval < 0)
530 printk(KERN_WARNING DRIVER_NAME
531 ": si470x_set_report: usb_control_msg returned %d\n",
532 retval);
533 return retval;
534}
535
536
537/*
538 * si470x_get_register - read register
539 */
540static int si470x_get_register(struct si470x_device *radio, int regnr)
541{
542 unsigned char buf[REGISTER_REPORT_SIZE];
543 int retval;
544
545 buf[0] = REGISTER_REPORT(regnr);
546
547 retval = si470x_get_report(radio, (void *) &buf, sizeof(buf));
548
549 if (retval >= 0)
550 radio->registers[regnr] = get_unaligned_be16(&buf[1]);
551
552 return (retval < 0) ? -EINVAL : 0;
553}
554
555
556/*
557 * si470x_set_register - write register
558 */
559static int si470x_set_register(struct si470x_device *radio, int regnr)
560{
561 unsigned char buf[REGISTER_REPORT_SIZE];
562 int retval;
563
564 buf[0] = REGISTER_REPORT(regnr);
565 put_unaligned_be16(radio->registers[regnr], &buf[1]);
566
567 retval = si470x_set_report(radio, (void *) &buf, sizeof(buf));
568
569 return (retval < 0) ? -EINVAL : 0;
570}
571
572
573/*
574 * si470x_set_chan - set the channel
575 */
576static int si470x_set_chan(struct si470x_device *radio, unsigned short chan)
577{
578 int retval;
579 unsigned long timeout;
580 bool timed_out = 0;
581
582 /* start tuning */
583 radio->registers[CHANNEL] &= ~CHANNEL_CHAN;
584 radio->registers[CHANNEL] |= CHANNEL_TUNE | chan;
585 retval = si470x_set_register(radio, CHANNEL);
586 if (retval < 0)
587 goto done;
588
589 /* wait till tune operation has completed */
590 timeout = jiffies + msecs_to_jiffies(tune_timeout);
591 do {
592 retval = si470x_get_register(radio, STATUSRSSI);
593 if (retval < 0)
594 goto stop;
595 timed_out = time_after(jiffies, timeout);
596 } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) &&
597 (!timed_out));
598 if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0)
599 printk(KERN_WARNING DRIVER_NAME ": tune does not complete\n");
600 if (timed_out)
601 printk(KERN_WARNING DRIVER_NAME
602 ": tune timed out after %u ms\n", tune_timeout);
603
604stop:
605 /* stop tuning */
606 radio->registers[CHANNEL] &= ~CHANNEL_TUNE;
607 retval = si470x_set_register(radio, CHANNEL);
608
609done:
610 return retval;
611}
612
613
614/*
615 * si470x_get_freq - get the frequency
616 */
617static int si470x_get_freq(struct si470x_device *radio, unsigned int *freq)
618{
619 unsigned int spacing, band_bottom;
620 unsigned short chan;
621 int retval;
622
623 /* Spacing (kHz) */
624 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) {
625 /* 0: 200 kHz (USA, Australia) */
626 case 0:
627 spacing = 0.200 * FREQ_MUL; break;
628 /* 1: 100 kHz (Europe, Japan) */
629 case 1:
630 spacing = 0.100 * FREQ_MUL; break;
631 /* 2: 50 kHz */
632 default:
633 spacing = 0.050 * FREQ_MUL; break;
634 };
635
636 /* Bottom of Band (MHz) */
637 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
638 /* 0: 87.5 - 108 MHz (USA, Europe) */
639 case 0:
640 band_bottom = 87.5 * FREQ_MUL; break;
641 /* 1: 76 - 108 MHz (Japan wide band) */
642 default:
643 band_bottom = 76 * FREQ_MUL; break;
644 /* 2: 76 - 90 MHz (Japan) */
645 case 2:
646 band_bottom = 76 * FREQ_MUL; break;
647 };
648
649 /* read channel */
650 retval = si470x_get_register(radio, READCHAN);
651 chan = radio->registers[READCHAN] & READCHAN_READCHAN;
652
653 /* Frequency (MHz) = Spacing (kHz) x Channel + Bottom of Band (MHz) */
654 *freq = chan * spacing + band_bottom;
655
656 return retval;
657}
658
659
660/*
661 * si470x_set_freq - set the frequency
662 */
663static int si470x_set_freq(struct si470x_device *radio, unsigned int freq)
664{
665 unsigned int spacing, band_bottom;
666 unsigned short chan;
667
668 /* Spacing (kHz) */
669 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) {
670 /* 0: 200 kHz (USA, Australia) */
671 case 0:
672 spacing = 0.200 * FREQ_MUL; break;
673 /* 1: 100 kHz (Europe, Japan) */
674 case 1:
675 spacing = 0.100 * FREQ_MUL; break;
676 /* 2: 50 kHz */
677 default:
678 spacing = 0.050 * FREQ_MUL; break;
679 };
680
681 /* Bottom of Band (MHz) */
682 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
683 /* 0: 87.5 - 108 MHz (USA, Europe) */
684 case 0:
685 band_bottom = 87.5 * FREQ_MUL; break;
686 /* 1: 76 - 108 MHz (Japan wide band) */
687 default:
688 band_bottom = 76 * FREQ_MUL; break;
689 /* 2: 76 - 90 MHz (Japan) */
690 case 2:
691 band_bottom = 76 * FREQ_MUL; break;
692 };
693
694 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */
695 chan = (freq - band_bottom) / spacing;
696
697 return si470x_set_chan(radio, chan);
698}
699
700
701/*
702 * si470x_set_seek - set seek
703 */
704static int si470x_set_seek(struct si470x_device *radio,
705 unsigned int wrap_around, unsigned int seek_upward)
706{
707 int retval = 0;
708 unsigned long timeout;
709 bool timed_out = 0;
710
711 /* start seeking */
712 radio->registers[POWERCFG] |= POWERCFG_SEEK;
713 if (wrap_around == 1)
714 radio->registers[POWERCFG] &= ~POWERCFG_SKMODE;
715 else
716 radio->registers[POWERCFG] |= POWERCFG_SKMODE;
717 if (seek_upward == 1)
718 radio->registers[POWERCFG] |= POWERCFG_SEEKUP;
719 else
720 radio->registers[POWERCFG] &= ~POWERCFG_SEEKUP;
721 retval = si470x_set_register(radio, POWERCFG);
722 if (retval < 0)
723 goto done;
724
725 /* wait till seek operation has completed */
726 timeout = jiffies + msecs_to_jiffies(seek_timeout);
727 do {
728 retval = si470x_get_register(radio, STATUSRSSI);
729 if (retval < 0)
730 goto stop;
731 timed_out = time_after(jiffies, timeout);
732 } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) &&
733 (!timed_out));
734 if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0)
735 printk(KERN_WARNING DRIVER_NAME ": seek does not complete\n");
736 if (radio->registers[STATUSRSSI] & STATUSRSSI_SF)
737 printk(KERN_WARNING DRIVER_NAME
738 ": seek failed / band limit reached\n");
739 if (timed_out)
740 printk(KERN_WARNING DRIVER_NAME
741 ": seek timed out after %u ms\n", seek_timeout);
742
743stop:
744 /* stop seeking */
745 radio->registers[POWERCFG] &= ~POWERCFG_SEEK;
746 retval = si470x_set_register(radio, POWERCFG);
747
748done:
749 /* try again, if timed out */
750 if ((retval == 0) && timed_out)
751 retval = -EAGAIN;
752
753 return retval;
754}
755
756
757/*
758 * si470x_start - switch on radio
759 */
760static int si470x_start(struct si470x_device *radio)
761{
762 int retval;
763
764 /* powercfg */
765 radio->registers[POWERCFG] =
766 POWERCFG_DMUTE | POWERCFG_ENABLE | POWERCFG_RDSM;
767 retval = si470x_set_register(radio, POWERCFG);
768 if (retval < 0)
769 goto done;
770
771 /* sysconfig 1 */
772 radio->registers[SYSCONFIG1] = SYSCONFIG1_DE;
773 retval = si470x_set_register(radio, SYSCONFIG1);
774 if (retval < 0)
775 goto done;
776
777 /* sysconfig 2 */
778 radio->registers[SYSCONFIG2] =
779 (0x3f << 8) | /* SEEKTH */
780 ((band << 6) & SYSCONFIG2_BAND) | /* BAND */
781 ((space << 4) & SYSCONFIG2_SPACE) | /* SPACE */
782 15; /* VOLUME (max) */
783 retval = si470x_set_register(radio, SYSCONFIG2);
784 if (retval < 0)
785 goto done;
786
787 /* reset last channel */
788 retval = si470x_set_chan(radio,
789 radio->registers[CHANNEL] & CHANNEL_CHAN);
790
791done:
792 return retval;
793}
794
795
796/*
797 * si470x_stop - switch off radio
798 */
799static int si470x_stop(struct si470x_device *radio)
800{
801 int retval;
802
803 /* sysconfig 1 */
804 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS;
805 retval = si470x_set_register(radio, SYSCONFIG1);
806 if (retval < 0)
807 goto done;
808
809 /* powercfg */
810 radio->registers[POWERCFG] &= ~POWERCFG_DMUTE;
811 /* POWERCFG_ENABLE has to automatically go low */
812 radio->registers[POWERCFG] |= POWERCFG_ENABLE | POWERCFG_DISABLE;
813 retval = si470x_set_register(radio, POWERCFG);
814
815done:
816 return retval;
817}
818
819
820/*
821 * si470x_rds_on - switch on rds reception
822 */
823static int si470x_rds_on(struct si470x_device *radio)
824{
825 int retval;
826
827 /* sysconfig 1 */
828 mutex_lock(&radio->lock);
829 radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDS;
830 retval = si470x_set_register(radio, SYSCONFIG1);
831 if (retval < 0)
832 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS;
833 mutex_unlock(&radio->lock);
834
835 return retval;
836}
837
838
839
840/**************************************************************************
841 * General Driver Functions - ENTIRE_REPORT
842 **************************************************************************/
843
844/*
845 * si470x_get_all_registers - read entire registers
846 */
847static int si470x_get_all_registers(struct si470x_device *radio)
848{
849 unsigned char buf[ENTIRE_REPORT_SIZE];
850 int retval;
851 unsigned char regnr;
852
853 buf[0] = ENTIRE_REPORT;
854
855 retval = si470x_get_report(radio, (void *) &buf, sizeof(buf));
856
857 if (retval >= 0)
858 for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++)
859 radio->registers[regnr] = get_unaligned_be16(
860 &buf[regnr * RADIO_REGISTER_SIZE + 1]);
861
862 return (retval < 0) ? -EINVAL : 0;
863}
864
865
866
867/**************************************************************************
868 * General Driver Functions - RDS_REPORT
869 **************************************************************************/
870
871/*
872 * si470x_get_rds_registers - read rds registers
873 */
874static int si470x_get_rds_registers(struct si470x_device *radio)
875{
876 unsigned char buf[RDS_REPORT_SIZE];
877 int retval;
878 int size;
879 unsigned char regnr;
880
881 buf[0] = RDS_REPORT;
882
883 retval = usb_interrupt_msg(radio->usbdev,
884 usb_rcvintpipe(radio->usbdev, 1),
885 (void *) &buf, sizeof(buf), &size, usb_timeout);
886 if (size != sizeof(buf))
887 printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: "
888 "return size differs: %d != %zu\n", size, sizeof(buf));
889 if (retval < 0)
890 printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: "
891 "usb_interrupt_msg returned %d\n", retval);
892
893 if (retval >= 0)
894 for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++)
895 radio->registers[STATUSRSSI + regnr] =
896 get_unaligned_be16(
897 &buf[regnr * RADIO_REGISTER_SIZE + 1]);
898
899 return (retval < 0) ? -EINVAL : 0;
900}
901
902
903
904/**************************************************************************
905 * General Driver Functions - LED_REPORT
906 **************************************************************************/
907
908/*
909 * si470x_set_led_state - sets the led state
910 */
911static int si470x_set_led_state(struct si470x_device *radio,
912 unsigned char led_state)
913{
914 unsigned char buf[LED_REPORT_SIZE];
915 int retval;
916
917 buf[0] = LED_REPORT;
918 buf[1] = LED_COMMAND;
919 buf[2] = led_state;
920
921 retval = si470x_set_report(radio, (void *) &buf, sizeof(buf));
922
923 return (retval < 0) ? -EINVAL : 0;
924}
925
926
927
928/**************************************************************************
929 * General Driver Functions - SCRATCH_REPORT
930 **************************************************************************/
931
932/*
933 * si470x_get_scratch_versions - gets the scratch page and version infos
934 */
935static int si470x_get_scratch_page_versions(struct si470x_device *radio)
936{
937 unsigned char buf[SCRATCH_REPORT_SIZE];
938 int retval;
939
940 buf[0] = SCRATCH_REPORT;
941
942 retval = si470x_get_report(radio, (void *) &buf, sizeof(buf));
943
944 if (retval < 0)
945 printk(KERN_WARNING DRIVER_NAME ": si470x_get_scratch: "
946 "si470x_get_report returned %d\n", retval);
947 else {
948 radio->software_version = buf[1];
949 radio->hardware_version = buf[2];
950 }
951
952 return (retval < 0) ? -EINVAL : 0;
953}
954
955
956
957/**************************************************************************
958 * RDS Driver Functions
959 **************************************************************************/
960
961/*
962 * si470x_rds - rds processing function
963 */
964static void si470x_rds(struct si470x_device *radio)
965{
966 unsigned char blocknum;
967 unsigned short bler; /* rds block errors */
968 unsigned short rds;
969 unsigned char tmpbuf[3];
970
971 /* get rds blocks */
972 if (si470x_get_rds_registers(radio) < 0)
973 return;
974 if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSR) == 0) {
975 /* No RDS group ready */
976 return;
977 }
978 if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSS) == 0) {
979 /* RDS decoder not synchronized */
980 return;
981 }
982
983 /* copy all four RDS blocks to internal buffer */
984 mutex_lock(&radio->lock);
985 for (blocknum = 0; blocknum < 4; blocknum++) {
986 switch (blocknum) {
987 default:
988 bler = (radio->registers[STATUSRSSI] &
989 STATUSRSSI_BLERA) >> 9;
990 rds = radio->registers[RDSA];
991 break;
992 case 1:
993 bler = (radio->registers[READCHAN] &
994 READCHAN_BLERB) >> 14;
995 rds = radio->registers[RDSB];
996 break;
997 case 2:
998 bler = (radio->registers[READCHAN] &
999 READCHAN_BLERC) >> 12;
1000 rds = radio->registers[RDSC];
1001 break;
1002 case 3:
1003 bler = (radio->registers[READCHAN] &
1004 READCHAN_BLERD) >> 10;
1005 rds = radio->registers[RDSD];
1006 break;
1007 };
1008
1009 /* Fill the V4L2 RDS buffer */
1010 put_unaligned_le16(rds, &tmpbuf);
1011 tmpbuf[2] = blocknum; /* offset name */
1012 tmpbuf[2] |= blocknum << 3; /* received offset */
1013 if (bler > max_rds_errors)
1014 tmpbuf[2] |= 0x80; /* uncorrectable errors */
1015 else if (bler > 0)
1016 tmpbuf[2] |= 0x40; /* corrected error(s) */
1017
1018 /* copy RDS block to internal buffer */
1019 memcpy(&radio->buffer[radio->wr_index], &tmpbuf, 3);
1020 radio->wr_index += 3;
1021
1022 /* wrap write pointer */
1023 if (radio->wr_index >= radio->buf_size)
1024 radio->wr_index = 0;
1025
1026 /* check for overflow */
1027 if (radio->wr_index == radio->rd_index) {
1028 /* increment and wrap read pointer */
1029 radio->rd_index += 3;
1030 if (radio->rd_index >= radio->buf_size)
1031 radio->rd_index = 0;
1032 }
1033 }
1034 mutex_unlock(&radio->lock);
1035
1036 /* wake up read queue */
1037 if (radio->wr_index != radio->rd_index)
1038 wake_up_interruptible(&radio->read_queue);
1039}
1040
1041
1042/*
1043 * si470x_work - rds work function
1044 */
1045static void si470x_work(struct work_struct *work)
1046{
1047 struct si470x_device *radio = container_of(work, struct si470x_device,
1048 work.work);
1049
1050 /* safety checks */
1051 if (radio->disconnected)
1052 return;
1053 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
1054 return;
1055
1056 si470x_rds(radio);
1057 schedule_delayed_work(&radio->work, msecs_to_jiffies(rds_poll_time));
1058}
1059
1060
1061
1062/**************************************************************************
1063 * File Operations Interface
1064 **************************************************************************/
1065
1066/*
1067 * si470x_fops_read - read RDS data
1068 */
1069static ssize_t si470x_fops_read(struct file *file, char __user *buf,
1070 size_t count, loff_t *ppos)
1071{
1072 struct si470x_device *radio = video_drvdata(file);
1073 int retval = 0;
1074 unsigned int block_count = 0;
1075
1076 /* switch on rds reception */
1077 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) {
1078 si470x_rds_on(radio);
1079 schedule_delayed_work(&radio->work,
1080 msecs_to_jiffies(rds_poll_time));
1081 }
1082
1083 /* block if no new data available */
1084 while (radio->wr_index == radio->rd_index) {
1085 if (file->f_flags & O_NONBLOCK) {
1086 retval = -EWOULDBLOCK;
1087 goto done;
1088 }
1089 if (wait_event_interruptible(radio->read_queue,
1090 radio->wr_index != radio->rd_index) < 0) {
1091 retval = -EINTR;
1092 goto done;
1093 }
1094 }
1095
1096 /* calculate block count from byte count */
1097 count /= 3;
1098
1099 /* copy RDS block out of internal buffer and to user buffer */
1100 mutex_lock(&radio->lock);
1101 while (block_count < count) {
1102 if (radio->rd_index == radio->wr_index)
1103 break;
1104
1105 /* always transfer rds complete blocks */
1106 if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
1107 /* retval = -EFAULT; */
1108 break;
1109
1110 /* increment and wrap read pointer */
1111 radio->rd_index += 3;
1112 if (radio->rd_index >= radio->buf_size)
1113 radio->rd_index = 0;
1114
1115 /* increment counters */
1116 block_count++;
1117 buf += 3;
1118 retval += 3;
1119 }
1120 mutex_unlock(&radio->lock);
1121
1122done:
1123 return retval;
1124}
1125
1126
1127/*
1128 * si470x_fops_poll - poll RDS data
1129 */
1130static unsigned int si470x_fops_poll(struct file *file,
1131 struct poll_table_struct *pts)
1132{
1133 struct si470x_device *radio = video_drvdata(file);
1134 int retval = 0;
1135
1136 /* switch on rds reception */
1137 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) {
1138 si470x_rds_on(radio);
1139 schedule_delayed_work(&radio->work,
1140 msecs_to_jiffies(rds_poll_time));
1141 }
1142
1143 poll_wait(file, &radio->read_queue, pts);
1144
1145 if (radio->rd_index != radio->wr_index)
1146 retval = POLLIN | POLLRDNORM;
1147
1148 return retval;
1149}
1150
1151
1152/*
1153 * si470x_fops_open - file open
1154 */
1155static int si470x_fops_open(struct file *file)
1156{
1157 struct si470x_device *radio = video_drvdata(file);
1158 int retval;
1159
1160 lock_kernel();
1161 radio->users++;
1162
1163 retval = usb_autopm_get_interface(radio->intf);
1164 if (retval < 0) {
1165 radio->users--;
1166 retval = -EIO;
1167 goto done;
1168 }
1169
1170 if (radio->users == 1) {
1171 /* start radio */
1172 retval = si470x_start(radio);
1173 if (retval < 0)
1174 usb_autopm_put_interface(radio->intf);
1175 }
1176
1177done:
1178 unlock_kernel();
1179 return retval;
1180}
1181
1182
1183/*
1184 * si470x_fops_release - file release
1185 */
1186static int si470x_fops_release(struct file *file)
1187{
1188 struct si470x_device *radio = video_drvdata(file);
1189 int retval = 0;
1190
1191 /* safety check */
1192 if (!radio) {
1193 retval = -ENODEV;
1194 goto done;
1195 }
1196
1197 mutex_lock(&radio->disconnect_lock);
1198 radio->users--;
1199 if (radio->users == 0) {
1200 if (radio->disconnected) {
1201 video_unregister_device(radio->videodev);
1202 kfree(radio->buffer);
1203 kfree(radio);
1204 goto unlock;
1205 }
1206
1207 /* stop rds reception */
1208 cancel_delayed_work_sync(&radio->work);
1209
1210 /* cancel read processes */
1211 wake_up_interruptible(&radio->read_queue);
1212
1213 /* stop radio */
1214 retval = si470x_stop(radio);
1215 usb_autopm_put_interface(radio->intf);
1216 }
1217unlock:
1218 mutex_unlock(&radio->disconnect_lock);
1219done:
1220 return retval;
1221}
1222
1223
1224/*
1225 * si470x_fops - file operations interface
1226 */
1227static const struct v4l2_file_operations si470x_fops = {
1228 .owner = THIS_MODULE,
1229 .read = si470x_fops_read,
1230 .poll = si470x_fops_poll,
1231 .ioctl = video_ioctl2,
1232 .open = si470x_fops_open,
1233 .release = si470x_fops_release,
1234};
1235
1236
1237
1238/**************************************************************************
1239 * Video4Linux Interface
1240 **************************************************************************/
1241
1242/*
1243 * si470x_v4l2_queryctrl - query control
1244 */
1245static struct v4l2_queryctrl si470x_v4l2_queryctrl[] = {
1246 {
1247 .id = V4L2_CID_AUDIO_VOLUME,
1248 .type = V4L2_CTRL_TYPE_INTEGER,
1249 .name = "Volume",
1250 .minimum = 0,
1251 .maximum = 15,
1252 .step = 1,
1253 .default_value = 15,
1254 },
1255 {
1256 .id = V4L2_CID_AUDIO_MUTE,
1257 .type = V4L2_CTRL_TYPE_BOOLEAN,
1258 .name = "Mute",
1259 .minimum = 0,
1260 .maximum = 1,
1261 .step = 1,
1262 .default_value = 1,
1263 },
1264};
1265
1266
1267/*
1268 * si470x_vidioc_querycap - query device capabilities
1269 */
1270static int si470x_vidioc_querycap(struct file *file, void *priv,
1271 struct v4l2_capability *capability)
1272{
1273 struct si470x_device *radio = video_drvdata(file);
1274
1275 strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
1276 strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
1277 usb_make_path(radio->usbdev, capability->bus_info, sizeof(capability->bus_info));
1278 capability->version = DRIVER_KERNEL_VERSION;
1279 capability->capabilities = V4L2_CAP_HW_FREQ_SEEK |
1280 V4L2_CAP_TUNER | V4L2_CAP_RADIO;
1281
1282 return 0;
1283}
1284
1285
1286/*
1287 * si470x_vidioc_queryctrl - enumerate control items
1288 */
1289static int si470x_vidioc_queryctrl(struct file *file, void *priv,
1290 struct v4l2_queryctrl *qc)
1291{
1292 unsigned char i = 0;
1293 int retval = -EINVAL;
1294
1295 /* abort if qc->id is below V4L2_CID_BASE */
1296 if (qc->id < V4L2_CID_BASE)
1297 goto done;
1298
1299 /* search video control */
1300 for (i = 0; i < ARRAY_SIZE(si470x_v4l2_queryctrl); i++) {
1301 if (qc->id == si470x_v4l2_queryctrl[i].id) {
1302 memcpy(qc, &(si470x_v4l2_queryctrl[i]), sizeof(*qc));
1303 retval = 0; /* found */
1304 break;
1305 }
1306 }
1307
1308 /* disable unsupported base controls */
1309 /* to satisfy kradio and such apps */
1310 if ((retval == -EINVAL) && (qc->id < V4L2_CID_LASTP1)) {
1311 qc->flags = V4L2_CTRL_FLAG_DISABLED;
1312 retval = 0;
1313 }
1314
1315done:
1316 if (retval < 0)
1317 printk(KERN_WARNING DRIVER_NAME
1318 ": query controls failed with %d\n", retval);
1319 return retval;
1320}
1321
1322
1323/*
1324 * si470x_vidioc_g_ctrl - get the value of a control
1325 */
1326static int si470x_vidioc_g_ctrl(struct file *file, void *priv,
1327 struct v4l2_control *ctrl)
1328{
1329 struct si470x_device *radio = video_drvdata(file);
1330 int retval = 0;
1331
1332 /* safety checks */
1333 if (radio->disconnected) {
1334 retval = -EIO;
1335 goto done;
1336 }
1337
1338 switch (ctrl->id) {
1339 case V4L2_CID_AUDIO_VOLUME:
1340 ctrl->value = radio->registers[SYSCONFIG2] &
1341 SYSCONFIG2_VOLUME;
1342 break;
1343 case V4L2_CID_AUDIO_MUTE:
1344 ctrl->value = ((radio->registers[POWERCFG] &
1345 POWERCFG_DMUTE) == 0) ? 1 : 0;
1346 break;
1347 default:
1348 retval = -EINVAL;
1349 }
1350
1351done:
1352 if (retval < 0)
1353 printk(KERN_WARNING DRIVER_NAME
1354 ": get control failed with %d\n", retval);
1355 return retval;
1356}
1357
1358
1359/*
1360 * si470x_vidioc_s_ctrl - set the value of a control
1361 */
1362static int si470x_vidioc_s_ctrl(struct file *file, void *priv,
1363 struct v4l2_control *ctrl)
1364{
1365 struct si470x_device *radio = video_drvdata(file);
1366 int retval = 0;
1367
1368 /* safety checks */
1369 if (radio->disconnected) {
1370 retval = -EIO;
1371 goto done;
1372 }
1373
1374 switch (ctrl->id) {
1375 case V4L2_CID_AUDIO_VOLUME:
1376 radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME;
1377 radio->registers[SYSCONFIG2] |= ctrl->value;
1378 retval = si470x_set_register(radio, SYSCONFIG2);
1379 break;
1380 case V4L2_CID_AUDIO_MUTE:
1381 if (ctrl->value == 1)
1382 radio->registers[POWERCFG] &= ~POWERCFG_DMUTE;
1383 else
1384 radio->registers[POWERCFG] |= POWERCFG_DMUTE;
1385 retval = si470x_set_register(radio, POWERCFG);
1386 break;
1387 default:
1388 retval = -EINVAL;
1389 }
1390
1391done:
1392 if (retval < 0)
1393 printk(KERN_WARNING DRIVER_NAME
1394 ": set control failed with %d\n", retval);
1395 return retval;
1396}
1397
1398
1399/*
1400 * si470x_vidioc_g_audio - get audio attributes
1401 */
1402static int si470x_vidioc_g_audio(struct file *file, void *priv,
1403 struct v4l2_audio *audio)
1404{
1405 /* driver constants */
1406 audio->index = 0;
1407 strcpy(audio->name, "Radio");
1408 audio->capability = V4L2_AUDCAP_STEREO;
1409 audio->mode = 0;
1410
1411 return 0;
1412}
1413
1414
1415/*
1416 * si470x_vidioc_g_tuner - get tuner attributes
1417 */
1418static int si470x_vidioc_g_tuner(struct file *file, void *priv,
1419 struct v4l2_tuner *tuner)
1420{
1421 struct si470x_device *radio = video_drvdata(file);
1422 int retval = 0;
1423
1424 /* safety checks */
1425 if (radio->disconnected) {
1426 retval = -EIO;
1427 goto done;
1428 }
1429 if (tuner->index != 0) {
1430 retval = -EINVAL;
1431 goto done;
1432 }
1433
1434 retval = si470x_get_register(radio, STATUSRSSI);
1435 if (retval < 0)
1436 goto done;
1437
1438 /* driver constants */
1439 strcpy(tuner->name, "FM");
1440 tuner->type = V4L2_TUNER_RADIO;
1441 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
1442
1443 /* range limits */
1444 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
1445 /* 0: 87.5 - 108 MHz (USA, Europe, default) */
1446 default:
1447 tuner->rangelow = 87.5 * FREQ_MUL;
1448 tuner->rangehigh = 108 * FREQ_MUL;
1449 break;
1450 /* 1: 76 - 108 MHz (Japan wide band) */
1451 case 1 :
1452 tuner->rangelow = 76 * FREQ_MUL;
1453 tuner->rangehigh = 108 * FREQ_MUL;
1454 break;
1455 /* 2: 76 - 90 MHz (Japan) */
1456 case 2 :
1457 tuner->rangelow = 76 * FREQ_MUL;
1458 tuner->rangehigh = 90 * FREQ_MUL;
1459 break;
1460 };
1461
1462 /* stereo indicator == stereo (instead of mono) */
1463 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 0)
1464 tuner->rxsubchans = V4L2_TUNER_SUB_MONO;
1465 else
1466 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
1467
1468 /* mono/stereo selector */
1469 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0)
1470 tuner->audmode = V4L2_TUNER_MODE_STEREO;
1471 else
1472 tuner->audmode = V4L2_TUNER_MODE_MONO;
1473
1474 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */
1475 /* measured in units of dbµV in 1 db increments (max at ~75 dbµV) */
1476 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI);
1477 /* the ideal factor is 0xffff/75 = 873,8 */
1478 tuner->signal = (tuner->signal * 873) + (8 * tuner->signal / 10);
1479
1480 /* automatic frequency control: -1: freq to low, 1 freq to high */
1481 /* AFCRL does only indicate that freq. differs, not if too low/high */
1482 tuner->afc = (radio->registers[STATUSRSSI] & STATUSRSSI_AFCRL) ? 1 : 0;
1483
1484done:
1485 if (retval < 0)
1486 printk(KERN_WARNING DRIVER_NAME
1487 ": get tuner failed with %d\n", retval);
1488 return retval;
1489}
1490
1491
1492/*
1493 * si470x_vidioc_s_tuner - set tuner attributes
1494 */
1495static int si470x_vidioc_s_tuner(struct file *file, void *priv,
1496 struct v4l2_tuner *tuner)
1497{
1498 struct si470x_device *radio = video_drvdata(file);
1499 int retval = -EINVAL;
1500
1501 /* safety checks */
1502 if (radio->disconnected) {
1503 retval = -EIO;
1504 goto done;
1505 }
1506 if (tuner->index != 0)
1507 goto done;
1508
1509 /* mono/stereo selector */
1510 switch (tuner->audmode) {
1511 case V4L2_TUNER_MODE_MONO:
1512 radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */
1513 break;
1514 case V4L2_TUNER_MODE_STEREO:
1515 radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */
1516 break;
1517 default:
1518 goto done;
1519 }
1520
1521 retval = si470x_set_register(radio, POWERCFG);
1522
1523done:
1524 if (retval < 0)
1525 printk(KERN_WARNING DRIVER_NAME
1526 ": set tuner failed with %d\n", retval);
1527 return retval;
1528}
1529
1530
1531/*
1532 * si470x_vidioc_g_frequency - get tuner or modulator radio frequency
1533 */
1534static int si470x_vidioc_g_frequency(struct file *file, void *priv,
1535 struct v4l2_frequency *freq)
1536{
1537 struct si470x_device *radio = video_drvdata(file);
1538 int retval = 0;
1539
1540 /* safety checks */
1541 if (radio->disconnected) {
1542 retval = -EIO;
1543 goto done;
1544 }
1545 if (freq->tuner != 0) {
1546 retval = -EINVAL;
1547 goto done;
1548 }
1549
1550 freq->type = V4L2_TUNER_RADIO;
1551 retval = si470x_get_freq(radio, &freq->frequency);
1552
1553done:
1554 if (retval < 0)
1555 printk(KERN_WARNING DRIVER_NAME
1556 ": get frequency failed with %d\n", retval);
1557 return retval;
1558}
1559
1560
1561/*
1562 * si470x_vidioc_s_frequency - set tuner or modulator radio frequency
1563 */
1564static int si470x_vidioc_s_frequency(struct file *file, void *priv,
1565 struct v4l2_frequency *freq)
1566{
1567 struct si470x_device *radio = video_drvdata(file);
1568 int retval = 0;
1569
1570 /* safety checks */
1571 if (radio->disconnected) {
1572 retval = -EIO;
1573 goto done;
1574 }
1575 if (freq->tuner != 0) {
1576 retval = -EINVAL;
1577 goto done;
1578 }
1579
1580 retval = si470x_set_freq(radio, freq->frequency);
1581
1582done:
1583 if (retval < 0)
1584 printk(KERN_WARNING DRIVER_NAME
1585 ": set frequency failed with %d\n", retval);
1586 return retval;
1587}
1588
1589
1590/*
1591 * si470x_vidioc_s_hw_freq_seek - set hardware frequency seek
1592 */
1593static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv,
1594 struct v4l2_hw_freq_seek *seek)
1595{
1596 struct si470x_device *radio = video_drvdata(file);
1597 int retval = 0;
1598
1599 /* safety checks */
1600 if (radio->disconnected) {
1601 retval = -EIO;
1602 goto done;
1603 }
1604 if (seek->tuner != 0) {
1605 retval = -EINVAL;
1606 goto done;
1607 }
1608
1609 retval = si470x_set_seek(radio, seek->wrap_around, seek->seek_upward);
1610
1611done:
1612 if (retval < 0)
1613 printk(KERN_WARNING DRIVER_NAME
1614 ": set hardware frequency seek failed with %d\n",
1615 retval);
1616 return retval;
1617}
1618
1619
1620/*
1621 * si470x_ioctl_ops - video device ioctl operations
1622 */
1623static const struct v4l2_ioctl_ops si470x_ioctl_ops = {
1624 .vidioc_querycap = si470x_vidioc_querycap,
1625 .vidioc_queryctrl = si470x_vidioc_queryctrl,
1626 .vidioc_g_ctrl = si470x_vidioc_g_ctrl,
1627 .vidioc_s_ctrl = si470x_vidioc_s_ctrl,
1628 .vidioc_g_audio = si470x_vidioc_g_audio,
1629 .vidioc_g_tuner = si470x_vidioc_g_tuner,
1630 .vidioc_s_tuner = si470x_vidioc_s_tuner,
1631 .vidioc_g_frequency = si470x_vidioc_g_frequency,
1632 .vidioc_s_frequency = si470x_vidioc_s_frequency,
1633 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek,
1634};
1635
1636
1637/*
1638 * si470x_viddev_template - video device interface
1639 */
1640static struct video_device si470x_viddev_template = {
1641 .fops = &si470x_fops,
1642 .name = DRIVER_NAME,
1643 .release = video_device_release,
1644 .ioctl_ops = &si470x_ioctl_ops,
1645};
1646
1647
1648
1649/**************************************************************************
1650 * USB Interface
1651 **************************************************************************/
1652
1653/*
1654 * si470x_usb_driver_probe - probe for the device
1655 */
1656static int si470x_usb_driver_probe(struct usb_interface *intf,
1657 const struct usb_device_id *id)
1658{
1659 struct si470x_device *radio;
1660 int retval = 0;
1661
1662 /* private data allocation and initialization */
1663 radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);
1664 if (!radio) {
1665 retval = -ENOMEM;
1666 goto err_initial;
1667 }
1668 radio->users = 0;
1669 radio->disconnected = 0;
1670 radio->usbdev = interface_to_usbdev(intf);
1671 radio->intf = intf;
1672 mutex_init(&radio->disconnect_lock);
1673 mutex_init(&radio->lock);
1674
1675 /* video device allocation and initialization */
1676 radio->videodev = video_device_alloc();
1677 if (!radio->videodev) {
1678 retval = -ENOMEM;
1679 goto err_radio;
1680 }
1681 memcpy(radio->videodev, &si470x_viddev_template,
1682 sizeof(si470x_viddev_template));
1683 video_set_drvdata(radio->videodev, radio);
1684
1685 /* show some infos about the specific si470x device */
1686 if (si470x_get_all_registers(radio) < 0) {
1687 retval = -EIO;
1688 goto err_video;
1689 }
1690 printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
1691 radio->registers[DEVICEID], radio->registers[CHIPID]);
1692
1693 /* get software and hardware versions */
1694 if (si470x_get_scratch_page_versions(radio) < 0) {
1695 retval = -EIO;
1696 goto err_video;
1697 }
1698 printk(KERN_INFO DRIVER_NAME
1699 ": software version %d, hardware version %d\n",
1700 radio->software_version, radio->hardware_version);
1701
1702 /* check if device and firmware is current */
1703 if ((radio->registers[CHIPID] & CHIPID_FIRMWARE)
1704 < RADIO_SW_VERSION_CURRENT) {
1705 printk(KERN_WARNING DRIVER_NAME
1706 ": This driver is known to work with "
1707 "firmware version %hu,\n", RADIO_SW_VERSION_CURRENT);
1708 printk(KERN_WARNING DRIVER_NAME
1709 ": but the device has firmware version %hu.\n",
1710 radio->registers[CHIPID] & CHIPID_FIRMWARE);
1711 printk(KERN_WARNING DRIVER_NAME
1712 ": If you have some trouble using this driver,\n");
1713 printk(KERN_WARNING DRIVER_NAME
1714 ": please report to V4L ML at "
1715 "linux-media@vger.kernel.org\n");
1716 }
1717
1718 /* set initial frequency */
1719 si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
1720
1721 /* set led to connect state */
1722 si470x_set_led_state(radio, BLINK_GREEN_LED);
1723
1724 /* rds buffer allocation */
1725 radio->buf_size = rds_buf * 3;
1726 radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL);
1727 if (!radio->buffer) {
1728 retval = -EIO;
1729 goto err_video;
1730 }
1731
1732 /* rds buffer configuration */
1733 radio->wr_index = 0;
1734 radio->rd_index = 0;
1735 init_waitqueue_head(&radio->read_queue);
1736
1737 /* prepare rds work function */
1738 INIT_DELAYED_WORK(&radio->work, si470x_work);
1739
1740 /* register video device */
1741 retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
1742 if (retval) {
1743 printk(KERN_WARNING DRIVER_NAME
1744 ": Could not register video device\n");
1745 goto err_all;
1746 }
1747 usb_set_intfdata(intf, radio);
1748
1749 return 0;
1750err_all:
1751 kfree(radio->buffer);
1752err_video:
1753 video_device_release(radio->videodev);
1754err_radio:
1755 kfree(radio);
1756err_initial:
1757 return retval;
1758}
1759
1760
1761/*
1762 * si470x_usb_driver_suspend - suspend the device
1763 */
1764static int si470x_usb_driver_suspend(struct usb_interface *intf,
1765 pm_message_t message)
1766{
1767 struct si470x_device *radio = usb_get_intfdata(intf);
1768
1769 printk(KERN_INFO DRIVER_NAME ": suspending now...\n");
1770
1771 cancel_delayed_work_sync(&radio->work);
1772
1773 return 0;
1774}
1775
1776
1777/*
1778 * si470x_usb_driver_resume - resume the device
1779 */
1780static int si470x_usb_driver_resume(struct usb_interface *intf)
1781{
1782 struct si470x_device *radio = usb_get_intfdata(intf);
1783
1784 printk(KERN_INFO DRIVER_NAME ": resuming now...\n");
1785
1786 mutex_lock(&radio->lock);
1787 if (radio->users && radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS)
1788 schedule_delayed_work(&radio->work,
1789 msecs_to_jiffies(rds_poll_time));
1790 mutex_unlock(&radio->lock);
1791
1792 return 0;
1793}
1794
1795
1796/*
1797 * si470x_usb_driver_disconnect - disconnect the device
1798 */
1799static void si470x_usb_driver_disconnect(struct usb_interface *intf)
1800{
1801 struct si470x_device *radio = usb_get_intfdata(intf);
1802
1803 mutex_lock(&radio->disconnect_lock);
1804 radio->disconnected = 1;
1805 cancel_delayed_work_sync(&radio->work);
1806 usb_set_intfdata(intf, NULL);
1807 if (radio->users == 0) {
1808 /* set led to disconnect state */
1809 si470x_set_led_state(radio, BLINK_ORANGE_LED);
1810
1811 video_unregister_device(radio->videodev);
1812 kfree(radio->buffer);
1813 kfree(radio);
1814 }
1815 mutex_unlock(&radio->disconnect_lock);
1816}
1817
1818
1819/*
1820 * si470x_usb_driver - usb driver interface
1821 */
1822static struct usb_driver si470x_usb_driver = {
1823 .name = DRIVER_NAME,
1824 .probe = si470x_usb_driver_probe,
1825 .disconnect = si470x_usb_driver_disconnect,
1826 .suspend = si470x_usb_driver_suspend,
1827 .resume = si470x_usb_driver_resume,
1828 .id_table = si470x_usb_driver_id_table,
1829 .supports_autosuspend = 1,
1830};
1831
1832
1833
1834/**************************************************************************
1835 * Module Interface
1836 **************************************************************************/
1837
1838/*
1839 * si470x_module_init - module init
1840 */
1841static int __init si470x_module_init(void)
1842{
1843 printk(KERN_INFO DRIVER_DESC ", Version " DRIVER_VERSION "\n");
1844 return usb_register(&si470x_usb_driver);
1845}
1846
1847
1848/*
1849 * si470x_module_exit - module exit
1850 */
1851static void __exit si470x_module_exit(void)
1852{
1853 usb_deregister(&si470x_usb_driver);
1854}
1855
1856
1857module_init(si470x_module_init);
1858module_exit(si470x_module_exit);
1859
1860MODULE_LICENSE("GPL");
1861MODULE_AUTHOR(DRIVER_AUTHOR);
1862MODULE_DESCRIPTION(DRIVER_DESC);
1863MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
new file mode 100644
index 000000000000..65c14b704586
--- /dev/null
+++ b/drivers/media/radio/radio-si4713.c
@@ -0,0 +1,367 @@
1/*
2 * drivers/media/radio/radio-si4713.c
3 *
4 * Platform Driver for Silicon Labs Si4713 FM Radio Transmitter:
5 *
6 * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
7 * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/version.h>
28#include <linux/platform_device.h>
29#include <linux/i2c.h>
30#include <linux/videodev2.h>
31#include <media/v4l2-device.h>
32#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h>
34#include <media/radio-si4713.h>
35
36/* module parameters */
37static int radio_nr = -1; /* radio device minor (-1 ==> auto assign) */
38module_param(radio_nr, int, 0);
39MODULE_PARM_DESC(radio_nr,
40 "Minor number for radio device (-1 ==> auto assign)");
41
42MODULE_LICENSE("GPL");
43MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
44MODULE_DESCRIPTION("Platform driver for Si4713 FM Radio Transmitter");
45MODULE_VERSION("0.0.1");
46
47/* Driver state struct */
48struct radio_si4713_device {
49 struct v4l2_device v4l2_dev;
50 struct video_device *radio_dev;
51};
52
53/* radio_si4713_fops - file operations interface */
54static const struct v4l2_file_operations radio_si4713_fops = {
55 .owner = THIS_MODULE,
56 .ioctl = video_ioctl2,
57};
58
59/* Video4Linux Interface */
60static int radio_si4713_fill_audout(struct v4l2_audioout *vao)
61{
62 /* TODO: check presence of audio output */
63 strlcpy(vao->name, "FM Modulator Audio Out", 32);
64
65 return 0;
66}
67
68static int radio_si4713_enumaudout(struct file *file, void *priv,
69 struct v4l2_audioout *vao)
70{
71 return radio_si4713_fill_audout(vao);
72}
73
74static int radio_si4713_g_audout(struct file *file, void *priv,
75 struct v4l2_audioout *vao)
76{
77 int rval = radio_si4713_fill_audout(vao);
78
79 vao->index = 0;
80
81 return rval;
82}
83
84static int radio_si4713_s_audout(struct file *file, void *priv,
85 struct v4l2_audioout *vao)
86{
87 return vao->index ? -EINVAL : 0;
88}
89
90/* radio_si4713_querycap - query device capabilities */
91static int radio_si4713_querycap(struct file *file, void *priv,
92 struct v4l2_capability *capability)
93{
94 struct radio_si4713_device *rsdev;
95
96 rsdev = video_get_drvdata(video_devdata(file));
97
98 strlcpy(capability->driver, "radio-si4713", sizeof(capability->driver));
99 strlcpy(capability->card, "Silicon Labs Si4713 Modulator",
100 sizeof(capability->card));
101 capability->capabilities = V4L2_CAP_MODULATOR | V4L2_CAP_RDS_OUTPUT;
102
103 return 0;
104}
105
106/* radio_si4713_queryctrl - enumerate control items */
107static int radio_si4713_queryctrl(struct file *file, void *priv,
108 struct v4l2_queryctrl *qc)
109{
110 /* Must be sorted from low to high control ID! */
111 static const u32 user_ctrls[] = {
112 V4L2_CID_USER_CLASS,
113 V4L2_CID_AUDIO_MUTE,
114 0
115 };
116
117 /* Must be sorted from low to high control ID! */
118 static const u32 fmtx_ctrls[] = {
119 V4L2_CID_FM_TX_CLASS,
120 V4L2_CID_RDS_TX_DEVIATION,
121 V4L2_CID_RDS_TX_PI,
122 V4L2_CID_RDS_TX_PTY,
123 V4L2_CID_RDS_TX_PS_NAME,
124 V4L2_CID_RDS_TX_RADIO_TEXT,
125 V4L2_CID_AUDIO_LIMITER_ENABLED,
126 V4L2_CID_AUDIO_LIMITER_RELEASE_TIME,
127 V4L2_CID_AUDIO_LIMITER_DEVIATION,
128 V4L2_CID_AUDIO_COMPRESSION_ENABLED,
129 V4L2_CID_AUDIO_COMPRESSION_GAIN,
130 V4L2_CID_AUDIO_COMPRESSION_THRESHOLD,
131 V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME,
132 V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME,
133 V4L2_CID_PILOT_TONE_ENABLED,
134 V4L2_CID_PILOT_TONE_DEVIATION,
135 V4L2_CID_PILOT_TONE_FREQUENCY,
136 V4L2_CID_TUNE_PREEMPHASIS,
137 V4L2_CID_TUNE_POWER_LEVEL,
138 V4L2_CID_TUNE_ANTENNA_CAPACITOR,
139 0
140 };
141 static const u32 *ctrl_classes[] = {
142 user_ctrls,
143 fmtx_ctrls,
144 NULL
145 };
146 struct radio_si4713_device *rsdev;
147
148 rsdev = video_get_drvdata(video_devdata(file));
149
150 qc->id = v4l2_ctrl_next(ctrl_classes, qc->id);
151 if (qc->id == 0)
152 return -EINVAL;
153
154 if (qc->id == V4L2_CID_USER_CLASS || qc->id == V4L2_CID_FM_TX_CLASS)
155 return v4l2_ctrl_query_fill(qc, 0, 0, 0, 0);
156
157 return v4l2_device_call_until_err(&rsdev->v4l2_dev, 0, core,
158 queryctrl, qc);
159}
160
161/*
162 * v4l2 ioctl call backs.
163 * we are just a wrapper for v4l2_sub_devs.
164 */
165static inline struct v4l2_device *get_v4l2_dev(struct file *file)
166{
167 return &((struct radio_si4713_device *)video_drvdata(file))->v4l2_dev;
168}
169
170static int radio_si4713_g_ext_ctrls(struct file *file, void *p,
171 struct v4l2_ext_controls *vecs)
172{
173 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
174 g_ext_ctrls, vecs);
175}
176
177static int radio_si4713_s_ext_ctrls(struct file *file, void *p,
178 struct v4l2_ext_controls *vecs)
179{
180 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
181 s_ext_ctrls, vecs);
182}
183
184static int radio_si4713_g_ctrl(struct file *file, void *p,
185 struct v4l2_control *vc)
186{
187 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
188 g_ctrl, vc);
189}
190
191static int radio_si4713_s_ctrl(struct file *file, void *p,
192 struct v4l2_control *vc)
193{
194 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
195 s_ctrl, vc);
196}
197
198static int radio_si4713_g_modulator(struct file *file, void *p,
199 struct v4l2_modulator *vm)
200{
201 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
202 g_modulator, vm);
203}
204
205static int radio_si4713_s_modulator(struct file *file, void *p,
206 struct v4l2_modulator *vm)
207{
208 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
209 s_modulator, vm);
210}
211
212static int radio_si4713_g_frequency(struct file *file, void *p,
213 struct v4l2_frequency *vf)
214{
215 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
216 g_frequency, vf);
217}
218
219static int radio_si4713_s_frequency(struct file *file, void *p,
220 struct v4l2_frequency *vf)
221{
222 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, tuner,
223 s_frequency, vf);
224}
225
226static long radio_si4713_default(struct file *file, void *p, int cmd, void *arg)
227{
228 return v4l2_device_call_until_err(get_v4l2_dev(file), 0, core,
229 ioctl, cmd, arg);
230}
231
232static struct v4l2_ioctl_ops radio_si4713_ioctl_ops = {
233 .vidioc_enumaudout = radio_si4713_enumaudout,
234 .vidioc_g_audout = radio_si4713_g_audout,
235 .vidioc_s_audout = radio_si4713_s_audout,
236 .vidioc_querycap = radio_si4713_querycap,
237 .vidioc_queryctrl = radio_si4713_queryctrl,
238 .vidioc_g_ext_ctrls = radio_si4713_g_ext_ctrls,
239 .vidioc_s_ext_ctrls = radio_si4713_s_ext_ctrls,
240 .vidioc_g_ctrl = radio_si4713_g_ctrl,
241 .vidioc_s_ctrl = radio_si4713_s_ctrl,
242 .vidioc_g_modulator = radio_si4713_g_modulator,
243 .vidioc_s_modulator = radio_si4713_s_modulator,
244 .vidioc_g_frequency = radio_si4713_g_frequency,
245 .vidioc_s_frequency = radio_si4713_s_frequency,
246 .vidioc_default = radio_si4713_default,
247};
248
249/* radio_si4713_vdev_template - video device interface */
250static struct video_device radio_si4713_vdev_template = {
251 .fops = &radio_si4713_fops,
252 .name = "radio-si4713",
253 .release = video_device_release,
254 .ioctl_ops = &radio_si4713_ioctl_ops,
255};
256
257/* Platform driver interface */
258/* radio_si4713_pdriver_probe - probe for the device */
259static int radio_si4713_pdriver_probe(struct platform_device *pdev)
260{
261 struct radio_si4713_platform_data *pdata = pdev->dev.platform_data;
262 struct radio_si4713_device *rsdev;
263 struct i2c_adapter *adapter;
264 struct v4l2_subdev *sd;
265 int rval = 0;
266
267 if (!pdata) {
268 dev_err(&pdev->dev, "Cannot proceed without platform data.\n");
269 rval = -EINVAL;
270 goto exit;
271 }
272
273 rsdev = kzalloc(sizeof *rsdev, GFP_KERNEL);
274 if (!rsdev) {
275 dev_err(&pdev->dev, "Failed to alloc video device.\n");
276 rval = -ENOMEM;
277 goto exit;
278 }
279
280 rval = v4l2_device_register(&pdev->dev, &rsdev->v4l2_dev);
281 if (rval) {
282 dev_err(&pdev->dev, "Failed to register v4l2 device.\n");
283 goto free_rsdev;
284 }
285
286 adapter = i2c_get_adapter(pdata->i2c_bus);
287 if (!adapter) {
288 dev_err(&pdev->dev, "Cannot get i2c adapter %d\n",
289 pdata->i2c_bus);
290 rval = -ENODEV;
291 goto unregister_v4l2_dev;
292 }
293
294 sd = v4l2_i2c_new_subdev_board(&rsdev->v4l2_dev, adapter, "si4713_i2c",
295 pdata->subdev_board_info, NULL);
296 if (!sd) {
297 dev_err(&pdev->dev, "Cannot get v4l2 subdevice\n");
298 rval = -ENODEV;
299 goto unregister_v4l2_dev;
300 }
301
302 rsdev->radio_dev = video_device_alloc();
303 if (!rsdev->radio_dev) {
304 dev_err(&pdev->dev, "Failed to alloc video device.\n");
305 rval = -ENOMEM;
306 goto unregister_v4l2_dev;
307 }
308
309 memcpy(rsdev->radio_dev, &radio_si4713_vdev_template,
310 sizeof(radio_si4713_vdev_template));
311 video_set_drvdata(rsdev->radio_dev, rsdev);
312 if (video_register_device(rsdev->radio_dev, VFL_TYPE_RADIO, radio_nr)) {
313 dev_err(&pdev->dev, "Could not register video device.\n");
314 rval = -EIO;
315 goto free_vdev;
316 }
317 dev_info(&pdev->dev, "New device successfully probed\n");
318
319 goto exit;
320
321free_vdev:
322 video_device_release(rsdev->radio_dev);
323unregister_v4l2_dev:
324 v4l2_device_unregister(&rsdev->v4l2_dev);
325free_rsdev:
326 kfree(rsdev);
327exit:
328 return rval;
329}
330
331/* radio_si4713_pdriver_remove - remove the device */
332static int __exit radio_si4713_pdriver_remove(struct platform_device *pdev)
333{
334 struct v4l2_device *v4l2_dev = platform_get_drvdata(pdev);
335 struct radio_si4713_device *rsdev = container_of(v4l2_dev,
336 struct radio_si4713_device,
337 v4l2_dev);
338
339 video_unregister_device(rsdev->radio_dev);
340 v4l2_device_unregister(&rsdev->v4l2_dev);
341 kfree(rsdev);
342
343 return 0;
344}
345
346static struct platform_driver radio_si4713_pdriver = {
347 .driver = {
348 .name = "radio-si4713",
349 },
350 .probe = radio_si4713_pdriver_probe,
351 .remove = __exit_p(radio_si4713_pdriver_remove),
352};
353
354/* Module Interface */
355static int __init radio_si4713_module_init(void)
356{
357 return platform_driver_register(&radio_si4713_pdriver);
358}
359
360static void __exit radio_si4713_module_exit(void)
361{
362 platform_driver_unregister(&radio_si4713_pdriver);
363}
364
365module_init(radio_si4713_module_init);
366module_exit(radio_si4713_module_exit);
367
diff --git a/drivers/media/radio/si470x/Kconfig b/drivers/media/radio/si470x/Kconfig
new file mode 100644
index 000000000000..a466654ee5c9
--- /dev/null
+++ b/drivers/media/radio/si470x/Kconfig
@@ -0,0 +1,37 @@
1config USB_SI470X
2 tristate "Silicon Labs Si470x FM Radio Receiver support with USB"
3 depends on USB && RADIO_SI470X
4 ---help---
5 This is a driver for USB devices with the Silicon Labs SI470x
6 chip. Currently these devices are known to work:
7 - 10c4:818a: Silicon Labs USB FM Radio Reference Design
8 - 06e1:a155: ADS/Tech FM Radio Receiver (formerly Instant FM Music)
9 - 1b80:d700: KWorld USB FM Radio SnapMusic Mobile 700 (FM700)
10 - 10c5:819a: Sanei Electric FM USB Radio (aka DealExtreme.com PCear)
11
12 Sound is provided by the ALSA USB Audio/MIDI driver. Therefore
13 if you don't want to use the device solely for RDS receiving,
14 it is recommended to also select SND_USB_AUDIO.
15
16 Please have a look at the documentation, especially on how
17 to redirect the audio stream from the radio to your sound device:
18 Documentation/video4linux/si470x.txt
19
20 Say Y here if you want to connect this type of radio to your
21 computer's USB port.
22
23 To compile this driver as a module, choose M here: the
24 module will be called radio-usb-si470x.
25
26config I2C_SI470X
27 tristate "Silicon Labs Si470x FM Radio Receiver support with I2C"
28 depends on I2C && RADIO_SI470X && !USB_SI470X
29 ---help---
30 This is a driver for I2C devices with the Silicon Labs SI470x
31 chip.
32
33 Say Y here if you want to connect this type of radio to your
34 computer's I2C port.
35
36 To compile this driver as a module, choose M here: the
37 module will be called radio-i2c-si470x.
diff --git a/drivers/media/radio/si470x/Makefile b/drivers/media/radio/si470x/Makefile
new file mode 100644
index 000000000000..06964816cfd6
--- /dev/null
+++ b/drivers/media/radio/si470x/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for radios with Silicon Labs Si470x FM Radio Receivers
3#
4
5radio-usb-si470x-objs := radio-si470x-usb.o radio-si470x-common.o
6radio-i2c-si470x-objs := radio-si470x-i2c.o radio-si470x-common.o
7
8obj-$(CONFIG_USB_SI470X) += radio-usb-si470x.o
9obj-$(CONFIG_I2C_SI470X) += radio-i2c-si470x.o
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
new file mode 100644
index 000000000000..f33315f2c543
--- /dev/null
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -0,0 +1,798 @@
1/*
2 * drivers/media/radio/si470x/radio-si470x-common.c
3 *
4 * Driver for radios with Silicon Labs Si470x FM Radio Receivers
5 *
6 * Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23
24/*
25 * History:
26 * 2008-01-12 Tobias Lorenz <tobias.lorenz@gmx.net>
27 * Version 1.0.0
28 * - First working version
29 * 2008-01-13 Tobias Lorenz <tobias.lorenz@gmx.net>
30 * Version 1.0.1
31 * - Improved error handling, every function now returns errno
32 * - Improved multi user access (start/mute/stop)
33 * - Channel doesn't get lost anymore after start/mute/stop
34 * - RDS support added (polling mode via interrupt EP 1)
35 * - marked default module parameters with *value*
36 * - switched from bit structs to bit masks
37 * - header file cleaned and integrated
38 * 2008-01-14 Tobias Lorenz <tobias.lorenz@gmx.net>
39 * Version 1.0.2
40 * - hex values are now lower case
41 * - commented USB ID for ADS/Tech moved on todo list
42 * - blacklisted si470x in hid-quirks.c
43 * - rds buffer handling functions integrated into *_work, *_read
44 * - rds_command in si470x_poll exchanged against simple retval
45 * - check for firmware version 15
46 * - code order and prototypes still remain the same
47 * - spacing and bottom of band codes remain the same
48 * 2008-01-16 Tobias Lorenz <tobias.lorenz@gmx.net>
49 * Version 1.0.3
50 * - code reordered to avoid function prototypes
51 * - switch/case defaults are now more user-friendly
52 * - unified comment style
53 * - applied all checkpatch.pl v1.12 suggestions
54 * except the warning about the too long lines with bit comments
55 * - renamed FMRADIO to RADIO to cut line length (checkpatch.pl)
56 * 2008-01-22 Tobias Lorenz <tobias.lorenz@gmx.net>
57 * Version 1.0.4
58 * - avoid poss. locking when doing copy_to_user which may sleep
59 * - RDS is automatically activated on read now
60 * - code cleaned of unnecessary rds_commands
61 * - USB Vendor/Product ID for ADS/Tech FM Radio Receiver verified
62 * (thanks to Guillaume RAMOUSSE)
63 * 2008-01-27 Tobias Lorenz <tobias.lorenz@gmx.net>
64 * Version 1.0.5
65 * - number of seek_retries changed to tune_timeout
66 * - fixed problem with incomplete tune operations by own buffers
67 * - optimization of variables and printf types
68 * - improved error logging
69 * 2008-01-31 Tobias Lorenz <tobias.lorenz@gmx.net>
70 * Oliver Neukum <oliver@neukum.org>
71 * Version 1.0.6
72 * - fixed coverity checker warnings in *_usb_driver_disconnect
73 * - probe()/open() race by correct ordering in probe()
74 * - DMA coherency rules by separate allocation of all buffers
75 * - use of endianness macros
76 * - abuse of spinlock, replaced by mutex
77 * - racy handling of timer in disconnect,
78 * replaced by delayed_work
79 * - racy interruptible_sleep_on(),
80 * replaced with wait_event_interruptible()
81 * - handle signals in read()
82 * 2008-02-08 Tobias Lorenz <tobias.lorenz@gmx.net>
83 * Oliver Neukum <oliver@neukum.org>
84 * Version 1.0.7
85 * - usb autosuspend support
86 * - unplugging fixed
87 * 2008-05-07 Tobias Lorenz <tobias.lorenz@gmx.net>
88 * Version 1.0.8
89 * - hardware frequency seek support
90 * - afc indication
91 * - more safety checks, let si470x_get_freq return errno
92 * - vidioc behavior corrected according to v4l2 spec
93 * 2008-10-20 Alexey Klimov <klimov.linux@gmail.com>
94 * - add support for KWorld USB FM Radio FM700
95 * - blacklisted KWorld radio in hid-core.c and hid-ids.h
96 * 2008-12-03 Mark Lord <mlord@pobox.com>
97 * - add support for DealExtreme USB Radio
98 * 2009-01-31 Bob Ross <pigiron@gmx.com>
99 * - correction of stereo detection/setting
100 * - correction of signal strength indicator scaling
101 * 2009-01-31 Rick Bronson <rick@efn.org>
102 * Tobias Lorenz <tobias.lorenz@gmx.net>
103 * - add LED status output
104 * - get HW/SW version from scratchpad
105 * 2009-06-16 Edouard Lafargue <edouard@lafargue.name>
106 * Version 1.0.10
107 * - add support for interrupt mode for RDS endpoint,
108 * instead of polling.
109 * Improves RDS reception significantly
110 */
111
112
113/* kernel includes */
114#include "radio-si470x.h"
115
116
117
118/**************************************************************************
119 * Module Parameters
120 **************************************************************************/
121
122/* Spacing (kHz) */
123/* 0: 200 kHz (USA, Australia) */
124/* 1: 100 kHz (Europe, Japan) */
125/* 2: 50 kHz */
126static unsigned short space = 2;
127module_param(space, ushort, 0444);
128MODULE_PARM_DESC(space, "Spacing: 0=200kHz 1=100kHz *2=50kHz*");
129
130/* Bottom of Band (MHz) */
131/* 0: 87.5 - 108 MHz (USA, Europe)*/
132/* 1: 76 - 108 MHz (Japan wide band) */
133/* 2: 76 - 90 MHz (Japan) */
134static unsigned short band = 1;
135module_param(band, ushort, 0444);
136MODULE_PARM_DESC(band, "Band: 0=87.5..108MHz *1=76..108MHz* 2=76..90MHz");
137
138/* De-emphasis */
139/* 0: 75 us (USA) */
140/* 1: 50 us (Europe, Australia, Japan) */
141static unsigned short de = 1;
142module_param(de, ushort, 0444);
143MODULE_PARM_DESC(de, "De-emphasis: 0=75us *1=50us*");
144
145/* Tune timeout */
146static unsigned int tune_timeout = 3000;
147module_param(tune_timeout, uint, 0644);
148MODULE_PARM_DESC(tune_timeout, "Tune timeout: *3000*");
149
150/* Seek timeout */
151static unsigned int seek_timeout = 5000;
152module_param(seek_timeout, uint, 0644);
153MODULE_PARM_DESC(seek_timeout, "Seek timeout: *5000*");
154
155
156
157/**************************************************************************
158 * Generic Functions
159 **************************************************************************/
160
161/*
162 * si470x_set_chan - set the channel
163 */
164static int si470x_set_chan(struct si470x_device *radio, unsigned short chan)
165{
166 int retval;
167 unsigned long timeout;
168 bool timed_out = 0;
169
170 /* start tuning */
171 radio->registers[CHANNEL] &= ~CHANNEL_CHAN;
172 radio->registers[CHANNEL] |= CHANNEL_TUNE | chan;
173 retval = si470x_set_register(radio, CHANNEL);
174 if (retval < 0)
175 goto done;
176
177 /* wait till tune operation has completed */
178 timeout = jiffies + msecs_to_jiffies(tune_timeout);
179 do {
180 retval = si470x_get_register(radio, STATUSRSSI);
181 if (retval < 0)
182 goto stop;
183 timed_out = time_after(jiffies, timeout);
184 } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) &&
185 (!timed_out));
186 if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0)
187 dev_warn(&radio->videodev->dev, "tune does not complete\n");
188 if (timed_out)
189 dev_warn(&radio->videodev->dev,
190 "tune timed out after %u ms\n", tune_timeout);
191
192stop:
193 /* stop tuning */
194 radio->registers[CHANNEL] &= ~CHANNEL_TUNE;
195 retval = si470x_set_register(radio, CHANNEL);
196
197done:
198 return retval;
199}
200
201
202/*
203 * si470x_get_freq - get the frequency
204 */
205static int si470x_get_freq(struct si470x_device *radio, unsigned int *freq)
206{
207 unsigned int spacing, band_bottom;
208 unsigned short chan;
209 int retval;
210
211 /* Spacing (kHz) */
212 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) {
213 /* 0: 200 kHz (USA, Australia) */
214 case 0:
215 spacing = 0.200 * FREQ_MUL; break;
216 /* 1: 100 kHz (Europe, Japan) */
217 case 1:
218 spacing = 0.100 * FREQ_MUL; break;
219 /* 2: 50 kHz */
220 default:
221 spacing = 0.050 * FREQ_MUL; break;
222 };
223
224 /* Bottom of Band (MHz) */
225 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
226 /* 0: 87.5 - 108 MHz (USA, Europe) */
227 case 0:
228 band_bottom = 87.5 * FREQ_MUL; break;
229 /* 1: 76 - 108 MHz (Japan wide band) */
230 default:
231 band_bottom = 76 * FREQ_MUL; break;
232 /* 2: 76 - 90 MHz (Japan) */
233 case 2:
234 band_bottom = 76 * FREQ_MUL; break;
235 };
236
237 /* read channel */
238 retval = si470x_get_register(radio, READCHAN);
239 chan = radio->registers[READCHAN] & READCHAN_READCHAN;
240
241 /* Frequency (MHz) = Spacing (kHz) x Channel + Bottom of Band (MHz) */
242 *freq = chan * spacing + band_bottom;
243
244 return retval;
245}
246
247
248/*
249 * si470x_set_freq - set the frequency
250 */
251int si470x_set_freq(struct si470x_device *radio, unsigned int freq)
252{
253 unsigned int spacing, band_bottom;
254 unsigned short chan;
255
256 /* Spacing (kHz) */
257 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_SPACE) >> 4) {
258 /* 0: 200 kHz (USA, Australia) */
259 case 0:
260 spacing = 0.200 * FREQ_MUL; break;
261 /* 1: 100 kHz (Europe, Japan) */
262 case 1:
263 spacing = 0.100 * FREQ_MUL; break;
264 /* 2: 50 kHz */
265 default:
266 spacing = 0.050 * FREQ_MUL; break;
267 };
268
269 /* Bottom of Band (MHz) */
270 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
271 /* 0: 87.5 - 108 MHz (USA, Europe) */
272 case 0:
273 band_bottom = 87.5 * FREQ_MUL; break;
274 /* 1: 76 - 108 MHz (Japan wide band) */
275 default:
276 band_bottom = 76 * FREQ_MUL; break;
277 /* 2: 76 - 90 MHz (Japan) */
278 case 2:
279 band_bottom = 76 * FREQ_MUL; break;
280 };
281
282 /* Chan = [ Freq (Mhz) - Bottom of Band (MHz) ] / Spacing (kHz) */
283 chan = (freq - band_bottom) / spacing;
284
285 return si470x_set_chan(radio, chan);
286}
287
288
289/*
290 * si470x_set_seek - set seek
291 */
292static int si470x_set_seek(struct si470x_device *radio,
293 unsigned int wrap_around, unsigned int seek_upward)
294{
295 int retval = 0;
296 unsigned long timeout;
297 bool timed_out = 0;
298
299 /* start seeking */
300 radio->registers[POWERCFG] |= POWERCFG_SEEK;
301 if (wrap_around == 1)
302 radio->registers[POWERCFG] &= ~POWERCFG_SKMODE;
303 else
304 radio->registers[POWERCFG] |= POWERCFG_SKMODE;
305 if (seek_upward == 1)
306 radio->registers[POWERCFG] |= POWERCFG_SEEKUP;
307 else
308 radio->registers[POWERCFG] &= ~POWERCFG_SEEKUP;
309 retval = si470x_set_register(radio, POWERCFG);
310 if (retval < 0)
311 goto done;
312
313 /* wait till seek operation has completed */
314 timeout = jiffies + msecs_to_jiffies(seek_timeout);
315 do {
316 retval = si470x_get_register(radio, STATUSRSSI);
317 if (retval < 0)
318 goto stop;
319 timed_out = time_after(jiffies, timeout);
320 } while (((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0) &&
321 (!timed_out));
322 if ((radio->registers[STATUSRSSI] & STATUSRSSI_STC) == 0)
323 dev_warn(&radio->videodev->dev, "seek does not complete\n");
324 if (radio->registers[STATUSRSSI] & STATUSRSSI_SF)
325 dev_warn(&radio->videodev->dev,
326 "seek failed / band limit reached\n");
327 if (timed_out)
328 dev_warn(&radio->videodev->dev,
329 "seek timed out after %u ms\n", seek_timeout);
330
331stop:
332 /* stop seeking */
333 radio->registers[POWERCFG] &= ~POWERCFG_SEEK;
334 retval = si470x_set_register(radio, POWERCFG);
335
336done:
337 /* try again, if timed out */
338 if ((retval == 0) && timed_out)
339 retval = -EAGAIN;
340
341 return retval;
342}
343
344
345/*
346 * si470x_start - switch on radio
347 */
348int si470x_start(struct si470x_device *radio)
349{
350 int retval;
351
352 /* powercfg */
353 radio->registers[POWERCFG] =
354 POWERCFG_DMUTE | POWERCFG_ENABLE | POWERCFG_RDSM;
355 retval = si470x_set_register(radio, POWERCFG);
356 if (retval < 0)
357 goto done;
358
359 /* sysconfig 1 */
360 radio->registers[SYSCONFIG1] = SYSCONFIG1_DE;
361 retval = si470x_set_register(radio, SYSCONFIG1);
362 if (retval < 0)
363 goto done;
364
365 /* sysconfig 2 */
366 radio->registers[SYSCONFIG2] =
367 (0x3f << 8) | /* SEEKTH */
368 ((band << 6) & SYSCONFIG2_BAND) | /* BAND */
369 ((space << 4) & SYSCONFIG2_SPACE) | /* SPACE */
370 15; /* VOLUME (max) */
371 retval = si470x_set_register(radio, SYSCONFIG2);
372 if (retval < 0)
373 goto done;
374
375 /* reset last channel */
376 retval = si470x_set_chan(radio,
377 radio->registers[CHANNEL] & CHANNEL_CHAN);
378
379done:
380 return retval;
381}
382
383
384/*
385 * si470x_stop - switch off radio
386 */
387int si470x_stop(struct si470x_device *radio)
388{
389 int retval;
390
391 /* sysconfig 1 */
392 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS;
393 retval = si470x_set_register(radio, SYSCONFIG1);
394 if (retval < 0)
395 goto done;
396
397 /* powercfg */
398 radio->registers[POWERCFG] &= ~POWERCFG_DMUTE;
399 /* POWERCFG_ENABLE has to automatically go low */
400 radio->registers[POWERCFG] |= POWERCFG_ENABLE | POWERCFG_DISABLE;
401 retval = si470x_set_register(radio, POWERCFG);
402
403done:
404 return retval;
405}
406
407
408/*
409 * si470x_rds_on - switch on rds reception
410 */
411int si470x_rds_on(struct si470x_device *radio)
412{
413 int retval;
414
415 /* sysconfig 1 */
416 mutex_lock(&radio->lock);
417 radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDS;
418 retval = si470x_set_register(radio, SYSCONFIG1);
419 if (retval < 0)
420 radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_RDS;
421 mutex_unlock(&radio->lock);
422
423 return retval;
424}
425
426
427
428/**************************************************************************
429 * Video4Linux Interface
430 **************************************************************************/
431
432/*
433 * si470x_vidioc_queryctrl - enumerate control items
434 */
435static int si470x_vidioc_queryctrl(struct file *file, void *priv,
436 struct v4l2_queryctrl *qc)
437{
438 struct si470x_device *radio = video_drvdata(file);
439 int retval = -EINVAL;
440
441 /* abort if qc->id is below V4L2_CID_BASE */
442 if (qc->id < V4L2_CID_BASE)
443 goto done;
444
445 /* search video control */
446 switch (qc->id) {
447 case V4L2_CID_AUDIO_VOLUME:
448 return v4l2_ctrl_query_fill(qc, 0, 15, 1, 15);
449 case V4L2_CID_AUDIO_MUTE:
450 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
451 }
452
453 /* disable unsupported base controls */
454 /* to satisfy kradio and such apps */
455 if ((retval == -EINVAL) && (qc->id < V4L2_CID_LASTP1)) {
456 qc->flags = V4L2_CTRL_FLAG_DISABLED;
457 retval = 0;
458 }
459
460done:
461 if (retval < 0)
462 dev_warn(&radio->videodev->dev,
463 "query controls failed with %d\n", retval);
464 return retval;
465}
466
467
468/*
469 * si470x_vidioc_g_ctrl - get the value of a control
470 */
471static int si470x_vidioc_g_ctrl(struct file *file, void *priv,
472 struct v4l2_control *ctrl)
473{
474 struct si470x_device *radio = video_drvdata(file);
475 int retval = 0;
476
477 /* safety checks */
478 retval = si470x_disconnect_check(radio);
479 if (retval)
480 goto done;
481
482 switch (ctrl->id) {
483 case V4L2_CID_AUDIO_VOLUME:
484 ctrl->value = radio->registers[SYSCONFIG2] &
485 SYSCONFIG2_VOLUME;
486 break;
487 case V4L2_CID_AUDIO_MUTE:
488 ctrl->value = ((radio->registers[POWERCFG] &
489 POWERCFG_DMUTE) == 0) ? 1 : 0;
490 break;
491 default:
492 retval = -EINVAL;
493 }
494
495done:
496 if (retval < 0)
497 dev_warn(&radio->videodev->dev,
498 "get control failed with %d\n", retval);
499 return retval;
500}
501
502
503/*
504 * si470x_vidioc_s_ctrl - set the value of a control
505 */
506static int si470x_vidioc_s_ctrl(struct file *file, void *priv,
507 struct v4l2_control *ctrl)
508{
509 struct si470x_device *radio = video_drvdata(file);
510 int retval = 0;
511
512 /* safety checks */
513 retval = si470x_disconnect_check(radio);
514 if (retval)
515 goto done;
516
517 switch (ctrl->id) {
518 case V4L2_CID_AUDIO_VOLUME:
519 radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME;
520 radio->registers[SYSCONFIG2] |= ctrl->value;
521 retval = si470x_set_register(radio, SYSCONFIG2);
522 break;
523 case V4L2_CID_AUDIO_MUTE:
524 if (ctrl->value == 1)
525 radio->registers[POWERCFG] &= ~POWERCFG_DMUTE;
526 else
527 radio->registers[POWERCFG] |= POWERCFG_DMUTE;
528 retval = si470x_set_register(radio, POWERCFG);
529 break;
530 default:
531 retval = -EINVAL;
532 }
533
534done:
535 if (retval < 0)
536 dev_warn(&radio->videodev->dev,
537 "set control failed with %d\n", retval);
538 return retval;
539}
540
541
542/*
543 * si470x_vidioc_g_audio - get audio attributes
544 */
545static int si470x_vidioc_g_audio(struct file *file, void *priv,
546 struct v4l2_audio *audio)
547{
548 /* driver constants */
549 audio->index = 0;
550 strcpy(audio->name, "Radio");
551 audio->capability = V4L2_AUDCAP_STEREO;
552 audio->mode = 0;
553
554 return 0;
555}
556
557
558/*
559 * si470x_vidioc_g_tuner - get tuner attributes
560 */
561static int si470x_vidioc_g_tuner(struct file *file, void *priv,
562 struct v4l2_tuner *tuner)
563{
564 struct si470x_device *radio = video_drvdata(file);
565 int retval = 0;
566
567 /* safety checks */
568 retval = si470x_disconnect_check(radio);
569 if (retval)
570 goto done;
571
572 if (tuner->index != 0) {
573 retval = -EINVAL;
574 goto done;
575 }
576
577 retval = si470x_get_register(radio, STATUSRSSI);
578 if (retval < 0)
579 goto done;
580
581 /* driver constants */
582 strcpy(tuner->name, "FM");
583 tuner->type = V4L2_TUNER_RADIO;
584#if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE)
585 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO |
586 V4L2_TUNER_CAP_RDS;
587#else
588 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
589#endif
590
591 /* range limits */
592 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
593 /* 0: 87.5 - 108 MHz (USA, Europe, default) */
594 default:
595 tuner->rangelow = 87.5 * FREQ_MUL;
596 tuner->rangehigh = 108 * FREQ_MUL;
597 break;
598 /* 1: 76 - 108 MHz (Japan wide band) */
599 case 1:
600 tuner->rangelow = 76 * FREQ_MUL;
601 tuner->rangehigh = 108 * FREQ_MUL;
602 break;
603 /* 2: 76 - 90 MHz (Japan) */
604 case 2:
605 tuner->rangelow = 76 * FREQ_MUL;
606 tuner->rangehigh = 90 * FREQ_MUL;
607 break;
608 };
609
610 /* stereo indicator == stereo (instead of mono) */
611 if ((radio->registers[STATUSRSSI] & STATUSRSSI_ST) == 0)
612 tuner->rxsubchans = V4L2_TUNER_SUB_MONO;
613 else
614 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
615#if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE)
616 /* If there is a reliable method of detecting an RDS channel,
617 then this code should check for that before setting this
618 RDS subchannel. */
619 tuner->rxsubchans |= V4L2_TUNER_SUB_RDS;
620#endif
621
622 /* mono/stereo selector */
623 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0)
624 tuner->audmode = V4L2_TUNER_MODE_STEREO;
625 else
626 tuner->audmode = V4L2_TUNER_MODE_MONO;
627
628 /* min is worst, max is best; signal:0..0xffff; rssi: 0..0xff */
629 /* measured in units of db쨉V in 1 db increments (max at ~75 db쨉V) */
630 tuner->signal = (radio->registers[STATUSRSSI] & STATUSRSSI_RSSI);
631 /* the ideal factor is 0xffff/75 = 873,8 */
632 tuner->signal = (tuner->signal * 873) + (8 * tuner->signal / 10);
633
634 /* automatic frequency control: -1: freq to low, 1 freq to high */
635 /* AFCRL does only indicate that freq. differs, not if too low/high */
636 tuner->afc = (radio->registers[STATUSRSSI] & STATUSRSSI_AFCRL) ? 1 : 0;
637
638done:
639 if (retval < 0)
640 dev_warn(&radio->videodev->dev,
641 "get tuner failed with %d\n", retval);
642 return retval;
643}
644
645
646/*
647 * si470x_vidioc_s_tuner - set tuner attributes
648 */
649static int si470x_vidioc_s_tuner(struct file *file, void *priv,
650 struct v4l2_tuner *tuner)
651{
652 struct si470x_device *radio = video_drvdata(file);
653 int retval = -EINVAL;
654
655 /* safety checks */
656 retval = si470x_disconnect_check(radio);
657 if (retval)
658 goto done;
659
660 if (tuner->index != 0)
661 goto done;
662
663 /* mono/stereo selector */
664 switch (tuner->audmode) {
665 case V4L2_TUNER_MODE_MONO:
666 radio->registers[POWERCFG] |= POWERCFG_MONO; /* force mono */
667 break;
668 case V4L2_TUNER_MODE_STEREO:
669 radio->registers[POWERCFG] &= ~POWERCFG_MONO; /* try stereo */
670 break;
671 default:
672 goto done;
673 }
674
675 retval = si470x_set_register(radio, POWERCFG);
676
677done:
678 if (retval < 0)
679 dev_warn(&radio->videodev->dev,
680 "set tuner failed with %d\n", retval);
681 return retval;
682}
683
684
685/*
686 * si470x_vidioc_g_frequency - get tuner or modulator radio frequency
687 */
688static int si470x_vidioc_g_frequency(struct file *file, void *priv,
689 struct v4l2_frequency *freq)
690{
691 struct si470x_device *radio = video_drvdata(file);
692 int retval = 0;
693
694 /* safety checks */
695 retval = si470x_disconnect_check(radio);
696 if (retval)
697 goto done;
698
699 if (freq->tuner != 0) {
700 retval = -EINVAL;
701 goto done;
702 }
703
704 freq->type = V4L2_TUNER_RADIO;
705 retval = si470x_get_freq(radio, &freq->frequency);
706
707done:
708 if (retval < 0)
709 dev_warn(&radio->videodev->dev,
710 "get frequency failed with %d\n", retval);
711 return retval;
712}
713
714
715/*
716 * si470x_vidioc_s_frequency - set tuner or modulator radio frequency
717 */
718static int si470x_vidioc_s_frequency(struct file *file, void *priv,
719 struct v4l2_frequency *freq)
720{
721 struct si470x_device *radio = video_drvdata(file);
722 int retval = 0;
723
724 /* safety checks */
725 retval = si470x_disconnect_check(radio);
726 if (retval)
727 goto done;
728
729 if (freq->tuner != 0) {
730 retval = -EINVAL;
731 goto done;
732 }
733
734 retval = si470x_set_freq(radio, freq->frequency);
735
736done:
737 if (retval < 0)
738 dev_warn(&radio->videodev->dev,
739 "set frequency failed with %d\n", retval);
740 return retval;
741}
742
743
744/*
745 * si470x_vidioc_s_hw_freq_seek - set hardware frequency seek
746 */
747static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv,
748 struct v4l2_hw_freq_seek *seek)
749{
750 struct si470x_device *radio = video_drvdata(file);
751 int retval = 0;
752
753 /* safety checks */
754 retval = si470x_disconnect_check(radio);
755 if (retval)
756 goto done;
757
758 if (seek->tuner != 0) {
759 retval = -EINVAL;
760 goto done;
761 }
762
763 retval = si470x_set_seek(radio, seek->wrap_around, seek->seek_upward);
764
765done:
766 if (retval < 0)
767 dev_warn(&radio->videodev->dev,
768 "set hardware frequency seek failed with %d\n", retval);
769 return retval;
770}
771
772
773/*
774 * si470x_ioctl_ops - video device ioctl operations
775 */
776static const struct v4l2_ioctl_ops si470x_ioctl_ops = {
777 .vidioc_querycap = si470x_vidioc_querycap,
778 .vidioc_queryctrl = si470x_vidioc_queryctrl,
779 .vidioc_g_ctrl = si470x_vidioc_g_ctrl,
780 .vidioc_s_ctrl = si470x_vidioc_s_ctrl,
781 .vidioc_g_audio = si470x_vidioc_g_audio,
782 .vidioc_g_tuner = si470x_vidioc_g_tuner,
783 .vidioc_s_tuner = si470x_vidioc_s_tuner,
784 .vidioc_g_frequency = si470x_vidioc_g_frequency,
785 .vidioc_s_frequency = si470x_vidioc_s_frequency,
786 .vidioc_s_hw_freq_seek = si470x_vidioc_s_hw_freq_seek,
787};
788
789
790/*
791 * si470x_viddev_template - video device interface
792 */
793struct video_device si470x_viddev_template = {
794 .fops = &si470x_fops,
795 .name = DRIVER_NAME,
796 .release = video_device_release,
797 .ioctl_ops = &si470x_ioctl_ops,
798};
diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
new file mode 100644
index 000000000000..2d53b6a9409b
--- /dev/null
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -0,0 +1,401 @@
1/*
2 * drivers/media/radio/si470x/radio-si470x-i2c.c
3 *
4 * I2C driver for radios with Silicon Labs Si470x FM Radio Receivers
5 *
6 * Copyright (c) 2009 Samsung Electronics Co.Ltd
7 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24
25/*
26 * ToDo:
27 * - RDS support
28 */
29
30
31/* driver definitions */
32#define DRIVER_AUTHOR "Joonyoung Shim <jy0922.shim@samsung.com>";
33#define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 0)
34#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
35#define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"
36#define DRIVER_VERSION "1.0.0"
37
38/* kernel includes */
39#include <linux/i2c.h>
40#include <linux/delay.h>
41
42#include "radio-si470x.h"
43
44
45/* I2C Device ID List */
46static const struct i2c_device_id si470x_i2c_id[] = {
47 /* Generic Entry */
48 { "si470x", 0 },
49 /* Terminating entry */
50 { }
51};
52MODULE_DEVICE_TABLE(i2c, si470x_i2c_id);
53
54
55
56/**************************************************************************
57 * Module Parameters
58 **************************************************************************/
59
60/* Radio Nr */
61static int radio_nr = -1;
62module_param(radio_nr, int, 0444);
63MODULE_PARM_DESC(radio_nr, "Radio Nr");
64
65
66
67/**************************************************************************
68 * I2C Definitions
69 **************************************************************************/
70
71/* Write starts with the upper byte of register 0x02 */
72#define WRITE_REG_NUM 8
73#define WRITE_INDEX(i) (i + 0x02)
74
75/* Read starts with the upper byte of register 0x0a */
76#define READ_REG_NUM RADIO_REGISTER_NUM
77#define READ_INDEX(i) ((i + RADIO_REGISTER_NUM - 0x0a) % READ_REG_NUM)
78
79
80
81/**************************************************************************
82 * General Driver Functions - REGISTERs
83 **************************************************************************/
84
85/*
86 * si470x_get_register - read register
87 */
88int si470x_get_register(struct si470x_device *radio, int regnr)
89{
90 u16 buf[READ_REG_NUM];
91 struct i2c_msg msgs[1] = {
92 { radio->client->addr, I2C_M_RD, sizeof(u16) * READ_REG_NUM,
93 (void *)buf },
94 };
95
96 if (i2c_transfer(radio->client->adapter, msgs, 1) != 1)
97 return -EIO;
98
99 radio->registers[regnr] = __be16_to_cpu(buf[READ_INDEX(regnr)]);
100
101 return 0;
102}
103
104
105/*
106 * si470x_set_register - write register
107 */
108int si470x_set_register(struct si470x_device *radio, int regnr)
109{
110 int i;
111 u16 buf[WRITE_REG_NUM];
112 struct i2c_msg msgs[1] = {
113 { radio->client->addr, 0, sizeof(u16) * WRITE_REG_NUM,
114 (void *)buf },
115 };
116
117 for (i = 0; i < WRITE_REG_NUM; i++)
118 buf[i] = __cpu_to_be16(radio->registers[WRITE_INDEX(i)]);
119
120 if (i2c_transfer(radio->client->adapter, msgs, 1) != 1)
121 return -EIO;
122
123 return 0;
124}
125
126
127
128/**************************************************************************
129 * General Driver Functions - ENTIRE REGISTERS
130 **************************************************************************/
131
132/*
133 * si470x_get_all_registers - read entire registers
134 */
135static int si470x_get_all_registers(struct si470x_device *radio)
136{
137 int i;
138 u16 buf[READ_REG_NUM];
139 struct i2c_msg msgs[1] = {
140 { radio->client->addr, I2C_M_RD, sizeof(u16) * READ_REG_NUM,
141 (void *)buf },
142 };
143
144 if (i2c_transfer(radio->client->adapter, msgs, 1) != 1)
145 return -EIO;
146
147 for (i = 0; i < READ_REG_NUM; i++)
148 radio->registers[i] = __be16_to_cpu(buf[READ_INDEX(i)]);
149
150 return 0;
151}
152
153
154
155/**************************************************************************
156 * General Driver Functions - DISCONNECT_CHECK
157 **************************************************************************/
158
159/*
160 * si470x_disconnect_check - check whether radio disconnects
161 */
162int si470x_disconnect_check(struct si470x_device *radio)
163{
164 return 0;
165}
166
167
168
169/**************************************************************************
170 * File Operations Interface
171 **************************************************************************/
172
173/*
174 * si470x_fops_open - file open
175 */
176static int si470x_fops_open(struct file *file)
177{
178 struct si470x_device *radio = video_drvdata(file);
179 int retval = 0;
180
181 mutex_lock(&radio->lock);
182 radio->users++;
183
184 if (radio->users == 1)
185 /* start radio */
186 retval = si470x_start(radio);
187
188 mutex_unlock(&radio->lock);
189
190 return retval;
191}
192
193
194/*
195 * si470x_fops_release - file release
196 */
197static int si470x_fops_release(struct file *file)
198{
199 struct si470x_device *radio = video_drvdata(file);
200 int retval = 0;
201
202 /* safety check */
203 if (!radio)
204 return -ENODEV;
205
206 mutex_lock(&radio->lock);
207 radio->users--;
208 if (radio->users == 0)
209 /* stop radio */
210 retval = si470x_stop(radio);
211
212 mutex_unlock(&radio->lock);
213
214 return retval;
215}
216
217
218/*
219 * si470x_fops - file operations interface
220 */
221const struct v4l2_file_operations si470x_fops = {
222 .owner = THIS_MODULE,
223 .ioctl = video_ioctl2,
224 .open = si470x_fops_open,
225 .release = si470x_fops_release,
226};
227
228
229
230/**************************************************************************
231 * Video4Linux Interface
232 **************************************************************************/
233
234/*
235 * si470x_vidioc_querycap - query device capabilities
236 */
237int si470x_vidioc_querycap(struct file *file, void *priv,
238 struct v4l2_capability *capability)
239{
240 strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
241 strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
242 capability->version = DRIVER_KERNEL_VERSION;
243 capability->capabilities = V4L2_CAP_HW_FREQ_SEEK |
244 V4L2_CAP_TUNER | V4L2_CAP_RADIO;
245
246 return 0;
247}
248
249
250
251/**************************************************************************
252 * I2C Interface
253 **************************************************************************/
254
255/*
256 * si470x_i2c_probe - probe for the device
257 */
258static int __devinit si470x_i2c_probe(struct i2c_client *client,
259 const struct i2c_device_id *id)
260{
261 struct si470x_device *radio;
262 int retval = 0;
263 unsigned char version_warning = 0;
264
265 /* private data allocation and initialization */
266 radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);
267 if (!radio) {
268 retval = -ENOMEM;
269 goto err_initial;
270 }
271 radio->users = 0;
272 radio->client = client;
273 mutex_init(&radio->lock);
274
275 /* video device allocation and initialization */
276 radio->videodev = video_device_alloc();
277 if (!radio->videodev) {
278 retval = -ENOMEM;
279 goto err_radio;
280 }
281 memcpy(radio->videodev, &si470x_viddev_template,
282 sizeof(si470x_viddev_template));
283 video_set_drvdata(radio->videodev, radio);
284
285 /* power up : need 110ms */
286 radio->registers[POWERCFG] = POWERCFG_ENABLE;
287 if (si470x_set_register(radio, POWERCFG) < 0) {
288 retval = -EIO;
289 goto err_all;
290 }
291 msleep(110);
292
293 /* get device and chip versions */
294 if (si470x_get_all_registers(radio) < 0) {
295 retval = -EIO;
296 goto err_video;
297 }
298 dev_info(&client->dev, "DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
299 radio->registers[DEVICEID], radio->registers[CHIPID]);
300 if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
301 dev_warn(&client->dev,
302 "This driver is known to work with "
303 "firmware version %hu,\n", RADIO_FW_VERSION);
304 dev_warn(&client->dev,
305 "but the device has firmware version %hu.\n",
306 radio->registers[CHIPID] & CHIPID_FIRMWARE);
307 version_warning = 1;
308 }
309
310 /* give out version warning */
311 if (version_warning == 1) {
312 dev_warn(&client->dev,
313 "If you have some trouble using this driver,\n");
314 dev_warn(&client->dev,
315 "please report to V4L ML at "
316 "linux-media@vger.kernel.org\n");
317 }
318
319 /* set initial frequency */
320 si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
321
322 /* register video device */
323 retval = video_register_device(radio->videodev, VFL_TYPE_RADIO,
324 radio_nr);
325 if (retval) {
326 dev_warn(&client->dev, "Could not register video device\n");
327 goto err_all;
328 }
329 i2c_set_clientdata(client, radio);
330
331 return 0;
332err_all:
333err_video:
334 video_device_release(radio->videodev);
335err_radio:
336 kfree(radio);
337err_initial:
338 return retval;
339}
340
341
342/*
343 * si470x_i2c_remove - remove the device
344 */
345static __devexit int si470x_i2c_remove(struct i2c_client *client)
346{
347 struct si470x_device *radio = i2c_get_clientdata(client);
348
349 video_unregister_device(radio->videodev);
350 kfree(radio);
351 i2c_set_clientdata(client, NULL);
352
353 return 0;
354}
355
356
357/*
358 * si470x_i2c_driver - i2c driver interface
359 */
360static struct i2c_driver si470x_i2c_driver = {
361 .driver = {
362 .name = "si470x",
363 .owner = THIS_MODULE,
364 },
365 .probe = si470x_i2c_probe,
366 .remove = __devexit_p(si470x_i2c_remove),
367 .id_table = si470x_i2c_id,
368};
369
370
371
372/**************************************************************************
373 * Module Interface
374 **************************************************************************/
375
376/*
377 * si470x_i2c_init - module init
378 */
379static int __init si470x_i2c_init(void)
380{
381 printk(KERN_INFO DRIVER_DESC ", Version " DRIVER_VERSION "\n");
382 return i2c_add_driver(&si470x_i2c_driver);
383}
384
385
386/*
387 * si470x_i2c_exit - module exit
388 */
389static void __exit si470x_i2c_exit(void)
390{
391 i2c_del_driver(&si470x_i2c_driver);
392}
393
394
395module_init(si470x_i2c_init);
396module_exit(si470x_i2c_exit);
397
398MODULE_LICENSE("GPL");
399MODULE_AUTHOR(DRIVER_AUTHOR);
400MODULE_DESCRIPTION(DRIVER_DESC);
401MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
new file mode 100644
index 000000000000..f2d0e1ddb301
--- /dev/null
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -0,0 +1,988 @@
1/*
2 * drivers/media/radio/si470x/radio-si470x-usb.c
3 *
4 * USB driver for radios with Silicon Labs Si470x FM Radio Receivers
5 *
6 * Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23
24/*
25 * ToDo:
26 * - add firmware download/update support
27 */
28
29
30/* driver definitions */
31#define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>"
32#define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 10)
33#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
34#define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"
35#define DRIVER_VERSION "1.0.10"
36
37/* kernel includes */
38#include <linux/usb.h>
39#include <linux/hid.h>
40
41#include "radio-si470x.h"
42
43
44/* USB Device ID List */
45static struct usb_device_id si470x_usb_driver_id_table[] = {
46 /* Silicon Labs USB FM Radio Reference Design */
47 { USB_DEVICE_AND_INTERFACE_INFO(0x10c4, 0x818a, USB_CLASS_HID, 0, 0) },
48 /* ADS/Tech FM Radio Receiver (formerly Instant FM Music) */
49 { USB_DEVICE_AND_INTERFACE_INFO(0x06e1, 0xa155, USB_CLASS_HID, 0, 0) },
50 /* KWorld USB FM Radio SnapMusic Mobile 700 (FM700) */
51 { USB_DEVICE_AND_INTERFACE_INFO(0x1b80, 0xd700, USB_CLASS_HID, 0, 0) },
52 /* Sanei Electric, Inc. FM USB Radio (sold as DealExtreme.com PCear) */
53 { USB_DEVICE_AND_INTERFACE_INFO(0x10c5, 0x819a, USB_CLASS_HID, 0, 0) },
54 /* Terminating entry */
55 { }
56};
57MODULE_DEVICE_TABLE(usb, si470x_usb_driver_id_table);
58
59
60
61/**************************************************************************
62 * Module Parameters
63 **************************************************************************/
64
65/* Radio Nr */
66static int radio_nr = -1;
67module_param(radio_nr, int, 0444);
68MODULE_PARM_DESC(radio_nr, "Radio Nr");
69
70/* USB timeout */
71static unsigned int usb_timeout = 500;
72module_param(usb_timeout, uint, 0644);
73MODULE_PARM_DESC(usb_timeout, "USB timeout (ms): *500*");
74
75/* RDS buffer blocks */
76static unsigned int rds_buf = 100;
77module_param(rds_buf, uint, 0444);
78MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*");
79
80/* RDS maximum block errors */
81static unsigned short max_rds_errors = 1;
82/* 0 means 0 errors requiring correction */
83/* 1 means 1-2 errors requiring correction (used by original USBRadio.exe) */
84/* 2 means 3-5 errors requiring correction */
85/* 3 means 6+ errors or errors in checkword, correction not possible */
86module_param(max_rds_errors, ushort, 0644);
87MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*");
88
89
90
91/**************************************************************************
92 * USB HID Reports
93 **************************************************************************/
94
95/* Reports 1-16 give direct read/write access to the 16 Si470x registers */
96/* with the (REPORT_ID - 1) corresponding to the register address across USB */
97/* endpoint 0 using GET_REPORT and SET_REPORT */
98#define REGISTER_REPORT_SIZE (RADIO_REGISTER_SIZE + 1)
99#define REGISTER_REPORT(reg) ((reg) + 1)
100
101/* Report 17 gives direct read/write access to the entire Si470x register */
102/* map across endpoint 0 using GET_REPORT and SET_REPORT */
103#define ENTIRE_REPORT_SIZE (RADIO_REGISTER_NUM * RADIO_REGISTER_SIZE + 1)
104#define ENTIRE_REPORT 17
105
106/* Report 18 is used to send the lowest 6 Si470x registers up the HID */
107/* interrupt endpoint 1 to Windows every 20 milliseconds for status */
108#define RDS_REPORT_SIZE (RDS_REGISTER_NUM * RADIO_REGISTER_SIZE + 1)
109#define RDS_REPORT 18
110
111/* Report 19: LED state */
112#define LED_REPORT_SIZE 3
113#define LED_REPORT 19
114
115/* Report 19: stream */
116#define STREAM_REPORT_SIZE 3
117#define STREAM_REPORT 19
118
119/* Report 20: scratch */
120#define SCRATCH_PAGE_SIZE 63
121#define SCRATCH_REPORT_SIZE (SCRATCH_PAGE_SIZE + 1)
122#define SCRATCH_REPORT 20
123
124/* Reports 19-22: flash upgrade of the C8051F321 */
125#define WRITE_REPORT_SIZE 4
126#define WRITE_REPORT 19
127#define FLASH_REPORT_SIZE 64
128#define FLASH_REPORT 20
129#define CRC_REPORT_SIZE 3
130#define CRC_REPORT 21
131#define RESPONSE_REPORT_SIZE 2
132#define RESPONSE_REPORT 22
133
134/* Report 23: currently unused, but can accept 60 byte reports on the HID */
135/* interrupt out endpoint 2 every 1 millisecond */
136#define UNUSED_REPORT 23
137
138
139
140/**************************************************************************
141 * Software/Hardware Versions from Scratch Page
142 **************************************************************************/
143#define RADIO_SW_VERSION_NOT_BOOTLOADABLE 6
144#define RADIO_SW_VERSION 7
145#define RADIO_HW_VERSION 1
146
147
148
149/**************************************************************************
150 * LED State Definitions
151 **************************************************************************/
152#define LED_COMMAND 0x35
153
154#define NO_CHANGE_LED 0x00
155#define ALL_COLOR_LED 0x01 /* streaming state */
156#define BLINK_GREEN_LED 0x02 /* connect state */
157#define BLINK_RED_LED 0x04
158#define BLINK_ORANGE_LED 0x10 /* disconnect state */
159#define SOLID_GREEN_LED 0x20 /* tuning/seeking state */
160#define SOLID_RED_LED 0x40 /* bootload state */
161#define SOLID_ORANGE_LED 0x80
162
163
164
165/**************************************************************************
166 * Stream State Definitions
167 **************************************************************************/
168#define STREAM_COMMAND 0x36
169#define STREAM_VIDPID 0x00
170#define STREAM_AUDIO 0xff
171
172
173
174/**************************************************************************
175 * Bootloader / Flash Commands
176 **************************************************************************/
177
178/* unique id sent to bootloader and required to put into a bootload state */
179#define UNIQUE_BL_ID 0x34
180
181/* mask for the flash data */
182#define FLASH_DATA_MASK 0x55
183
184/* bootloader commands */
185#define GET_SW_VERSION_COMMAND 0x00
186#define SET_PAGE_COMMAND 0x01
187#define ERASE_PAGE_COMMAND 0x02
188#define WRITE_PAGE_COMMAND 0x03
189#define CRC_ON_PAGE_COMMAND 0x04
190#define READ_FLASH_BYTE_COMMAND 0x05
191#define RESET_DEVICE_COMMAND 0x06
192#define GET_HW_VERSION_COMMAND 0x07
193#define BLANK 0xff
194
195/* bootloader command responses */
196#define COMMAND_OK 0x01
197#define COMMAND_FAILED 0x02
198#define COMMAND_PENDING 0x03
199
200
201
202/**************************************************************************
203 * General Driver Functions - REGISTER_REPORTs
204 **************************************************************************/
205
206/*
207 * si470x_get_report - receive a HID report
208 */
209static int si470x_get_report(struct si470x_device *radio, void *buf, int size)
210{
211 unsigned char *report = (unsigned char *) buf;
212 int retval;
213
214 retval = usb_control_msg(radio->usbdev,
215 usb_rcvctrlpipe(radio->usbdev, 0),
216 HID_REQ_GET_REPORT,
217 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
218 report[0], 2,
219 buf, size, usb_timeout);
220
221 if (retval < 0)
222 dev_warn(&radio->intf->dev,
223 "si470x_get_report: usb_control_msg returned %d\n",
224 retval);
225 return retval;
226}
227
228
229/*
230 * si470x_set_report - send a HID report
231 */
232static int si470x_set_report(struct si470x_device *radio, void *buf, int size)
233{
234 unsigned char *report = (unsigned char *) buf;
235 int retval;
236
237 retval = usb_control_msg(radio->usbdev,
238 usb_sndctrlpipe(radio->usbdev, 0),
239 HID_REQ_SET_REPORT,
240 USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
241 report[0], 2,
242 buf, size, usb_timeout);
243
244 if (retval < 0)
245 dev_warn(&radio->intf->dev,
246 "si470x_set_report: usb_control_msg returned %d\n",
247 retval);
248 return retval;
249}
250
251
252/*
253 * si470x_get_register - read register
254 */
255int si470x_get_register(struct si470x_device *radio, int regnr)
256{
257 unsigned char buf[REGISTER_REPORT_SIZE];
258 int retval;
259
260 buf[0] = REGISTER_REPORT(regnr);
261
262 retval = si470x_get_report(radio, (void *) &buf, sizeof(buf));
263
264 if (retval >= 0)
265 radio->registers[regnr] = get_unaligned_be16(&buf[1]);
266
267 return (retval < 0) ? -EINVAL : 0;
268}
269
270
271/*
272 * si470x_set_register - write register
273 */
274int si470x_set_register(struct si470x_device *radio, int regnr)
275{
276 unsigned char buf[REGISTER_REPORT_SIZE];
277 int retval;
278
279 buf[0] = REGISTER_REPORT(regnr);
280 put_unaligned_be16(radio->registers[regnr], &buf[1]);
281
282 retval = si470x_set_report(radio, (void *) &buf, sizeof(buf));
283
284 return (retval < 0) ? -EINVAL : 0;
285}
286
287
288
289/**************************************************************************
290 * General Driver Functions - ENTIRE_REPORT
291 **************************************************************************/
292
293/*
294 * si470x_get_all_registers - read entire registers
295 */
296static int si470x_get_all_registers(struct si470x_device *radio)
297{
298 unsigned char buf[ENTIRE_REPORT_SIZE];
299 int retval;
300 unsigned char regnr;
301
302 buf[0] = ENTIRE_REPORT;
303
304 retval = si470x_get_report(radio, (void *) &buf, sizeof(buf));
305
306 if (retval >= 0)
307 for (regnr = 0; regnr < RADIO_REGISTER_NUM; regnr++)
308 radio->registers[regnr] = get_unaligned_be16(
309 &buf[regnr * RADIO_REGISTER_SIZE + 1]);
310
311 return (retval < 0) ? -EINVAL : 0;
312}
313
314
315
316/**************************************************************************
317 * General Driver Functions - LED_REPORT
318 **************************************************************************/
319
320/*
321 * si470x_set_led_state - sets the led state
322 */
323static int si470x_set_led_state(struct si470x_device *radio,
324 unsigned char led_state)
325{
326 unsigned char buf[LED_REPORT_SIZE];
327 int retval;
328
329 buf[0] = LED_REPORT;
330 buf[1] = LED_COMMAND;
331 buf[2] = led_state;
332
333 retval = si470x_set_report(radio, (void *) &buf, sizeof(buf));
334
335 return (retval < 0) ? -EINVAL : 0;
336}
337
338
339
340/**************************************************************************
341 * General Driver Functions - SCRATCH_REPORT
342 **************************************************************************/
343
344/*
345 * si470x_get_scratch_versions - gets the scratch page and version infos
346 */
347static int si470x_get_scratch_page_versions(struct si470x_device *radio)
348{
349 unsigned char buf[SCRATCH_REPORT_SIZE];
350 int retval;
351
352 buf[0] = SCRATCH_REPORT;
353
354 retval = si470x_get_report(radio, (void *) &buf, sizeof(buf));
355
356 if (retval < 0)
357 dev_warn(&radio->intf->dev, "si470x_get_scratch: "
358 "si470x_get_report returned %d\n", retval);
359 else {
360 radio->software_version = buf[1];
361 radio->hardware_version = buf[2];
362 }
363
364 return (retval < 0) ? -EINVAL : 0;
365}
366
367
368
369/**************************************************************************
370 * General Driver Functions - DISCONNECT_CHECK
371 **************************************************************************/
372
373/*
374 * si470x_disconnect_check - check whether radio disconnects
375 */
376int si470x_disconnect_check(struct si470x_device *radio)
377{
378 if (radio->disconnected)
379 return -EIO;
380 else
381 return 0;
382}
383
384
385
386/**************************************************************************
387 * RDS Driver Functions
388 **************************************************************************/
389
390/*
391 * si470x_int_in_callback - rds callback and processing function
392 *
393 * TODO: do we need to use mutex locks in some sections?
394 */
395static void si470x_int_in_callback(struct urb *urb)
396{
397 struct si470x_device *radio = urb->context;
398 unsigned char buf[RDS_REPORT_SIZE];
399 int retval;
400 unsigned char regnr;
401 unsigned char blocknum;
402 unsigned short bler; /* rds block errors */
403 unsigned short rds;
404 unsigned char tmpbuf[3];
405
406 if (urb->status) {
407 if (urb->status == -ENOENT ||
408 urb->status == -ECONNRESET ||
409 urb->status == -ESHUTDOWN) {
410 return;
411 } else {
412 dev_warn(&radio->intf->dev,
413 "non-zero urb status (%d)\n", urb->status);
414 goto resubmit; /* Maybe we can recover. */
415 }
416 }
417
418 /* safety checks */
419 if (radio->disconnected)
420 return;
421 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
422 goto resubmit;
423
424 if (urb->actual_length > 0) {
425 /* Update RDS registers with URB data */
426 buf[0] = RDS_REPORT;
427 for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++)
428 radio->registers[STATUSRSSI + regnr] =
429 get_unaligned_be16(&radio->int_in_buffer[
430 regnr * RADIO_REGISTER_SIZE + 1]);
431 /* get rds blocks */
432 if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSR) == 0) {
433 /* No RDS group ready, better luck next time */
434 goto resubmit;
435 }
436 if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSS) == 0) {
437 /* RDS decoder not synchronized */
438 goto resubmit;
439 }
440 for (blocknum = 0; blocknum < 4; blocknum++) {
441 switch (blocknum) {
442 default:
443 bler = (radio->registers[STATUSRSSI] &
444 STATUSRSSI_BLERA) >> 9;
445 rds = radio->registers[RDSA];
446 break;
447 case 1:
448 bler = (radio->registers[READCHAN] &
449 READCHAN_BLERB) >> 14;
450 rds = radio->registers[RDSB];
451 break;
452 case 2:
453 bler = (radio->registers[READCHAN] &
454 READCHAN_BLERC) >> 12;
455 rds = radio->registers[RDSC];
456 break;
457 case 3:
458 bler = (radio->registers[READCHAN] &
459 READCHAN_BLERD) >> 10;
460 rds = radio->registers[RDSD];
461 break;
462 };
463
464 /* Fill the V4L2 RDS buffer */
465 put_unaligned_le16(rds, &tmpbuf);
466 tmpbuf[2] = blocknum; /* offset name */
467 tmpbuf[2] |= blocknum << 3; /* received offset */
468 if (bler > max_rds_errors)
469 tmpbuf[2] |= 0x80; /* uncorrectable errors */
470 else if (bler > 0)
471 tmpbuf[2] |= 0x40; /* corrected error(s) */
472
473 /* copy RDS block to internal buffer */
474 memcpy(&radio->buffer[radio->wr_index], &tmpbuf, 3);
475 radio->wr_index += 3;
476
477 /* wrap write pointer */
478 if (radio->wr_index >= radio->buf_size)
479 radio->wr_index = 0;
480
481 /* check for overflow */
482 if (radio->wr_index == radio->rd_index) {
483 /* increment and wrap read pointer */
484 radio->rd_index += 3;
485 if (radio->rd_index >= radio->buf_size)
486 radio->rd_index = 0;
487 }
488 }
489 if (radio->wr_index != radio->rd_index)
490 wake_up_interruptible(&radio->read_queue);
491 }
492
493resubmit:
494 /* Resubmit if we're still running. */
495 if (radio->int_in_running && radio->usbdev) {
496 retval = usb_submit_urb(radio->int_in_urb, GFP_ATOMIC);
497 if (retval) {
498 dev_warn(&radio->intf->dev,
499 "resubmitting urb failed (%d)", retval);
500 radio->int_in_running = 0;
501 }
502 }
503}
504
505
506
507/**************************************************************************
508 * File Operations Interface
509 **************************************************************************/
510
511/*
512 * si470x_fops_read - read RDS data
513 */
514static ssize_t si470x_fops_read(struct file *file, char __user *buf,
515 size_t count, loff_t *ppos)
516{
517 struct si470x_device *radio = video_drvdata(file);
518 int retval = 0;
519 unsigned int block_count = 0;
520
521 /* switch on rds reception */
522 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
523 si470x_rds_on(radio);
524
525 /* block if no new data available */
526 while (radio->wr_index == radio->rd_index) {
527 if (file->f_flags & O_NONBLOCK) {
528 retval = -EWOULDBLOCK;
529 goto done;
530 }
531 if (wait_event_interruptible(radio->read_queue,
532 radio->wr_index != radio->rd_index) < 0) {
533 retval = -EINTR;
534 goto done;
535 }
536 }
537
538 /* calculate block count from byte count */
539 count /= 3;
540
541 /* copy RDS block out of internal buffer and to user buffer */
542 mutex_lock(&radio->lock);
543 while (block_count < count) {
544 if (radio->rd_index == radio->wr_index)
545 break;
546
547 /* always transfer rds complete blocks */
548 if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
549 /* retval = -EFAULT; */
550 break;
551
552 /* increment and wrap read pointer */
553 radio->rd_index += 3;
554 if (radio->rd_index >= radio->buf_size)
555 radio->rd_index = 0;
556
557 /* increment counters */
558 block_count++;
559 buf += 3;
560 retval += 3;
561 }
562 mutex_unlock(&radio->lock);
563
564done:
565 return retval;
566}
567
568
569/*
570 * si470x_fops_poll - poll RDS data
571 */
572static unsigned int si470x_fops_poll(struct file *file,
573 struct poll_table_struct *pts)
574{
575 struct si470x_device *radio = video_drvdata(file);
576 int retval = 0;
577
578 /* switch on rds reception */
579 if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
580 si470x_rds_on(radio);
581
582 poll_wait(file, &radio->read_queue, pts);
583
584 if (radio->rd_index != radio->wr_index)
585 retval = POLLIN | POLLRDNORM;
586
587 return retval;
588}
589
590
591/*
592 * si470x_fops_open - file open
593 */
594static int si470x_fops_open(struct file *file)
595{
596 struct si470x_device *radio = video_drvdata(file);
597 int retval;
598
599 lock_kernel();
600 radio->users++;
601
602 retval = usb_autopm_get_interface(radio->intf);
603 if (retval < 0) {
604 radio->users--;
605 retval = -EIO;
606 goto done;
607 }
608
609 if (radio->users == 1) {
610 /* start radio */
611 retval = si470x_start(radio);
612 if (retval < 0) {
613 usb_autopm_put_interface(radio->intf);
614 goto done;
615 }
616
617 /* initialize interrupt urb */
618 usb_fill_int_urb(radio->int_in_urb, radio->usbdev,
619 usb_rcvintpipe(radio->usbdev,
620 radio->int_in_endpoint->bEndpointAddress),
621 radio->int_in_buffer,
622 le16_to_cpu(radio->int_in_endpoint->wMaxPacketSize),
623 si470x_int_in_callback,
624 radio,
625 radio->int_in_endpoint->bInterval);
626
627 radio->int_in_running = 1;
628 mb();
629
630 retval = usb_submit_urb(radio->int_in_urb, GFP_KERNEL);
631 if (retval) {
632 dev_info(&radio->intf->dev,
633 "submitting int urb failed (%d)\n", retval);
634 radio->int_in_running = 0;
635 usb_autopm_put_interface(radio->intf);
636 }
637 }
638
639done:
640 unlock_kernel();
641 return retval;
642}
643
644
645/*
646 * si470x_fops_release - file release
647 */
648static int si470x_fops_release(struct file *file)
649{
650 struct si470x_device *radio = video_drvdata(file);
651 int retval = 0;
652
653 /* safety check */
654 if (!radio) {
655 retval = -ENODEV;
656 goto done;
657 }
658
659 mutex_lock(&radio->disconnect_lock);
660 radio->users--;
661 if (radio->users == 0) {
662 /* shutdown interrupt handler */
663 if (radio->int_in_running) {
664 radio->int_in_running = 0;
665 if (radio->int_in_urb)
666 usb_kill_urb(radio->int_in_urb);
667 }
668
669 if (radio->disconnected) {
670 video_unregister_device(radio->videodev);
671 kfree(radio->int_in_buffer);
672 kfree(radio->buffer);
673 kfree(radio);
674 goto unlock;
675 }
676
677 /* cancel read processes */
678 wake_up_interruptible(&radio->read_queue);
679
680 /* stop radio */
681 retval = si470x_stop(radio);
682 usb_autopm_put_interface(radio->intf);
683 }
684unlock:
685 mutex_unlock(&radio->disconnect_lock);
686done:
687 return retval;
688}
689
690
691/*
692 * si470x_fops - file operations interface
693 */
694const struct v4l2_file_operations si470x_fops = {
695 .owner = THIS_MODULE,
696 .read = si470x_fops_read,
697 .poll = si470x_fops_poll,
698 .ioctl = video_ioctl2,
699 .open = si470x_fops_open,
700 .release = si470x_fops_release,
701};
702
703
704
705/**************************************************************************
706 * Video4Linux Interface
707 **************************************************************************/
708
709/*
710 * si470x_vidioc_querycap - query device capabilities
711 */
712int si470x_vidioc_querycap(struct file *file, void *priv,
713 struct v4l2_capability *capability)
714{
715 struct si470x_device *radio = video_drvdata(file);
716
717 strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
718 strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
719 usb_make_path(radio->usbdev, capability->bus_info,
720 sizeof(capability->bus_info));
721 capability->version = DRIVER_KERNEL_VERSION;
722 capability->capabilities = V4L2_CAP_HW_FREQ_SEEK |
723 V4L2_CAP_TUNER | V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE;
724
725 return 0;
726}
727
728
729
730/**************************************************************************
731 * USB Interface
732 **************************************************************************/
733
734/*
735 * si470x_usb_driver_probe - probe for the device
736 */
737static int si470x_usb_driver_probe(struct usb_interface *intf,
738 const struct usb_device_id *id)
739{
740 struct si470x_device *radio;
741 struct usb_host_interface *iface_desc;
742 struct usb_endpoint_descriptor *endpoint;
743 int i, int_end_size, retval = 0;
744 unsigned char version_warning = 0;
745
746 /* private data allocation and initialization */
747 radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);
748 if (!radio) {
749 retval = -ENOMEM;
750 goto err_initial;
751 }
752 radio->users = 0;
753 radio->disconnected = 0;
754 radio->usbdev = interface_to_usbdev(intf);
755 radio->intf = intf;
756 mutex_init(&radio->disconnect_lock);
757 mutex_init(&radio->lock);
758
759 iface_desc = intf->cur_altsetting;
760
761 /* Set up interrupt endpoint information. */
762 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
763 endpoint = &iface_desc->endpoint[i].desc;
764 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
765 USB_DIR_IN) && ((endpoint->bmAttributes &
766 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT))
767 radio->int_in_endpoint = endpoint;
768 }
769 if (!radio->int_in_endpoint) {
770 dev_info(&intf->dev, "could not find interrupt in endpoint\n");
771 retval = -EIO;
772 goto err_radio;
773 }
774
775 int_end_size = le16_to_cpu(radio->int_in_endpoint->wMaxPacketSize);
776
777 radio->int_in_buffer = kmalloc(int_end_size, GFP_KERNEL);
778 if (!radio->int_in_buffer) {
779 dev_info(&intf->dev, "could not allocate int_in_buffer");
780 retval = -ENOMEM;
781 goto err_radio;
782 }
783
784 radio->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
785 if (!radio->int_in_urb) {
786 dev_info(&intf->dev, "could not allocate int_in_urb");
787 retval = -ENOMEM;
788 goto err_intbuffer;
789 }
790
791 /* video device allocation and initialization */
792 radio->videodev = video_device_alloc();
793 if (!radio->videodev) {
794 retval = -ENOMEM;
795 goto err_intbuffer;
796 }
797 memcpy(radio->videodev, &si470x_viddev_template,
798 sizeof(si470x_viddev_template));
799 video_set_drvdata(radio->videodev, radio);
800
801 /* get device and chip versions */
802 if (si470x_get_all_registers(radio) < 0) {
803 retval = -EIO;
804 goto err_video;
805 }
806 dev_info(&intf->dev, "DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
807 radio->registers[DEVICEID], radio->registers[CHIPID]);
808 if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
809 dev_warn(&intf->dev,
810 "This driver is known to work with "
811 "firmware version %hu,\n", RADIO_FW_VERSION);
812 dev_warn(&intf->dev,
813 "but the device has firmware version %hu.\n",
814 radio->registers[CHIPID] & CHIPID_FIRMWARE);
815 version_warning = 1;
816 }
817
818 /* get software and hardware versions */
819 if (si470x_get_scratch_page_versions(radio) < 0) {
820 retval = -EIO;
821 goto err_video;
822 }
823 dev_info(&intf->dev, "software version %d, hardware version %d\n",
824 radio->software_version, radio->hardware_version);
825 if (radio->software_version < RADIO_SW_VERSION) {
826 dev_warn(&intf->dev,
827 "This driver is known to work with "
828 "software version %hu,\n", RADIO_SW_VERSION);
829 dev_warn(&intf->dev,
830 "but the device has software version %hu.\n",
831 radio->software_version);
832 version_warning = 1;
833 }
834 if (radio->hardware_version < RADIO_HW_VERSION) {
835 dev_warn(&intf->dev,
836 "This driver is known to work with "
837 "hardware version %hu,\n", RADIO_HW_VERSION);
838 dev_warn(&intf->dev,
839 "but the device has hardware version %hu.\n",
840 radio->hardware_version);
841 version_warning = 1;
842 }
843
844 /* give out version warning */
845 if (version_warning == 1) {
846 dev_warn(&intf->dev,
847 "If you have some trouble using this driver,\n");
848 dev_warn(&intf->dev,
849 "please report to V4L ML at "
850 "linux-media@vger.kernel.org\n");
851 }
852
853 /* set initial frequency */
854 si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
855
856 /* set led to connect state */
857 si470x_set_led_state(radio, BLINK_GREEN_LED);
858
859 /* rds buffer allocation */
860 radio->buf_size = rds_buf * 3;
861 radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL);
862 if (!radio->buffer) {
863 retval = -EIO;
864 goto err_video;
865 }
866
867 /* rds buffer configuration */
868 radio->wr_index = 0;
869 radio->rd_index = 0;
870 init_waitqueue_head(&radio->read_queue);
871
872 /* register video device */
873 retval = video_register_device(radio->videodev, VFL_TYPE_RADIO,
874 radio_nr);
875 if (retval) {
876 dev_warn(&intf->dev, "Could not register video device\n");
877 goto err_all;
878 }
879 usb_set_intfdata(intf, radio);
880
881 return 0;
882err_all:
883 kfree(radio->buffer);
884err_video:
885 video_device_release(radio->videodev);
886err_intbuffer:
887 kfree(radio->int_in_buffer);
888err_radio:
889 kfree(radio);
890err_initial:
891 return retval;
892}
893
894
895/*
896 * si470x_usb_driver_suspend - suspend the device
897 */
898static int si470x_usb_driver_suspend(struct usb_interface *intf,
899 pm_message_t message)
900{
901 dev_info(&intf->dev, "suspending now...\n");
902
903 return 0;
904}
905
906
907/*
908 * si470x_usb_driver_resume - resume the device
909 */
910static int si470x_usb_driver_resume(struct usb_interface *intf)
911{
912 dev_info(&intf->dev, "resuming now...\n");
913
914 return 0;
915}
916
917
918/*
919 * si470x_usb_driver_disconnect - disconnect the device
920 */
921static void si470x_usb_driver_disconnect(struct usb_interface *intf)
922{
923 struct si470x_device *radio = usb_get_intfdata(intf);
924
925 mutex_lock(&radio->disconnect_lock);
926 radio->disconnected = 1;
927 usb_set_intfdata(intf, NULL);
928 if (radio->users == 0) {
929 /* set led to disconnect state */
930 si470x_set_led_state(radio, BLINK_ORANGE_LED);
931
932 /* Free data structures. */
933 usb_free_urb(radio->int_in_urb);
934
935 kfree(radio->int_in_buffer);
936 video_unregister_device(radio->videodev);
937 kfree(radio->buffer);
938 kfree(radio);
939 }
940 mutex_unlock(&radio->disconnect_lock);
941}
942
943
944/*
945 * si470x_usb_driver - usb driver interface
946 */
947static struct usb_driver si470x_usb_driver = {
948 .name = DRIVER_NAME,
949 .probe = si470x_usb_driver_probe,
950 .disconnect = si470x_usb_driver_disconnect,
951 .suspend = si470x_usb_driver_suspend,
952 .resume = si470x_usb_driver_resume,
953 .id_table = si470x_usb_driver_id_table,
954 .supports_autosuspend = 1,
955};
956
957
958
959/**************************************************************************
960 * Module Interface
961 **************************************************************************/
962
963/*
964 * si470x_module_init - module init
965 */
966static int __init si470x_module_init(void)
967{
968 printk(KERN_INFO DRIVER_DESC ", Version " DRIVER_VERSION "\n");
969 return usb_register(&si470x_usb_driver);
970}
971
972
973/*
974 * si470x_module_exit - module exit
975 */
976static void __exit si470x_module_exit(void)
977{
978 usb_deregister(&si470x_usb_driver);
979}
980
981
982module_init(si470x_module_init);
983module_exit(si470x_module_exit);
984
985MODULE_LICENSE("GPL");
986MODULE_AUTHOR(DRIVER_AUTHOR);
987MODULE_DESCRIPTION(DRIVER_DESC);
988MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h
new file mode 100644
index 000000000000..d0af194d194c
--- /dev/null
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -0,0 +1,225 @@
1/*
2 * drivers/media/radio/si470x/radio-si470x.h
3 *
4 * Driver for radios with Silicon Labs Si470x FM Radio Receivers
5 *
6 * Copyright (c) 2009 Tobias Lorenz <tobias.lorenz@gmx.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23
24/* driver definitions */
25#define DRIVER_NAME "radio-si470x"
26
27
28/* kernel includes */
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/slab.h>
33#include <linux/smp_lock.h>
34#include <linux/input.h>
35#include <linux/version.h>
36#include <linux/videodev2.h>
37#include <linux/mutex.h>
38#include <media/v4l2-common.h>
39#include <media/v4l2-ioctl.h>
40#include <media/rds.h>
41#include <asm/unaligned.h>
42
43
44
45/**************************************************************************
46 * Register Definitions
47 **************************************************************************/
48#define RADIO_REGISTER_SIZE 2 /* 16 register bit width */
49#define RADIO_REGISTER_NUM 16 /* DEVICEID ... RDSD */
50#define RDS_REGISTER_NUM 6 /* STATUSRSSI ... RDSD */
51
52#define DEVICEID 0 /* Device ID */
53#define DEVICEID_PN 0xf000 /* bits 15..12: Part Number */
54#define DEVICEID_MFGID 0x0fff /* bits 11..00: Manufacturer ID */
55
56#define CHIPID 1 /* Chip ID */
57#define CHIPID_REV 0xfc00 /* bits 15..10: Chip Version */
58#define CHIPID_DEV 0x0200 /* bits 09..09: Device */
59#define CHIPID_FIRMWARE 0x01ff /* bits 08..00: Firmware Version */
60
61#define POWERCFG 2 /* Power Configuration */
62#define POWERCFG_DSMUTE 0x8000 /* bits 15..15: Softmute Disable */
63#define POWERCFG_DMUTE 0x4000 /* bits 14..14: Mute Disable */
64#define POWERCFG_MONO 0x2000 /* bits 13..13: Mono Select */
65#define POWERCFG_RDSM 0x0800 /* bits 11..11: RDS Mode (Si4701 only) */
66#define POWERCFG_SKMODE 0x0400 /* bits 10..10: Seek Mode */
67#define POWERCFG_SEEKUP 0x0200 /* bits 09..09: Seek Direction */
68#define POWERCFG_SEEK 0x0100 /* bits 08..08: Seek */
69#define POWERCFG_DISABLE 0x0040 /* bits 06..06: Powerup Disable */
70#define POWERCFG_ENABLE 0x0001 /* bits 00..00: Powerup Enable */
71
72#define CHANNEL 3 /* Channel */
73#define CHANNEL_TUNE 0x8000 /* bits 15..15: Tune */
74#define CHANNEL_CHAN 0x03ff /* bits 09..00: Channel Select */
75
76#define SYSCONFIG1 4 /* System Configuration 1 */
77#define SYSCONFIG1_RDSIEN 0x8000 /* bits 15..15: RDS Interrupt Enable (Si4701 only) */
78#define SYSCONFIG1_STCIEN 0x4000 /* bits 14..14: Seek/Tune Complete Interrupt Enable */
79#define SYSCONFIG1_RDS 0x1000 /* bits 12..12: RDS Enable (Si4701 only) */
80#define SYSCONFIG1_DE 0x0800 /* bits 11..11: De-emphasis (0=75us 1=50us) */
81#define SYSCONFIG1_AGCD 0x0400 /* bits 10..10: AGC Disable */
82#define SYSCONFIG1_BLNDADJ 0x00c0 /* bits 07..06: Stereo/Mono Blend Level Adjustment */
83#define SYSCONFIG1_GPIO3 0x0030 /* bits 05..04: General Purpose I/O 3 */
84#define SYSCONFIG1_GPIO2 0x000c /* bits 03..02: General Purpose I/O 2 */
85#define SYSCONFIG1_GPIO1 0x0003 /* bits 01..00: General Purpose I/O 1 */
86
87#define SYSCONFIG2 5 /* System Configuration 2 */
88#define SYSCONFIG2_SEEKTH 0xff00 /* bits 15..08: RSSI Seek Threshold */
89#define SYSCONFIG2_BAND 0x0080 /* bits 07..06: Band Select */
90#define SYSCONFIG2_SPACE 0x0030 /* bits 05..04: Channel Spacing */
91#define SYSCONFIG2_VOLUME 0x000f /* bits 03..00: Volume */
92
93#define SYSCONFIG3 6 /* System Configuration 3 */
94#define SYSCONFIG3_SMUTER 0xc000 /* bits 15..14: Softmute Attack/Recover Rate */
95#define SYSCONFIG3_SMUTEA 0x3000 /* bits 13..12: Softmute Attenuation */
96#define SYSCONFIG3_SKSNR 0x00f0 /* bits 07..04: Seek SNR Threshold */
97#define SYSCONFIG3_SKCNT 0x000f /* bits 03..00: Seek FM Impulse Detection Threshold */
98
99#define TEST1 7 /* Test 1 */
100#define TEST1_AHIZEN 0x4000 /* bits 14..14: Audio High-Z Enable */
101
102#define TEST2 8 /* Test 2 */
103/* TEST2 only contains reserved bits */
104
105#define BOOTCONFIG 9 /* Boot Configuration */
106/* BOOTCONFIG only contains reserved bits */
107
108#define STATUSRSSI 10 /* Status RSSI */
109#define STATUSRSSI_RDSR 0x8000 /* bits 15..15: RDS Ready (Si4701 only) */
110#define STATUSRSSI_STC 0x4000 /* bits 14..14: Seek/Tune Complete */
111#define STATUSRSSI_SF 0x2000 /* bits 13..13: Seek Fail/Band Limit */
112#define STATUSRSSI_AFCRL 0x1000 /* bits 12..12: AFC Rail */
113#define STATUSRSSI_RDSS 0x0800 /* bits 11..11: RDS Synchronized (Si4701 only) */
114#define STATUSRSSI_BLERA 0x0600 /* bits 10..09: RDS Block A Errors (Si4701 only) */
115#define STATUSRSSI_ST 0x0100 /* bits 08..08: Stereo Indicator */
116#define STATUSRSSI_RSSI 0x00ff /* bits 07..00: RSSI (Received Signal Strength Indicator) */
117
118#define READCHAN 11 /* Read Channel */
119#define READCHAN_BLERB 0xc000 /* bits 15..14: RDS Block D Errors (Si4701 only) */
120#define READCHAN_BLERC 0x3000 /* bits 13..12: RDS Block C Errors (Si4701 only) */
121#define READCHAN_BLERD 0x0c00 /* bits 11..10: RDS Block B Errors (Si4701 only) */
122#define READCHAN_READCHAN 0x03ff /* bits 09..00: Read Channel */
123
124#define RDSA 12 /* RDSA */
125#define RDSA_RDSA 0xffff /* bits 15..00: RDS Block A Data (Si4701 only) */
126
127#define RDSB 13 /* RDSB */
128#define RDSB_RDSB 0xffff /* bits 15..00: RDS Block B Data (Si4701 only) */
129
130#define RDSC 14 /* RDSC */
131#define RDSC_RDSC 0xffff /* bits 15..00: RDS Block C Data (Si4701 only) */
132
133#define RDSD 15 /* RDSD */
134#define RDSD_RDSD 0xffff /* bits 15..00: RDS Block D Data (Si4701 only) */
135
136
137
138/**************************************************************************
139 * General Driver Definitions
140 **************************************************************************/
141
142/*
143 * si470x_device - private data
144 */
145struct si470x_device {
146 struct video_device *videodev;
147
148 /* driver management */
149 unsigned int users;
150
151 /* Silabs internal registers (0..15) */
152 unsigned short registers[RADIO_REGISTER_NUM];
153
154 /* RDS receive buffer */
155 wait_queue_head_t read_queue;
156 struct mutex lock; /* buffer locking */
157 unsigned char *buffer; /* size is always multiple of three */
158 unsigned int buf_size;
159 unsigned int rd_index;
160 unsigned int wr_index;
161
162#if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE)
163 /* reference to USB and video device */
164 struct usb_device *usbdev;
165 struct usb_interface *intf;
166
167 /* Interrupt endpoint handling */
168 char *int_in_buffer;
169 struct usb_endpoint_descriptor *int_in_endpoint;
170 struct urb *int_in_urb;
171 int int_in_running;
172
173 /* scratch page */
174 unsigned char software_version;
175 unsigned char hardware_version;
176
177 /* driver management */
178 unsigned char disconnected;
179 struct mutex disconnect_lock;
180#endif
181
182#if defined(CONFIG_I2C_SI470X) || defined(CONFIG_I2C_SI470X_MODULE)
183 struct i2c_client *client;
184#endif
185};
186
187
188
189/**************************************************************************
190 * Firmware Versions
191 **************************************************************************/
192
193#define RADIO_FW_VERSION 15
194
195
196
197/**************************************************************************
198 * Frequency Multiplicator
199 **************************************************************************/
200
201/*
202 * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW,
203 * 62.5 kHz otherwise.
204 * The tuner is able to have a channel spacing of 50, 100 or 200 kHz.
205 * tuner->capability is therefore set to V4L2_TUNER_CAP_LOW
206 * The FREQ_MUL is then: 1 MHz / 62.5 Hz = 16000
207 */
208#define FREQ_MUL (1000000 / 62.5)
209
210
211
212/**************************************************************************
213 * Common Functions
214 **************************************************************************/
215extern const struct v4l2_file_operations si470x_fops;
216extern struct video_device si470x_viddev_template;
217int si470x_get_register(struct si470x_device *radio, int regnr);
218int si470x_set_register(struct si470x_device *radio, int regnr);
219int si470x_disconnect_check(struct si470x_device *radio);
220int si470x_set_freq(struct si470x_device *radio, unsigned int freq);
221int si470x_start(struct si470x_device *radio);
222int si470x_stop(struct si470x_device *radio);
223int si470x_rds_on(struct si470x_device *radio);
224int si470x_vidioc_querycap(struct file *file, void *priv,
225 struct v4l2_capability *capability);
diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c
new file mode 100644
index 000000000000..6a0028eb461f
--- /dev/null
+++ b/drivers/media/radio/si4713-i2c.c
@@ -0,0 +1,2060 @@
1/*
2 * drivers/media/radio/si4713-i2c.c
3 *
4 * Silicon Labs Si4713 FM Radio Transmitter I2C commands.
5 *
6 * Copyright (c) 2009 Nokia Corporation
7 * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/mutex.h>
25#include <linux/completion.h>
26#include <linux/delay.h>
27#include <linux/interrupt.h>
28#include <linux/i2c.h>
29#include <media/v4l2-device.h>
30#include <media/v4l2-ioctl.h>
31#include <media/v4l2-common.h>
32
33#include "si4713-i2c.h"
34
35/* module parameters */
36static int debug;
37module_param(debug, int, S_IRUGO | S_IWUSR);
38MODULE_PARM_DESC(debug, "Debug level (0 - 2)");
39
40MODULE_LICENSE("GPL");
41MODULE_AUTHOR("Eduardo Valentin <eduardo.valentin@nokia.com>");
42MODULE_DESCRIPTION("I2C driver for Si4713 FM Radio Transmitter");
43MODULE_VERSION("0.0.1");
44
45#define DEFAULT_RDS_PI 0x00
46#define DEFAULT_RDS_PTY 0x00
47#define DEFAULT_RDS_PS_NAME ""
48#define DEFAULT_RDS_RADIO_TEXT DEFAULT_RDS_PS_NAME
49#define DEFAULT_RDS_DEVIATION 0x00C8
50#define DEFAULT_RDS_PS_REPEAT_COUNT 0x0003
51#define DEFAULT_LIMITER_RTIME 0x1392
52#define DEFAULT_LIMITER_DEV 0x102CA
53#define DEFAULT_PILOT_FREQUENCY 0x4A38
54#define DEFAULT_PILOT_DEVIATION 0x1A5E
55#define DEFAULT_ACOMP_ATIME 0x0000
56#define DEFAULT_ACOMP_RTIME 0xF4240L
57#define DEFAULT_ACOMP_GAIN 0x0F
58#define DEFAULT_ACOMP_THRESHOLD (-0x28)
59#define DEFAULT_MUTE 0x01
60#define DEFAULT_POWER_LEVEL 88
61#define DEFAULT_FREQUENCY 8800
62#define DEFAULT_PREEMPHASIS FMPE_EU
63#define DEFAULT_TUNE_RNL 0xFF
64
65#define to_si4713_device(sd) container_of(sd, struct si4713_device, sd)
66
67/* frequency domain transformation (using times 10 to avoid floats) */
68#define FREQDEV_UNIT 100000
69#define FREQV4L2_MULTI 625
70#define si4713_to_v4l2(f) ((f * FREQDEV_UNIT) / FREQV4L2_MULTI)
71#define v4l2_to_si4713(f) ((f * FREQV4L2_MULTI) / FREQDEV_UNIT)
72#define FREQ_RANGE_LOW 7600
73#define FREQ_RANGE_HIGH 10800
74
75#define MAX_ARGS 7
76
77#define RDS_BLOCK 8
78#define RDS_BLOCK_CLEAR 0x03
79#define RDS_BLOCK_LOAD 0x04
80#define RDS_RADIOTEXT_2A 0x20
81#define RDS_RADIOTEXT_BLK_SIZE 4
82#define RDS_RADIOTEXT_INDEX_MAX 0x0F
83#define RDS_CARRIAGE_RETURN 0x0D
84
85#define rds_ps_nblocks(len) ((len / RDS_BLOCK) + (len % RDS_BLOCK ? 1 : 0))
86
87#define get_status_bit(p, b, m) (((p) & (m)) >> (b))
88#define set_bits(p, v, b, m) (((p) & ~(m)) | ((v) << (b)))
89
90#define ATTACK_TIME_UNIT 500
91
92#define POWER_OFF 0x00
93#define POWER_ON 0x01
94
95#define msb(x) ((u8)((u16) x >> 8))
96#define lsb(x) ((u8)((u16) x & 0x00FF))
97#define compose_u16(msb, lsb) (((u16)msb << 8) | lsb)
98#define check_command_failed(status) (!(status & SI4713_CTS) || \
99 (status & SI4713_ERR))
100/* mute definition */
101#define set_mute(p) ((p & 1) | ((p & 1) << 1));
102#define get_mute(p) (p & 0x01)
103
104#ifdef DEBUG
105#define DBG_BUFFER(device, message, buffer, size) \
106 { \
107 int i; \
108 char str[(size)*5]; \
109 for (i = 0; i < size; i++) \
110 sprintf(str + i * 5, " 0x%02x", buffer[i]); \
111 v4l2_dbg(2, debug, device, "%s:%s\n", message, str); \
112 }
113#else
114#define DBG_BUFFER(device, message, buffer, size)
115#endif
116
117/*
118 * Values for limiter release time (sorted by second column)
119 * device release
120 * value time (us)
121 */
122static long limiter_times[] = {
123 2000, 250,
124 1000, 500,
125 510, 1000,
126 255, 2000,
127 170, 3000,
128 127, 4020,
129 102, 5010,
130 85, 6020,
131 73, 7010,
132 64, 7990,
133 57, 8970,
134 51, 10030,
135 25, 20470,
136 17, 30110,
137 13, 39380,
138 10, 51190,
139 8, 63690,
140 7, 73140,
141 6, 85330,
142 5, 102390,
143};
144
145/*
146 * Values for audio compression release time (sorted by second column)
147 * device release
148 * value time (us)
149 */
150static unsigned long acomp_rtimes[] = {
151 0, 100000,
152 1, 200000,
153 2, 350000,
154 3, 525000,
155 4, 1000000,
156};
157
158/*
159 * Values for preemphasis (sorted by second column)
160 * device preemphasis
161 * value value (v4l2)
162 */
163static unsigned long preemphasis_values[] = {
164 FMPE_DISABLED, V4L2_PREEMPHASIS_DISABLED,
165 FMPE_EU, V4L2_PREEMPHASIS_50_uS,
166 FMPE_USA, V4L2_PREEMPHASIS_75_uS,
167};
168
169static int usecs_to_dev(unsigned long usecs, unsigned long const array[],
170 int size)
171{
172 int i;
173 int rval = -EINVAL;
174
175 for (i = 0; i < size / 2; i++)
176 if (array[(i * 2) + 1] >= usecs) {
177 rval = array[i * 2];
178 break;
179 }
180
181 return rval;
182}
183
184static unsigned long dev_to_usecs(int value, unsigned long const array[],
185 int size)
186{
187 int i;
188 int rval = -EINVAL;
189
190 for (i = 0; i < size / 2; i++)
191 if (array[i * 2] == value) {
192 rval = array[(i * 2) + 1];
193 break;
194 }
195
196 return rval;
197}
198
199/* si4713_handler: IRQ handler, just complete work */
200static irqreturn_t si4713_handler(int irq, void *dev)
201{
202 struct si4713_device *sdev = dev;
203
204 v4l2_dbg(2, debug, &sdev->sd,
205 "%s: sending signal to completion work.\n", __func__);
206 complete(&sdev->work);
207
208 return IRQ_HANDLED;
209}
210
211/*
212 * si4713_send_command - sends a command to si4713 and waits its response
213 * @sdev: si4713_device structure for the device we are communicating
214 * @command: command id
215 * @args: command arguments we are sending (up to 7)
216 * @argn: actual size of @args
217 * @response: buffer to place the expected response from the device (up to 15)
218 * @respn: actual size of @response
219 * @usecs: amount of time to wait before reading the response (in usecs)
220 */
221static int si4713_send_command(struct si4713_device *sdev, const u8 command,
222 const u8 args[], const int argn,
223 u8 response[], const int respn, const int usecs)
224{
225 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
226 u8 data1[MAX_ARGS + 1];
227 int err;
228
229 if (!client->adapter)
230 return -ENODEV;
231
232 /* First send the command and its arguments */
233 data1[0] = command;
234 memcpy(data1 + 1, args, argn);
235 DBG_BUFFER(&sdev->sd, "Parameters", data1, argn + 1);
236
237 err = i2c_master_send(client, data1, argn + 1);
238 if (err != argn + 1) {
239 v4l2_err(&sdev->sd, "Error while sending command 0x%02x\n",
240 command);
241 return (err > 0) ? -EIO : err;
242 }
243
244 /* Wait response from interrupt */
245 if (!wait_for_completion_timeout(&sdev->work,
246 usecs_to_jiffies(usecs) + 1))
247 v4l2_warn(&sdev->sd,
248 "(%s) Device took too much time to answer.\n",
249 __func__);
250
251 /* Then get the response */
252 err = i2c_master_recv(client, response, respn);
253 if (err != respn) {
254 v4l2_err(&sdev->sd,
255 "Error while reading response for command 0x%02x\n",
256 command);
257 return (err > 0) ? -EIO : err;
258 }
259
260 DBG_BUFFER(&sdev->sd, "Response", response, respn);
261 if (check_command_failed(response[0]))
262 return -EBUSY;
263
264 return 0;
265}
266
267/*
268 * si4713_read_property - reads a si4713 property
269 * @sdev: si4713_device structure for the device we are communicating
270 * @prop: property identification number
271 * @pv: property value to be returned on success
272 */
273static int si4713_read_property(struct si4713_device *sdev, u16 prop, u32 *pv)
274{
275 int err;
276 u8 val[SI4713_GET_PROP_NRESP];
277 /*
278 * .First byte = 0
279 * .Second byte = property's MSB
280 * .Third byte = property's LSB
281 */
282 const u8 args[SI4713_GET_PROP_NARGS] = {
283 0x00,
284 msb(prop),
285 lsb(prop),
286 };
287
288 err = si4713_send_command(sdev, SI4713_CMD_GET_PROPERTY,
289 args, ARRAY_SIZE(args), val,
290 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
291
292 if (err < 0)
293 return err;
294
295 *pv = compose_u16(val[2], val[3]);
296
297 v4l2_dbg(1, debug, &sdev->sd,
298 "%s: property=0x%02x value=0x%02x status=0x%02x\n",
299 __func__, prop, *pv, val[0]);
300
301 return err;
302}
303
304/*
305 * si4713_write_property - modifies a si4713 property
306 * @sdev: si4713_device structure for the device we are communicating
307 * @prop: property identification number
308 * @val: new value for that property
309 */
310static int si4713_write_property(struct si4713_device *sdev, u16 prop, u16 val)
311{
312 int rval;
313 u8 resp[SI4713_SET_PROP_NRESP];
314 /*
315 * .First byte = 0
316 * .Second byte = property's MSB
317 * .Third byte = property's LSB
318 * .Fourth byte = value's MSB
319 * .Fifth byte = value's LSB
320 */
321 const u8 args[SI4713_SET_PROP_NARGS] = {
322 0x00,
323 msb(prop),
324 lsb(prop),
325 msb(val),
326 lsb(val),
327 };
328
329 rval = si4713_send_command(sdev, SI4713_CMD_SET_PROPERTY,
330 args, ARRAY_SIZE(args),
331 resp, ARRAY_SIZE(resp),
332 DEFAULT_TIMEOUT);
333
334 if (rval < 0)
335 return rval;
336
337 v4l2_dbg(1, debug, &sdev->sd,
338 "%s: property=0x%02x value=0x%02x status=0x%02x\n",
339 __func__, prop, val, resp[0]);
340
341 /*
342 * As there is no command response for SET_PROPERTY,
343 * wait Tcomp time to finish before proceed, in order
344 * to have property properly set.
345 */
346 msleep(TIMEOUT_SET_PROPERTY);
347
348 return rval;
349}
350
351/*
352 * si4713_powerup - Powers the device up
353 * @sdev: si4713_device structure for the device we are communicating
354 */
355static int si4713_powerup(struct si4713_device *sdev)
356{
357 int err;
358 u8 resp[SI4713_PWUP_NRESP];
359 /*
360 * .First byte = Enabled interrupts and boot function
361 * .Second byte = Input operation mode
362 */
363 const u8 args[SI4713_PWUP_NARGS] = {
364 SI4713_PWUP_CTSIEN | SI4713_PWUP_GPO2OEN | SI4713_PWUP_FUNC_TX,
365 SI4713_PWUP_OPMOD_ANALOG,
366 };
367
368 if (sdev->power_state)
369 return 0;
370
371 sdev->platform_data->set_power(1);
372 err = si4713_send_command(sdev, SI4713_CMD_POWER_UP,
373 args, ARRAY_SIZE(args),
374 resp, ARRAY_SIZE(resp),
375 TIMEOUT_POWER_UP);
376
377 if (!err) {
378 v4l2_dbg(1, debug, &sdev->sd, "Powerup response: 0x%02x\n",
379 resp[0]);
380 v4l2_dbg(1, debug, &sdev->sd, "Device in power up mode\n");
381 sdev->power_state = POWER_ON;
382
383 err = si4713_write_property(sdev, SI4713_GPO_IEN,
384 SI4713_STC_INT | SI4713_CTS);
385 } else {
386 sdev->platform_data->set_power(0);
387 }
388
389 return err;
390}
391
392/*
393 * si4713_powerdown - Powers the device down
394 * @sdev: si4713_device structure for the device we are communicating
395 */
396static int si4713_powerdown(struct si4713_device *sdev)
397{
398 int err;
399 u8 resp[SI4713_PWDN_NRESP];
400
401 if (!sdev->power_state)
402 return 0;
403
404 err = si4713_send_command(sdev, SI4713_CMD_POWER_DOWN,
405 NULL, 0,
406 resp, ARRAY_SIZE(resp),
407 DEFAULT_TIMEOUT);
408
409 if (!err) {
410 v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n",
411 resp[0]);
412 v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n");
413 sdev->platform_data->set_power(0);
414 sdev->power_state = POWER_OFF;
415 }
416
417 return err;
418}
419
420/*
421 * si4713_checkrev - Checks if we are treating a device with the correct rev.
422 * @sdev: si4713_device structure for the device we are communicating
423 */
424static int si4713_checkrev(struct si4713_device *sdev)
425{
426 struct i2c_client *client = v4l2_get_subdevdata(&sdev->sd);
427 int rval;
428 u8 resp[SI4713_GETREV_NRESP];
429
430 mutex_lock(&sdev->mutex);
431
432 rval = si4713_send_command(sdev, SI4713_CMD_GET_REV,
433 NULL, 0,
434 resp, ARRAY_SIZE(resp),
435 DEFAULT_TIMEOUT);
436
437 if (rval < 0)
438 goto unlock;
439
440 if (resp[1] == SI4713_PRODUCT_NUMBER) {
441 v4l2_info(&sdev->sd, "chip found @ 0x%02x (%s)\n",
442 client->addr << 1, client->adapter->name);
443 } else {
444 v4l2_err(&sdev->sd, "Invalid product number\n");
445 rval = -EINVAL;
446 }
447
448unlock:
449 mutex_unlock(&sdev->mutex);
450 return rval;
451}
452
453/*
454 * si4713_wait_stc - Waits STC interrupt and clears status bits. Usefull
455 * for TX_TUNE_POWER, TX_TUNE_FREQ and TX_TUNE_MEAS
456 * @sdev: si4713_device structure for the device we are communicating
457 * @usecs: timeout to wait for STC interrupt signal
458 */
459static int si4713_wait_stc(struct si4713_device *sdev, const int usecs)
460{
461 int err;
462 u8 resp[SI4713_GET_STATUS_NRESP];
463
464 /* Wait response from STC interrupt */
465 if (!wait_for_completion_timeout(&sdev->work,
466 usecs_to_jiffies(usecs) + 1))
467 v4l2_warn(&sdev->sd,
468 "%s: device took too much time to answer (%d usec).\n",
469 __func__, usecs);
470
471 /* Clear status bits */
472 err = si4713_send_command(sdev, SI4713_CMD_GET_INT_STATUS,
473 NULL, 0,
474 resp, ARRAY_SIZE(resp),
475 DEFAULT_TIMEOUT);
476
477 if (err < 0)
478 goto exit;
479
480 v4l2_dbg(1, debug, &sdev->sd,
481 "%s: status bits: 0x%02x\n", __func__, resp[0]);
482
483 if (!(resp[0] & SI4713_STC_INT))
484 err = -EIO;
485
486exit:
487 return err;
488}
489
490/*
491 * si4713_tx_tune_freq - Sets the state of the RF carrier and sets the tuning
492 * frequency between 76 and 108 MHz in 10 kHz units and
493 * steps of 50 kHz.
494 * @sdev: si4713_device structure for the device we are communicating
495 * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
496 */
497static int si4713_tx_tune_freq(struct si4713_device *sdev, u16 frequency)
498{
499 int err;
500 u8 val[SI4713_TXFREQ_NRESP];
501 /*
502 * .First byte = 0
503 * .Second byte = frequency's MSB
504 * .Third byte = frequency's LSB
505 */
506 const u8 args[SI4713_TXFREQ_NARGS] = {
507 0x00,
508 msb(frequency),
509 lsb(frequency),
510 };
511
512 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_FREQ,
513 args, ARRAY_SIZE(args), val,
514 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
515
516 if (err < 0)
517 return err;
518
519 v4l2_dbg(1, debug, &sdev->sd,
520 "%s: frequency=0x%02x status=0x%02x\n", __func__,
521 frequency, val[0]);
522
523 err = si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
524 if (err < 0)
525 return err;
526
527 return compose_u16(args[1], args[2]);
528}
529
530/*
531 * si4713_tx_tune_power - Sets the RF voltage level between 88 and 115 dBuV in
532 * 1 dB units. A value of 0x00 indicates off. The command
533 * also sets the antenna tuning capacitance. A value of 0
534 * indicates autotuning, and a value of 1 - 191 indicates
535 * a manual override, which results in a tuning
536 * capacitance of 0.25 pF x @antcap.
537 * @sdev: si4713_device structure for the device we are communicating
538 * @power: tuning power (88 - 115 dBuV, unit/step 1 dB)
539 * @antcap: value of antenna tuning capacitor (0 - 191)
540 */
541static int si4713_tx_tune_power(struct si4713_device *sdev, u8 power,
542 u8 antcap)
543{
544 int err;
545 u8 val[SI4713_TXPWR_NRESP];
546 /*
547 * .First byte = 0
548 * .Second byte = 0
549 * .Third byte = power
550 * .Fourth byte = antcap
551 */
552 const u8 args[SI4713_TXPWR_NARGS] = {
553 0x00,
554 0x00,
555 power,
556 antcap,
557 };
558
559 if (((power > 0) && (power < SI4713_MIN_POWER)) ||
560 power > SI4713_MAX_POWER || antcap > SI4713_MAX_ANTCAP)
561 return -EDOM;
562
563 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_POWER,
564 args, ARRAY_SIZE(args), val,
565 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
566
567 if (err < 0)
568 return err;
569
570 v4l2_dbg(1, debug, &sdev->sd,
571 "%s: power=0x%02x antcap=0x%02x status=0x%02x\n",
572 __func__, power, antcap, val[0]);
573
574 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE_POWER);
575}
576
577/*
578 * si4713_tx_tune_measure - Enters receive mode and measures the received noise
579 * level in units of dBuV on the selected frequency.
580 * The Frequency must be between 76 and 108 MHz in 10 kHz
581 * units and steps of 50 kHz. The command also sets the
582 * antenna tuning capacitance. A value of 0 means
583 * autotuning, and a value of 1 to 191 indicates manual
584 * override.
585 * @sdev: si4713_device structure for the device we are communicating
586 * @frequency: desired frequency (76 - 108 MHz, unit 10 KHz, step 50 kHz)
587 * @antcap: value of antenna tuning capacitor (0 - 191)
588 */
589static int si4713_tx_tune_measure(struct si4713_device *sdev, u16 frequency,
590 u8 antcap)
591{
592 int err;
593 u8 val[SI4713_TXMEA_NRESP];
594 /*
595 * .First byte = 0
596 * .Second byte = frequency's MSB
597 * .Third byte = frequency's LSB
598 * .Fourth byte = antcap
599 */
600 const u8 args[SI4713_TXMEA_NARGS] = {
601 0x00,
602 msb(frequency),
603 lsb(frequency),
604 antcap,
605 };
606
607 sdev->tune_rnl = DEFAULT_TUNE_RNL;
608
609 if (antcap > SI4713_MAX_ANTCAP)
610 return -EDOM;
611
612 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_MEASURE,
613 args, ARRAY_SIZE(args), val,
614 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
615
616 if (err < 0)
617 return err;
618
619 v4l2_dbg(1, debug, &sdev->sd,
620 "%s: frequency=0x%02x antcap=0x%02x status=0x%02x\n",
621 __func__, frequency, antcap, val[0]);
622
623 return si4713_wait_stc(sdev, TIMEOUT_TX_TUNE);
624}
625
626/*
627 * si4713_tx_tune_status- Returns the status of the tx_tune_freq, tx_tune_mea or
628 * tx_tune_power commands. This command return the current
629 * frequency, output voltage in dBuV, the antenna tunning
630 * capacitance value and the received noise level. The
631 * command also clears the stcint interrupt bit when the
632 * first bit of its arguments is high.
633 * @sdev: si4713_device structure for the device we are communicating
634 * @intack: 0x01 to clear the seek/tune complete interrupt status indicator.
635 * @frequency: returned frequency
636 * @power: returned power
637 * @antcap: returned antenna capacitance
638 * @noise: returned noise level
639 */
640static int si4713_tx_tune_status(struct si4713_device *sdev, u8 intack,
641 u16 *frequency, u8 *power,
642 u8 *antcap, u8 *noise)
643{
644 int err;
645 u8 val[SI4713_TXSTATUS_NRESP];
646 /*
647 * .First byte = intack bit
648 */
649 const u8 args[SI4713_TXSTATUS_NARGS] = {
650 intack & SI4713_INTACK_MASK,
651 };
652
653 err = si4713_send_command(sdev, SI4713_CMD_TX_TUNE_STATUS,
654 args, ARRAY_SIZE(args), val,
655 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
656
657 if (!err) {
658 v4l2_dbg(1, debug, &sdev->sd,
659 "%s: status=0x%02x\n", __func__, val[0]);
660 *frequency = compose_u16(val[2], val[3]);
661 sdev->frequency = *frequency;
662 *power = val[5];
663 *antcap = val[6];
664 *noise = val[7];
665 v4l2_dbg(1, debug, &sdev->sd, "%s: response: %d x 10 kHz "
666 "(power %d, antcap %d, rnl %d)\n", __func__,
667 *frequency, *power, *antcap, *noise);
668 }
669
670 return err;
671}
672
673/*
674 * si4713_tx_rds_buff - Loads the RDS group buffer FIFO or circular buffer.
675 * @sdev: si4713_device structure for the device we are communicating
676 * @mode: the buffer operation mode.
677 * @rdsb: RDS Block B
678 * @rdsc: RDS Block C
679 * @rdsd: RDS Block D
680 * @cbleft: returns the number of available circular buffer blocks minus the
681 * number of used circular buffer blocks.
682 */
683static int si4713_tx_rds_buff(struct si4713_device *sdev, u8 mode, u16 rdsb,
684 u16 rdsc, u16 rdsd, s8 *cbleft)
685{
686 int err;
687 u8 val[SI4713_RDSBUFF_NRESP];
688
689 const u8 args[SI4713_RDSBUFF_NARGS] = {
690 mode & SI4713_RDSBUFF_MODE_MASK,
691 msb(rdsb),
692 lsb(rdsb),
693 msb(rdsc),
694 lsb(rdsc),
695 msb(rdsd),
696 lsb(rdsd),
697 };
698
699 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_BUFF,
700 args, ARRAY_SIZE(args), val,
701 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
702
703 if (!err) {
704 v4l2_dbg(1, debug, &sdev->sd,
705 "%s: status=0x%02x\n", __func__, val[0]);
706 *cbleft = (s8)val[2] - val[3];
707 v4l2_dbg(1, debug, &sdev->sd, "%s: response: interrupts"
708 " 0x%02x cb avail: %d cb used %d fifo avail"
709 " %d fifo used %d\n", __func__, val[1],
710 val[2], val[3], val[4], val[5]);
711 }
712
713 return err;
714}
715
716/*
717 * si4713_tx_rds_ps - Loads the program service buffer.
718 * @sdev: si4713_device structure for the device we are communicating
719 * @psid: program service id to be loaded.
720 * @pschar: assumed 4 size char array to be loaded into the program service
721 */
722static int si4713_tx_rds_ps(struct si4713_device *sdev, u8 psid,
723 unsigned char *pschar)
724{
725 int err;
726 u8 val[SI4713_RDSPS_NRESP];
727
728 const u8 args[SI4713_RDSPS_NARGS] = {
729 psid & SI4713_RDSPS_PSID_MASK,
730 pschar[0],
731 pschar[1],
732 pschar[2],
733 pschar[3],
734 };
735
736 err = si4713_send_command(sdev, SI4713_CMD_TX_RDS_PS,
737 args, ARRAY_SIZE(args), val,
738 ARRAY_SIZE(val), DEFAULT_TIMEOUT);
739
740 if (err < 0)
741 return err;
742
743 v4l2_dbg(1, debug, &sdev->sd, "%s: status=0x%02x\n", __func__, val[0]);
744
745 return err;
746}
747
748static int si4713_set_power_state(struct si4713_device *sdev, u8 value)
749{
750 int rval;
751
752 mutex_lock(&sdev->mutex);
753
754 if (value)
755 rval = si4713_powerup(sdev);
756 else
757 rval = si4713_powerdown(sdev);
758
759 mutex_unlock(&sdev->mutex);
760 return rval;
761}
762
763static int si4713_set_mute(struct si4713_device *sdev, u16 mute)
764{
765 int rval = 0;
766
767 mute = set_mute(mute);
768
769 mutex_lock(&sdev->mutex);
770
771 if (sdev->power_state)
772 rval = si4713_write_property(sdev,
773 SI4713_TX_LINE_INPUT_MUTE, mute);
774
775 if (rval >= 0)
776 sdev->mute = get_mute(mute);
777
778 mutex_unlock(&sdev->mutex);
779
780 return rval;
781}
782
783static int si4713_set_rds_ps_name(struct si4713_device *sdev, char *ps_name)
784{
785 int rval = 0, i;
786 u8 len = 0;
787
788 /* We want to clear the whole thing */
789 if (!strlen(ps_name))
790 memset(ps_name, 0, MAX_RDS_PS_NAME + 1);
791
792 mutex_lock(&sdev->mutex);
793
794 if (sdev->power_state) {
795 /* Write the new ps name and clear the padding */
796 for (i = 0; i < MAX_RDS_PS_NAME; i += (RDS_BLOCK / 2)) {
797 rval = si4713_tx_rds_ps(sdev, (i / (RDS_BLOCK / 2)),
798 ps_name + i);
799 if (rval < 0)
800 goto unlock;
801 }
802
803 /* Setup the size to be sent */
804 if (strlen(ps_name))
805 len = strlen(ps_name) - 1;
806 else
807 len = 1;
808
809 rval = si4713_write_property(sdev,
810 SI4713_TX_RDS_PS_MESSAGE_COUNT,
811 rds_ps_nblocks(len));
812 if (rval < 0)
813 goto unlock;
814
815 rval = si4713_write_property(sdev,
816 SI4713_TX_RDS_PS_REPEAT_COUNT,
817 DEFAULT_RDS_PS_REPEAT_COUNT * 2);
818 if (rval < 0)
819 goto unlock;
820 }
821
822 strncpy(sdev->rds_info.ps_name, ps_name, MAX_RDS_PS_NAME);
823
824unlock:
825 mutex_unlock(&sdev->mutex);
826 return rval;
827}
828
829static int si4713_set_rds_radio_text(struct si4713_device *sdev, char *rt)
830{
831 int rval = 0, i;
832 u16 t_index = 0;
833 u8 b_index = 0, cr_inserted = 0;
834 s8 left;
835
836 mutex_lock(&sdev->mutex);
837
838 if (!sdev->power_state)
839 goto copy;
840
841 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_CLEAR, 0, 0, 0, &left);
842 if (rval < 0)
843 goto unlock;
844
845 if (!strlen(rt))
846 goto copy;
847
848 do {
849 /* RDS spec says that if the last block isn't used,
850 * then apply a carriage return
851 */
852 if (t_index < (RDS_RADIOTEXT_INDEX_MAX *
853 RDS_RADIOTEXT_BLK_SIZE)) {
854 for (i = 0; i < RDS_RADIOTEXT_BLK_SIZE; i++) {
855 if (!rt[t_index + i] || rt[t_index + i] ==
856 RDS_CARRIAGE_RETURN) {
857 rt[t_index + i] = RDS_CARRIAGE_RETURN;
858 cr_inserted = 1;
859 break;
860 }
861 }
862 }
863
864 rval = si4713_tx_rds_buff(sdev, RDS_BLOCK_LOAD,
865 compose_u16(RDS_RADIOTEXT_2A, b_index++),
866 compose_u16(rt[t_index], rt[t_index + 1]),
867 compose_u16(rt[t_index + 2], rt[t_index + 3]),
868 &left);
869 if (rval < 0)
870 goto unlock;
871
872 t_index += RDS_RADIOTEXT_BLK_SIZE;
873
874 if (cr_inserted)
875 break;
876 } while (left > 0);
877
878copy:
879 strncpy(sdev->rds_info.radio_text, rt, MAX_RDS_RADIO_TEXT);
880
881unlock:
882 mutex_unlock(&sdev->mutex);
883 return rval;
884}
885
886static int si4713_choose_econtrol_action(struct si4713_device *sdev, u32 id,
887 u32 **shadow, s32 *bit, s32 *mask, u16 *property, int *mul,
888 unsigned long **table, int *size)
889{
890 s32 rval = 0;
891
892 switch (id) {
893 /* FM_TX class controls */
894 case V4L2_CID_RDS_TX_PI:
895 *property = SI4713_TX_RDS_PI;
896 *mul = 1;
897 *shadow = &sdev->rds_info.pi;
898 break;
899 case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD:
900 *property = SI4713_TX_ACOMP_THRESHOLD;
901 *mul = 1;
902 *shadow = &sdev->acomp_info.threshold;
903 break;
904 case V4L2_CID_AUDIO_COMPRESSION_GAIN:
905 *property = SI4713_TX_ACOMP_GAIN;
906 *mul = 1;
907 *shadow = &sdev->acomp_info.gain;
908 break;
909 case V4L2_CID_PILOT_TONE_FREQUENCY:
910 *property = SI4713_TX_PILOT_FREQUENCY;
911 *mul = 1;
912 *shadow = &sdev->pilot_info.frequency;
913 break;
914 case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME:
915 *property = SI4713_TX_ACOMP_ATTACK_TIME;
916 *mul = ATTACK_TIME_UNIT;
917 *shadow = &sdev->acomp_info.attack_time;
918 break;
919 case V4L2_CID_PILOT_TONE_DEVIATION:
920 *property = SI4713_TX_PILOT_DEVIATION;
921 *mul = 10;
922 *shadow = &sdev->pilot_info.deviation;
923 break;
924 case V4L2_CID_AUDIO_LIMITER_DEVIATION:
925 *property = SI4713_TX_AUDIO_DEVIATION;
926 *mul = 10;
927 *shadow = &sdev->limiter_info.deviation;
928 break;
929 case V4L2_CID_RDS_TX_DEVIATION:
930 *property = SI4713_TX_RDS_DEVIATION;
931 *mul = 1;
932 *shadow = &sdev->rds_info.deviation;
933 break;
934
935 case V4L2_CID_RDS_TX_PTY:
936 *property = SI4713_TX_RDS_PS_MISC;
937 *bit = 5;
938 *mask = 0x1F << 5;
939 *shadow = &sdev->rds_info.pty;
940 break;
941 case V4L2_CID_AUDIO_LIMITER_ENABLED:
942 *property = SI4713_TX_ACOMP_ENABLE;
943 *bit = 1;
944 *mask = 1 << 1;
945 *shadow = &sdev->limiter_info.enabled;
946 break;
947 case V4L2_CID_AUDIO_COMPRESSION_ENABLED:
948 *property = SI4713_TX_ACOMP_ENABLE;
949 *bit = 0;
950 *mask = 1 << 0;
951 *shadow = &sdev->acomp_info.enabled;
952 break;
953 case V4L2_CID_PILOT_TONE_ENABLED:
954 *property = SI4713_TX_COMPONENT_ENABLE;
955 *bit = 0;
956 *mask = 1 << 0;
957 *shadow = &sdev->pilot_info.enabled;
958 break;
959
960 case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME:
961 *property = SI4713_TX_LIMITER_RELEASE_TIME;
962 *table = limiter_times;
963 *size = ARRAY_SIZE(limiter_times);
964 *shadow = &sdev->limiter_info.release_time;
965 break;
966 case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME:
967 *property = SI4713_TX_ACOMP_RELEASE_TIME;
968 *table = acomp_rtimes;
969 *size = ARRAY_SIZE(acomp_rtimes);
970 *shadow = &sdev->acomp_info.release_time;
971 break;
972 case V4L2_CID_TUNE_PREEMPHASIS:
973 *property = SI4713_TX_PREEMPHASIS;
974 *table = preemphasis_values;
975 *size = ARRAY_SIZE(preemphasis_values);
976 *shadow = &sdev->preemphasis;
977 break;
978
979 default:
980 rval = -EINVAL;
981 };
982
983 return rval;
984}
985
986static int si4713_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc);
987
988/* write string property */
989static int si4713_write_econtrol_string(struct si4713_device *sdev,
990 struct v4l2_ext_control *control)
991{
992 struct v4l2_queryctrl vqc;
993 int len;
994 s32 rval = 0;
995
996 vqc.id = control->id;
997 rval = si4713_queryctrl(&sdev->sd, &vqc);
998 if (rval < 0)
999 goto exit;
1000
1001 switch (control->id) {
1002 case V4L2_CID_RDS_TX_PS_NAME: {
1003 char ps_name[MAX_RDS_PS_NAME + 1];
1004
1005 len = control->size - 1;
1006 if (len > MAX_RDS_PS_NAME) {
1007 rval = -ERANGE;
1008 goto exit;
1009 }
1010 rval = copy_from_user(ps_name, control->string, len);
1011 if (rval < 0)
1012 goto exit;
1013 ps_name[len] = '\0';
1014
1015 if (strlen(ps_name) % vqc.step) {
1016 rval = -ERANGE;
1017 goto exit;
1018 }
1019
1020 rval = si4713_set_rds_ps_name(sdev, ps_name);
1021 }
1022 break;
1023
1024 case V4L2_CID_RDS_TX_RADIO_TEXT: {
1025 char radio_text[MAX_RDS_RADIO_TEXT + 1];
1026
1027 len = control->size - 1;
1028 if (len > MAX_RDS_RADIO_TEXT) {
1029 rval = -ERANGE;
1030 goto exit;
1031 }
1032 rval = copy_from_user(radio_text, control->string, len);
1033 if (rval < 0)
1034 goto exit;
1035 radio_text[len] = '\0';
1036
1037 if (strlen(radio_text) % vqc.step) {
1038 rval = -ERANGE;
1039 goto exit;
1040 }
1041
1042 rval = si4713_set_rds_radio_text(sdev, radio_text);
1043 }
1044 break;
1045
1046 default:
1047 rval = -EINVAL;
1048 break;
1049 };
1050
1051exit:
1052 return rval;
1053}
1054
1055static int validate_range(struct v4l2_subdev *sd,
1056 struct v4l2_ext_control *control)
1057{
1058 struct v4l2_queryctrl vqc;
1059 int rval;
1060
1061 vqc.id = control->id;
1062 rval = si4713_queryctrl(sd, &vqc);
1063 if (rval < 0)
1064 goto exit;
1065
1066 if (control->value < vqc.minimum || control->value > vqc.maximum)
1067 rval = -ERANGE;
1068
1069exit:
1070 return rval;
1071}
1072
1073/* properties which use tx_tune_power*/
1074static int si4713_write_econtrol_tune(struct si4713_device *sdev,
1075 struct v4l2_ext_control *control)
1076{
1077 s32 rval = 0;
1078 u8 power, antcap;
1079
1080 rval = validate_range(&sdev->sd, control);
1081 if (rval < 0)
1082 goto exit;
1083
1084 mutex_lock(&sdev->mutex);
1085
1086 switch (control->id) {
1087 case V4L2_CID_TUNE_POWER_LEVEL:
1088 power = control->value;
1089 antcap = sdev->antenna_capacitor;
1090 break;
1091 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
1092 power = sdev->power_level;
1093 antcap = control->value;
1094 break;
1095 default:
1096 rval = -EINVAL;
1097 goto unlock;
1098 };
1099
1100 if (sdev->power_state)
1101 rval = si4713_tx_tune_power(sdev, power, antcap);
1102
1103 if (rval == 0) {
1104 sdev->power_level = power;
1105 sdev->antenna_capacitor = antcap;
1106 }
1107
1108unlock:
1109 mutex_unlock(&sdev->mutex);
1110exit:
1111 return rval;
1112}
1113
1114static int si4713_write_econtrol_integers(struct si4713_device *sdev,
1115 struct v4l2_ext_control *control)
1116{
1117 s32 rval;
1118 u32 *shadow = NULL, val = 0;
1119 s32 bit = 0, mask = 0;
1120 u16 property = 0;
1121 int mul = 0;
1122 unsigned long *table = NULL;
1123 int size = 0;
1124
1125 rval = validate_range(&sdev->sd, control);
1126 if (rval < 0)
1127 goto exit;
1128
1129 rval = si4713_choose_econtrol_action(sdev, control->id, &shadow, &bit,
1130 &mask, &property, &mul, &table, &size);
1131 if (rval < 0)
1132 goto exit;
1133
1134 val = control->value;
1135 if (mul) {
1136 val = control->value / mul;
1137 } else if (table) {
1138 rval = usecs_to_dev(control->value, table, size);
1139 if (rval < 0)
1140 goto exit;
1141 val = rval;
1142 rval = 0;
1143 }
1144
1145 mutex_lock(&sdev->mutex);
1146
1147 if (sdev->power_state) {
1148 if (mask) {
1149 rval = si4713_read_property(sdev, property, &val);
1150 if (rval < 0)
1151 goto unlock;
1152 val = set_bits(val, control->value, bit, mask);
1153 }
1154
1155 rval = si4713_write_property(sdev, property, val);
1156 if (rval < 0)
1157 goto unlock;
1158 if (mask)
1159 val = control->value;
1160 }
1161
1162 if (mul) {
1163 *shadow = val * mul;
1164 } else if (table) {
1165 rval = dev_to_usecs(val, table, size);
1166 if (rval < 0)
1167 goto unlock;
1168 *shadow = rval;
1169 rval = 0;
1170 } else {
1171 *shadow = val;
1172 }
1173
1174unlock:
1175 mutex_unlock(&sdev->mutex);
1176exit:
1177 return rval;
1178}
1179
1180static int si4713_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f);
1181static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *);
1182/*
1183 * si4713_setup - Sets the device up with current configuration.
1184 * @sdev: si4713_device structure for the device we are communicating
1185 */
1186static int si4713_setup(struct si4713_device *sdev)
1187{
1188 struct v4l2_ext_control ctrl;
1189 struct v4l2_frequency f;
1190 struct v4l2_modulator vm;
1191 struct si4713_device *tmp;
1192 int rval = 0;
1193
1194 tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
1195 if (!tmp)
1196 return -ENOMEM;
1197
1198 /* Get a local copy to avoid race */
1199 mutex_lock(&sdev->mutex);
1200 memcpy(tmp, sdev, sizeof(*sdev));
1201 mutex_unlock(&sdev->mutex);
1202
1203 ctrl.id = V4L2_CID_RDS_TX_PI;
1204 ctrl.value = tmp->rds_info.pi;
1205 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1206
1207 ctrl.id = V4L2_CID_AUDIO_COMPRESSION_THRESHOLD;
1208 ctrl.value = tmp->acomp_info.threshold;
1209 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1210
1211 ctrl.id = V4L2_CID_AUDIO_COMPRESSION_GAIN;
1212 ctrl.value = tmp->acomp_info.gain;
1213 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1214
1215 ctrl.id = V4L2_CID_PILOT_TONE_FREQUENCY;
1216 ctrl.value = tmp->pilot_info.frequency;
1217 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1218
1219 ctrl.id = V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME;
1220 ctrl.value = tmp->acomp_info.attack_time;
1221 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1222
1223 ctrl.id = V4L2_CID_PILOT_TONE_DEVIATION;
1224 ctrl.value = tmp->pilot_info.deviation;
1225 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1226
1227 ctrl.id = V4L2_CID_AUDIO_LIMITER_DEVIATION;
1228 ctrl.value = tmp->limiter_info.deviation;
1229 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1230
1231 ctrl.id = V4L2_CID_RDS_TX_DEVIATION;
1232 ctrl.value = tmp->rds_info.deviation;
1233 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1234
1235 ctrl.id = V4L2_CID_RDS_TX_PTY;
1236 ctrl.value = tmp->rds_info.pty;
1237 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1238
1239 ctrl.id = V4L2_CID_AUDIO_LIMITER_ENABLED;
1240 ctrl.value = tmp->limiter_info.enabled;
1241 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1242
1243 ctrl.id = V4L2_CID_AUDIO_COMPRESSION_ENABLED;
1244 ctrl.value = tmp->acomp_info.enabled;
1245 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1246
1247 ctrl.id = V4L2_CID_PILOT_TONE_ENABLED;
1248 ctrl.value = tmp->pilot_info.enabled;
1249 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1250
1251 ctrl.id = V4L2_CID_AUDIO_LIMITER_RELEASE_TIME;
1252 ctrl.value = tmp->limiter_info.release_time;
1253 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1254
1255 ctrl.id = V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME;
1256 ctrl.value = tmp->acomp_info.release_time;
1257 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1258
1259 ctrl.id = V4L2_CID_TUNE_PREEMPHASIS;
1260 ctrl.value = tmp->preemphasis;
1261 rval |= si4713_write_econtrol_integers(sdev, &ctrl);
1262
1263 ctrl.id = V4L2_CID_RDS_TX_PS_NAME;
1264 rval |= si4713_set_rds_ps_name(sdev, tmp->rds_info.ps_name);
1265
1266 ctrl.id = V4L2_CID_RDS_TX_RADIO_TEXT;
1267 rval |= si4713_set_rds_radio_text(sdev, tmp->rds_info.radio_text);
1268
1269 /* Device procedure needs to set frequency first */
1270 f.frequency = tmp->frequency ? tmp->frequency : DEFAULT_FREQUENCY;
1271 f.frequency = si4713_to_v4l2(f.frequency);
1272 rval |= si4713_s_frequency(&sdev->sd, &f);
1273
1274 ctrl.id = V4L2_CID_TUNE_POWER_LEVEL;
1275 ctrl.value = tmp->power_level;
1276 rval |= si4713_write_econtrol_tune(sdev, &ctrl);
1277
1278 ctrl.id = V4L2_CID_TUNE_ANTENNA_CAPACITOR;
1279 ctrl.value = tmp->antenna_capacitor;
1280 rval |= si4713_write_econtrol_tune(sdev, &ctrl);
1281
1282 vm.index = 0;
1283 if (tmp->stereo)
1284 vm.txsubchans = V4L2_TUNER_SUB_STEREO;
1285 else
1286 vm.txsubchans = V4L2_TUNER_SUB_MONO;
1287 if (tmp->rds_info.enabled)
1288 vm.txsubchans |= V4L2_TUNER_SUB_RDS;
1289 si4713_s_modulator(&sdev->sd, &vm);
1290
1291 kfree(tmp);
1292
1293 return rval;
1294}
1295
1296/*
1297 * si4713_initialize - Sets the device up with default configuration.
1298 * @sdev: si4713_device structure for the device we are communicating
1299 */
1300static int si4713_initialize(struct si4713_device *sdev)
1301{
1302 int rval;
1303
1304 rval = si4713_set_power_state(sdev, POWER_ON);
1305 if (rval < 0)
1306 goto exit;
1307
1308 rval = si4713_checkrev(sdev);
1309 if (rval < 0)
1310 goto exit;
1311
1312 rval = si4713_set_power_state(sdev, POWER_OFF);
1313 if (rval < 0)
1314 goto exit;
1315
1316 mutex_lock(&sdev->mutex);
1317
1318 sdev->rds_info.pi = DEFAULT_RDS_PI;
1319 sdev->rds_info.pty = DEFAULT_RDS_PTY;
1320 sdev->rds_info.deviation = DEFAULT_RDS_DEVIATION;
1321 strlcpy(sdev->rds_info.ps_name, DEFAULT_RDS_PS_NAME, MAX_RDS_PS_NAME);
1322 strlcpy(sdev->rds_info.radio_text, DEFAULT_RDS_RADIO_TEXT,
1323 MAX_RDS_RADIO_TEXT);
1324 sdev->rds_info.enabled = 1;
1325
1326 sdev->limiter_info.release_time = DEFAULT_LIMITER_RTIME;
1327 sdev->limiter_info.deviation = DEFAULT_LIMITER_DEV;
1328 sdev->limiter_info.enabled = 1;
1329
1330 sdev->pilot_info.deviation = DEFAULT_PILOT_DEVIATION;
1331 sdev->pilot_info.frequency = DEFAULT_PILOT_FREQUENCY;
1332 sdev->pilot_info.enabled = 1;
1333
1334 sdev->acomp_info.release_time = DEFAULT_ACOMP_RTIME;
1335 sdev->acomp_info.attack_time = DEFAULT_ACOMP_ATIME;
1336 sdev->acomp_info.threshold = DEFAULT_ACOMP_THRESHOLD;
1337 sdev->acomp_info.gain = DEFAULT_ACOMP_GAIN;
1338 sdev->acomp_info.enabled = 1;
1339
1340 sdev->frequency = DEFAULT_FREQUENCY;
1341 sdev->preemphasis = DEFAULT_PREEMPHASIS;
1342 sdev->mute = DEFAULT_MUTE;
1343 sdev->power_level = DEFAULT_POWER_LEVEL;
1344 sdev->antenna_capacitor = 0;
1345 sdev->stereo = 1;
1346 sdev->tune_rnl = DEFAULT_TUNE_RNL;
1347
1348 mutex_unlock(&sdev->mutex);
1349
1350exit:
1351 return rval;
1352}
1353
1354/* read string property */
1355static int si4713_read_econtrol_string(struct si4713_device *sdev,
1356 struct v4l2_ext_control *control)
1357{
1358 s32 rval = 0;
1359
1360 switch (control->id) {
1361 case V4L2_CID_RDS_TX_PS_NAME:
1362 if (strlen(sdev->rds_info.ps_name) + 1 > control->size) {
1363 control->size = MAX_RDS_PS_NAME + 1;
1364 rval = -ENOSPC;
1365 goto exit;
1366 }
1367 rval = copy_to_user(control->string, sdev->rds_info.ps_name,
1368 strlen(sdev->rds_info.ps_name) + 1);
1369 break;
1370
1371 case V4L2_CID_RDS_TX_RADIO_TEXT:
1372 if (strlen(sdev->rds_info.radio_text) + 1 > control->size) {
1373 control->size = MAX_RDS_RADIO_TEXT + 1;
1374 rval = -ENOSPC;
1375 goto exit;
1376 }
1377 rval = copy_to_user(control->string, sdev->rds_info.radio_text,
1378 strlen(sdev->rds_info.radio_text) + 1);
1379 break;
1380
1381 default:
1382 rval = -EINVAL;
1383 break;
1384 };
1385
1386exit:
1387 return rval;
1388}
1389
1390/*
1391 * si4713_update_tune_status - update properties from tx_tune_status
1392 * command. Must be called with sdev->mutex held.
1393 * @sdev: si4713_device structure for the device we are communicating
1394 */
1395static int si4713_update_tune_status(struct si4713_device *sdev)
1396{
1397 int rval;
1398 u16 f = 0;
1399 u8 p = 0, a = 0, n = 0;
1400
1401 rval = si4713_tx_tune_status(sdev, 0x00, &f, &p, &a, &n);
1402
1403 if (rval < 0)
1404 goto exit;
1405
1406 sdev->power_level = p;
1407 sdev->antenna_capacitor = a;
1408 sdev->tune_rnl = n;
1409
1410exit:
1411 return rval;
1412}
1413
1414/* properties which use tx_tune_status */
1415static int si4713_read_econtrol_tune(struct si4713_device *sdev,
1416 struct v4l2_ext_control *control)
1417{
1418 s32 rval = 0;
1419
1420 mutex_lock(&sdev->mutex);
1421
1422 if (sdev->power_state) {
1423 rval = si4713_update_tune_status(sdev);
1424 if (rval < 0)
1425 goto unlock;
1426 }
1427
1428 switch (control->id) {
1429 case V4L2_CID_TUNE_POWER_LEVEL:
1430 control->value = sdev->power_level;
1431 break;
1432 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
1433 control->value = sdev->antenna_capacitor;
1434 break;
1435 default:
1436 rval = -EINVAL;
1437 };
1438
1439unlock:
1440 mutex_unlock(&sdev->mutex);
1441 return rval;
1442}
1443
1444static int si4713_read_econtrol_integers(struct si4713_device *sdev,
1445 struct v4l2_ext_control *control)
1446{
1447 s32 rval;
1448 u32 *shadow = NULL, val = 0;
1449 s32 bit = 0, mask = 0;
1450 u16 property = 0;
1451 int mul = 0;
1452 unsigned long *table = NULL;
1453 int size = 0;
1454
1455 rval = si4713_choose_econtrol_action(sdev, control->id, &shadow, &bit,
1456 &mask, &property, &mul, &table, &size);
1457 if (rval < 0)
1458 goto exit;
1459
1460 mutex_lock(&sdev->mutex);
1461
1462 if (sdev->power_state) {
1463 rval = si4713_read_property(sdev, property, &val);
1464 if (rval < 0)
1465 goto unlock;
1466
1467 /* Keep negative values for threshold */
1468 if (control->id == V4L2_CID_AUDIO_COMPRESSION_THRESHOLD)
1469 *shadow = (s16)val;
1470 else if (mask)
1471 *shadow = get_status_bit(val, bit, mask);
1472 else if (mul)
1473 *shadow = val * mul;
1474 else
1475 *shadow = dev_to_usecs(val, table, size);
1476 }
1477
1478 control->value = *shadow;
1479
1480unlock:
1481 mutex_unlock(&sdev->mutex);
1482exit:
1483 return rval;
1484}
1485
1486/*
1487 * Video4Linux Subdev Interface
1488 */
1489/* si4713_s_ext_ctrls - set extended controls value */
1490static int si4713_s_ext_ctrls(struct v4l2_subdev *sd,
1491 struct v4l2_ext_controls *ctrls)
1492{
1493 struct si4713_device *sdev = to_si4713_device(sd);
1494 int i;
1495
1496 if (ctrls->ctrl_class != V4L2_CTRL_CLASS_FM_TX)
1497 return -EINVAL;
1498
1499 for (i = 0; i < ctrls->count; i++) {
1500 int err;
1501
1502 switch ((ctrls->controls + i)->id) {
1503 case V4L2_CID_RDS_TX_PS_NAME:
1504 case V4L2_CID_RDS_TX_RADIO_TEXT:
1505 err = si4713_write_econtrol_string(sdev,
1506 ctrls->controls + i);
1507 break;
1508 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
1509 case V4L2_CID_TUNE_POWER_LEVEL:
1510 err = si4713_write_econtrol_tune(sdev,
1511 ctrls->controls + i);
1512 break;
1513 default:
1514 err = si4713_write_econtrol_integers(sdev,
1515 ctrls->controls + i);
1516 }
1517
1518 if (err < 0) {
1519 ctrls->error_idx = i;
1520 return err;
1521 }
1522 }
1523
1524 return 0;
1525}
1526
1527/* si4713_g_ext_ctrls - get extended controls value */
1528static int si4713_g_ext_ctrls(struct v4l2_subdev *sd,
1529 struct v4l2_ext_controls *ctrls)
1530{
1531 struct si4713_device *sdev = to_si4713_device(sd);
1532 int i;
1533
1534 if (ctrls->ctrl_class != V4L2_CTRL_CLASS_FM_TX)
1535 return -EINVAL;
1536
1537 for (i = 0; i < ctrls->count; i++) {
1538 int err;
1539
1540 switch ((ctrls->controls + i)->id) {
1541 case V4L2_CID_RDS_TX_PS_NAME:
1542 case V4L2_CID_RDS_TX_RADIO_TEXT:
1543 err = si4713_read_econtrol_string(sdev,
1544 ctrls->controls + i);
1545 break;
1546 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
1547 case V4L2_CID_TUNE_POWER_LEVEL:
1548 err = si4713_read_econtrol_tune(sdev,
1549 ctrls->controls + i);
1550 break;
1551 default:
1552 err = si4713_read_econtrol_integers(sdev,
1553 ctrls->controls + i);
1554 }
1555
1556 if (err < 0) {
1557 ctrls->error_idx = i;
1558 return err;
1559 }
1560 }
1561
1562 return 0;
1563}
1564
1565/* si4713_queryctrl - enumerate control items */
1566static int si4713_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
1567{
1568 int rval = 0;
1569
1570 switch (qc->id) {
1571 /* User class controls */
1572 case V4L2_CID_AUDIO_MUTE:
1573 rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, DEFAULT_MUTE);
1574 break;
1575 /* FM_TX class controls */
1576 case V4L2_CID_RDS_TX_PI:
1577 rval = v4l2_ctrl_query_fill(qc, 0, 0xFFFF, 1, DEFAULT_RDS_PI);
1578 break;
1579 case V4L2_CID_RDS_TX_PTY:
1580 rval = v4l2_ctrl_query_fill(qc, 0, 31, 1, DEFAULT_RDS_PTY);
1581 break;
1582 case V4L2_CID_RDS_TX_DEVIATION:
1583 rval = v4l2_ctrl_query_fill(qc, 0, MAX_RDS_DEVIATION,
1584 10, DEFAULT_RDS_DEVIATION);
1585 break;
1586 case V4L2_CID_RDS_TX_PS_NAME:
1587 /*
1588 * Report step as 8. From RDS spec, psname
1589 * should be 8. But there are receivers which scroll strings
1590 * sized as 8xN.
1591 */
1592 rval = v4l2_ctrl_query_fill(qc, 0, MAX_RDS_PS_NAME, 8, 0);
1593 break;
1594 case V4L2_CID_RDS_TX_RADIO_TEXT:
1595 /*
1596 * Report step as 32 (2A block). From RDS spec,
1597 * radio text should be 32 for 2A block. But there are receivers
1598 * which scroll strings sized as 32xN. Setting default to 32.
1599 */
1600 rval = v4l2_ctrl_query_fill(qc, 0, MAX_RDS_RADIO_TEXT, 32, 0);
1601 break;
1602
1603 case V4L2_CID_AUDIO_LIMITER_ENABLED:
1604 rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
1605 break;
1606 case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME:
1607 rval = v4l2_ctrl_query_fill(qc, 250, MAX_LIMITER_RELEASE_TIME,
1608 50, DEFAULT_LIMITER_RTIME);
1609 break;
1610 case V4L2_CID_AUDIO_LIMITER_DEVIATION:
1611 rval = v4l2_ctrl_query_fill(qc, 0, MAX_LIMITER_DEVIATION,
1612 10, DEFAULT_LIMITER_DEV);
1613 break;
1614
1615 case V4L2_CID_AUDIO_COMPRESSION_ENABLED:
1616 rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
1617 break;
1618 case V4L2_CID_AUDIO_COMPRESSION_GAIN:
1619 rval = v4l2_ctrl_query_fill(qc, 0, MAX_ACOMP_GAIN, 1,
1620 DEFAULT_ACOMP_GAIN);
1621 break;
1622 case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD:
1623 rval = v4l2_ctrl_query_fill(qc, MIN_ACOMP_THRESHOLD,
1624 MAX_ACOMP_THRESHOLD, 1,
1625 DEFAULT_ACOMP_THRESHOLD);
1626 break;
1627 case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME:
1628 rval = v4l2_ctrl_query_fill(qc, 0, MAX_ACOMP_ATTACK_TIME,
1629 500, DEFAULT_ACOMP_ATIME);
1630 break;
1631 case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME:
1632 rval = v4l2_ctrl_query_fill(qc, 100000, MAX_ACOMP_RELEASE_TIME,
1633 100000, DEFAULT_ACOMP_RTIME);
1634 break;
1635
1636 case V4L2_CID_PILOT_TONE_ENABLED:
1637 rval = v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
1638 break;
1639 case V4L2_CID_PILOT_TONE_DEVIATION:
1640 rval = v4l2_ctrl_query_fill(qc, 0, MAX_PILOT_DEVIATION,
1641 10, DEFAULT_PILOT_DEVIATION);
1642 break;
1643 case V4L2_CID_PILOT_TONE_FREQUENCY:
1644 rval = v4l2_ctrl_query_fill(qc, 0, MAX_PILOT_FREQUENCY,
1645 1, DEFAULT_PILOT_FREQUENCY);
1646 break;
1647
1648 case V4L2_CID_TUNE_PREEMPHASIS:
1649 rval = v4l2_ctrl_query_fill(qc, V4L2_PREEMPHASIS_DISABLED,
1650 V4L2_PREEMPHASIS_75_uS, 1,
1651 V4L2_PREEMPHASIS_50_uS);
1652 break;
1653 case V4L2_CID_TUNE_POWER_LEVEL:
1654 rval = v4l2_ctrl_query_fill(qc, 0, 120, 1, DEFAULT_POWER_LEVEL);
1655 break;
1656 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
1657 rval = v4l2_ctrl_query_fill(qc, 0, 191, 1, 0);
1658 break;
1659 default:
1660 rval = -EINVAL;
1661 break;
1662 };
1663
1664 return rval;
1665}
1666
1667/* si4713_g_ctrl - get the value of a control */
1668static int si4713_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
1669{
1670 struct si4713_device *sdev = to_si4713_device(sd);
1671 int rval = 0;
1672
1673 if (!sdev)
1674 return -ENODEV;
1675
1676 mutex_lock(&sdev->mutex);
1677
1678 if (sdev->power_state) {
1679 rval = si4713_read_property(sdev, SI4713_TX_LINE_INPUT_MUTE,
1680 &sdev->mute);
1681
1682 if (rval < 0)
1683 goto unlock;
1684 }
1685
1686 switch (ctrl->id) {
1687 case V4L2_CID_AUDIO_MUTE:
1688 ctrl->value = get_mute(sdev->mute);
1689 break;
1690 }
1691
1692unlock:
1693 mutex_unlock(&sdev->mutex);
1694 return rval;
1695}
1696
1697/* si4713_s_ctrl - set the value of a control */
1698static int si4713_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
1699{
1700 struct si4713_device *sdev = to_si4713_device(sd);
1701 int rval = 0;
1702
1703 if (!sdev)
1704 return -ENODEV;
1705
1706 switch (ctrl->id) {
1707 case V4L2_CID_AUDIO_MUTE:
1708 if (ctrl->value) {
1709 rval = si4713_set_mute(sdev, ctrl->value);
1710 if (rval < 0)
1711 goto exit;
1712
1713 rval = si4713_set_power_state(sdev, POWER_DOWN);
1714 } else {
1715 rval = si4713_set_power_state(sdev, POWER_UP);
1716 if (rval < 0)
1717 goto exit;
1718
1719 rval = si4713_setup(sdev);
1720 if (rval < 0)
1721 goto exit;
1722
1723 rval = si4713_set_mute(sdev, ctrl->value);
1724 }
1725 break;
1726 }
1727
1728exit:
1729 return rval;
1730}
1731
1732/* si4713_ioctl - deal with private ioctls (only rnl for now) */
1733long si4713_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
1734{
1735 struct si4713_device *sdev = to_si4713_device(sd);
1736 struct si4713_rnl *rnl = arg;
1737 u16 frequency;
1738 int rval = 0;
1739
1740 if (!arg)
1741 return -EINVAL;
1742
1743 mutex_lock(&sdev->mutex);
1744 switch (cmd) {
1745 case SI4713_IOC_MEASURE_RNL:
1746 frequency = v4l2_to_si4713(rnl->frequency);
1747
1748 if (sdev->power_state) {
1749 /* Set desired measurement frequency */
1750 rval = si4713_tx_tune_measure(sdev, frequency, 0);
1751 if (rval < 0)
1752 goto unlock;
1753 /* get results from tune status */
1754 rval = si4713_update_tune_status(sdev);
1755 if (rval < 0)
1756 goto unlock;
1757 }
1758 rnl->rnl = sdev->tune_rnl;
1759 break;
1760
1761 default:
1762 /* nothing */
1763 rval = -ENOIOCTLCMD;
1764 }
1765
1766unlock:
1767 mutex_unlock(&sdev->mutex);
1768 return rval;
1769}
1770
1771static const struct v4l2_subdev_core_ops si4713_subdev_core_ops = {
1772 .queryctrl = si4713_queryctrl,
1773 .g_ext_ctrls = si4713_g_ext_ctrls,
1774 .s_ext_ctrls = si4713_s_ext_ctrls,
1775 .g_ctrl = si4713_g_ctrl,
1776 .s_ctrl = si4713_s_ctrl,
1777 .ioctl = si4713_ioctl,
1778};
1779
1780/* si4713_g_modulator - get modulator attributes */
1781static int si4713_g_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
1782{
1783 struct si4713_device *sdev = to_si4713_device(sd);
1784 int rval = 0;
1785
1786 if (!sdev) {
1787 rval = -ENODEV;
1788 goto exit;
1789 }
1790
1791 if (vm->index > 0) {
1792 rval = -EINVAL;
1793 goto exit;
1794 }
1795
1796 strncpy(vm->name, "FM Modulator", 32);
1797 vm->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW |
1798 V4L2_TUNER_CAP_RDS;
1799
1800 /* Report current frequency range limits */
1801 vm->rangelow = si4713_to_v4l2(FREQ_RANGE_LOW);
1802 vm->rangehigh = si4713_to_v4l2(FREQ_RANGE_HIGH);
1803
1804 mutex_lock(&sdev->mutex);
1805
1806 if (sdev->power_state) {
1807 u32 comp_en = 0;
1808
1809 rval = si4713_read_property(sdev, SI4713_TX_COMPONENT_ENABLE,
1810 &comp_en);
1811 if (rval < 0)
1812 goto unlock;
1813
1814 sdev->stereo = get_status_bit(comp_en, 1, 1 << 1);
1815 sdev->rds_info.enabled = get_status_bit(comp_en, 2, 1 << 2);
1816 }
1817
1818 /* Report current audio mode: mono or stereo */
1819 if (sdev->stereo)
1820 vm->txsubchans = V4L2_TUNER_SUB_STEREO;
1821 else
1822 vm->txsubchans = V4L2_TUNER_SUB_MONO;
1823
1824 /* Report rds feature status */
1825 if (sdev->rds_info.enabled)
1826 vm->txsubchans |= V4L2_TUNER_SUB_RDS;
1827 else
1828 vm->txsubchans &= ~V4L2_TUNER_SUB_RDS;
1829
1830unlock:
1831 mutex_unlock(&sdev->mutex);
1832exit:
1833 return rval;
1834}
1835
1836/* si4713_s_modulator - set modulator attributes */
1837static int si4713_s_modulator(struct v4l2_subdev *sd, struct v4l2_modulator *vm)
1838{
1839 struct si4713_device *sdev = to_si4713_device(sd);
1840 int rval = 0;
1841 u16 stereo, rds;
1842 u32 p;
1843
1844 if (!sdev)
1845 return -ENODEV;
1846
1847 if (vm->index > 0)
1848 return -EINVAL;
1849
1850 /* Set audio mode: mono or stereo */
1851 if (vm->txsubchans & V4L2_TUNER_SUB_STEREO)
1852 stereo = 1;
1853 else if (vm->txsubchans & V4L2_TUNER_SUB_MONO)
1854 stereo = 0;
1855 else
1856 return -EINVAL;
1857
1858 rds = !!(vm->txsubchans & V4L2_TUNER_SUB_RDS);
1859
1860 mutex_lock(&sdev->mutex);
1861
1862 if (sdev->power_state) {
1863 rval = si4713_read_property(sdev,
1864 SI4713_TX_COMPONENT_ENABLE, &p);
1865 if (rval < 0)
1866 goto unlock;
1867
1868 p = set_bits(p, stereo, 1, 1 << 1);
1869 p = set_bits(p, rds, 2, 1 << 2);
1870
1871 rval = si4713_write_property(sdev,
1872 SI4713_TX_COMPONENT_ENABLE, p);
1873 if (rval < 0)
1874 goto unlock;
1875 }
1876
1877 sdev->stereo = stereo;
1878 sdev->rds_info.enabled = rds;
1879
1880unlock:
1881 mutex_unlock(&sdev->mutex);
1882 return rval;
1883}
1884
1885/* si4713_g_frequency - get tuner or modulator radio frequency */
1886static int si4713_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
1887{
1888 struct si4713_device *sdev = to_si4713_device(sd);
1889 int rval = 0;
1890
1891 f->type = V4L2_TUNER_RADIO;
1892
1893 mutex_lock(&sdev->mutex);
1894
1895 if (sdev->power_state) {
1896 u16 freq;
1897 u8 p, a, n;
1898
1899 rval = si4713_tx_tune_status(sdev, 0x00, &freq, &p, &a, &n);
1900 if (rval < 0)
1901 goto unlock;
1902
1903 sdev->frequency = freq;
1904 }
1905
1906 f->frequency = si4713_to_v4l2(sdev->frequency);
1907
1908unlock:
1909 mutex_unlock(&sdev->mutex);
1910 return rval;
1911}
1912
1913/* si4713_s_frequency - set tuner or modulator radio frequency */
1914static int si4713_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
1915{
1916 struct si4713_device *sdev = to_si4713_device(sd);
1917 int rval = 0;
1918 u16 frequency = v4l2_to_si4713(f->frequency);
1919
1920 /* Check frequency range */
1921 if (frequency < FREQ_RANGE_LOW || frequency > FREQ_RANGE_HIGH)
1922 return -EDOM;
1923
1924 mutex_lock(&sdev->mutex);
1925
1926 if (sdev->power_state) {
1927 rval = si4713_tx_tune_freq(sdev, frequency);
1928 if (rval < 0)
1929 goto unlock;
1930 frequency = rval;
1931 rval = 0;
1932 }
1933 sdev->frequency = frequency;
1934 f->frequency = si4713_to_v4l2(frequency);
1935
1936unlock:
1937 mutex_unlock(&sdev->mutex);
1938 return rval;
1939}
1940
1941static const struct v4l2_subdev_tuner_ops si4713_subdev_tuner_ops = {
1942 .g_frequency = si4713_g_frequency,
1943 .s_frequency = si4713_s_frequency,
1944 .g_modulator = si4713_g_modulator,
1945 .s_modulator = si4713_s_modulator,
1946};
1947
1948static const struct v4l2_subdev_ops si4713_subdev_ops = {
1949 .core = &si4713_subdev_core_ops,
1950 .tuner = &si4713_subdev_tuner_ops,
1951};
1952
1953/*
1954 * I2C driver interface
1955 */
1956/* si4713_probe - probe for the device */
1957static int si4713_probe(struct i2c_client *client,
1958 const struct i2c_device_id *id)
1959{
1960 struct si4713_device *sdev;
1961 int rval;
1962
1963 sdev = kzalloc(sizeof *sdev, GFP_KERNEL);
1964 if (!sdev) {
1965 dev_err(&client->dev, "Failed to alloc video device.\n");
1966 rval = -ENOMEM;
1967 goto exit;
1968 }
1969
1970 sdev->platform_data = client->dev.platform_data;
1971 if (!sdev->platform_data) {
1972 v4l2_err(&sdev->sd, "No platform data registered.\n");
1973 rval = -ENODEV;
1974 goto free_sdev;
1975 }
1976
1977 v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops);
1978
1979 mutex_init(&sdev->mutex);
1980 init_completion(&sdev->work);
1981
1982 if (client->irq) {
1983 rval = request_irq(client->irq,
1984 si4713_handler, IRQF_TRIGGER_FALLING | IRQF_DISABLED,
1985 client->name, sdev);
1986 if (rval < 0) {
1987 v4l2_err(&sdev->sd, "Could not request IRQ\n");
1988 goto free_sdev;
1989 }
1990 v4l2_dbg(1, debug, &sdev->sd, "IRQ requested.\n");
1991 } else {
1992 v4l2_warn(&sdev->sd, "IRQ not configured. Using timeouts.\n");
1993 }
1994
1995 rval = si4713_initialize(sdev);
1996 if (rval < 0) {
1997 v4l2_err(&sdev->sd, "Failed to probe device information.\n");
1998 goto free_irq;
1999 }
2000
2001 return 0;
2002
2003free_irq:
2004 if (client->irq)
2005 free_irq(client->irq, sdev);
2006free_sdev:
2007 kfree(sdev);
2008exit:
2009 return rval;
2010}
2011
2012/* si4713_remove - remove the device */
2013static int si4713_remove(struct i2c_client *client)
2014{
2015 struct v4l2_subdev *sd = i2c_get_clientdata(client);
2016 struct si4713_device *sdev = to_si4713_device(sd);
2017
2018 if (sdev->power_state)
2019 si4713_set_power_state(sdev, POWER_DOWN);
2020
2021 if (client->irq > 0)
2022 free_irq(client->irq, sdev);
2023
2024 v4l2_device_unregister_subdev(sd);
2025
2026 kfree(sdev);
2027
2028 return 0;
2029}
2030
2031/* si4713_i2c_driver - i2c driver interface */
2032static const struct i2c_device_id si4713_id[] = {
2033 { "si4713" , 0 },
2034 { },
2035};
2036MODULE_DEVICE_TABLE(i2c, si4713_id);
2037
2038static struct i2c_driver si4713_i2c_driver = {
2039 .driver = {
2040 .name = "si4713",
2041 },
2042 .probe = si4713_probe,
2043 .remove = si4713_remove,
2044 .id_table = si4713_id,
2045};
2046
2047/* Module Interface */
2048static int __init si4713_module_init(void)
2049{
2050 return i2c_add_driver(&si4713_i2c_driver);
2051}
2052
2053static void __exit si4713_module_exit(void)
2054{
2055 i2c_del_driver(&si4713_i2c_driver);
2056}
2057
2058module_init(si4713_module_init);
2059module_exit(si4713_module_exit);
2060
diff --git a/drivers/media/radio/si4713-i2c.h b/drivers/media/radio/si4713-i2c.h
new file mode 100644
index 000000000000..faf8cff124f1
--- /dev/null
+++ b/drivers/media/radio/si4713-i2c.h
@@ -0,0 +1,237 @@
1/*
2 * drivers/media/radio/si4713-i2c.h
3 *
4 * Property and commands definitions for Si4713 radio transmitter chip.
5 *
6 * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
7 * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 *
13 */
14
15#ifndef SI4713_I2C_H
16#define SI4713_I2C_H
17
18#include <media/v4l2-subdev.h>
19#include <media/si4713.h>
20
21#define SI4713_PRODUCT_NUMBER 0x0D
22
23/* Command Timeouts */
24#define DEFAULT_TIMEOUT 500
25#define TIMEOUT_SET_PROPERTY 20
26#define TIMEOUT_TX_TUNE_POWER 30000
27#define TIMEOUT_TX_TUNE 110000
28#define TIMEOUT_POWER_UP 200000
29
30/*
31 * Command and its arguments definitions
32 */
33#define SI4713_PWUP_CTSIEN (1<<7)
34#define SI4713_PWUP_GPO2OEN (1<<6)
35#define SI4713_PWUP_PATCH (1<<5)
36#define SI4713_PWUP_XOSCEN (1<<4)
37#define SI4713_PWUP_FUNC_TX 0x02
38#define SI4713_PWUP_FUNC_PATCH 0x0F
39#define SI4713_PWUP_OPMOD_ANALOG 0x50
40#define SI4713_PWUP_OPMOD_DIGITAL 0x0F
41#define SI4713_PWUP_NARGS 2
42#define SI4713_PWUP_NRESP 1
43#define SI4713_CMD_POWER_UP 0x01
44
45#define SI4713_GETREV_NRESP 9
46#define SI4713_CMD_GET_REV 0x10
47
48#define SI4713_PWDN_NRESP 1
49#define SI4713_CMD_POWER_DOWN 0x11
50
51#define SI4713_SET_PROP_NARGS 5
52#define SI4713_SET_PROP_NRESP 1
53#define SI4713_CMD_SET_PROPERTY 0x12
54
55#define SI4713_GET_PROP_NARGS 3
56#define SI4713_GET_PROP_NRESP 4
57#define SI4713_CMD_GET_PROPERTY 0x13
58
59#define SI4713_GET_STATUS_NRESP 1
60#define SI4713_CMD_GET_INT_STATUS 0x14
61
62#define SI4713_CMD_PATCH_ARGS 0x15
63#define SI4713_CMD_PATCH_DATA 0x16
64
65#define SI4713_MAX_FREQ 10800
66#define SI4713_MIN_FREQ 7600
67#define SI4713_TXFREQ_NARGS 3
68#define SI4713_TXFREQ_NRESP 1
69#define SI4713_CMD_TX_TUNE_FREQ 0x30
70
71#define SI4713_MAX_POWER 120
72#define SI4713_MIN_POWER 88
73#define SI4713_MAX_ANTCAP 191
74#define SI4713_MIN_ANTCAP 0
75#define SI4713_TXPWR_NARGS 4
76#define SI4713_TXPWR_NRESP 1
77#define SI4713_CMD_TX_TUNE_POWER 0x31
78
79#define SI4713_TXMEA_NARGS 4
80#define SI4713_TXMEA_NRESP 1
81#define SI4713_CMD_TX_TUNE_MEASURE 0x32
82
83#define SI4713_INTACK_MASK 0x01
84#define SI4713_TXSTATUS_NARGS 1
85#define SI4713_TXSTATUS_NRESP 8
86#define SI4713_CMD_TX_TUNE_STATUS 0x33
87
88#define SI4713_OVERMOD_BIT (1 << 2)
89#define SI4713_IALH_BIT (1 << 1)
90#define SI4713_IALL_BIT (1 << 0)
91#define SI4713_ASQSTATUS_NARGS 1
92#define SI4713_ASQSTATUS_NRESP 5
93#define SI4713_CMD_TX_ASQ_STATUS 0x34
94
95#define SI4713_RDSBUFF_MODE_MASK 0x87
96#define SI4713_RDSBUFF_NARGS 7
97#define SI4713_RDSBUFF_NRESP 6
98#define SI4713_CMD_TX_RDS_BUFF 0x35
99
100#define SI4713_RDSPS_PSID_MASK 0x1F
101#define SI4713_RDSPS_NARGS 5
102#define SI4713_RDSPS_NRESP 1
103#define SI4713_CMD_TX_RDS_PS 0x36
104
105#define SI4713_CMD_GPO_CTL 0x80
106#define SI4713_CMD_GPO_SET 0x81
107
108/*
109 * Bits from status response
110 */
111#define SI4713_CTS (1<<7)
112#define SI4713_ERR (1<<6)
113#define SI4713_RDS_INT (1<<2)
114#define SI4713_ASQ_INT (1<<1)
115#define SI4713_STC_INT (1<<0)
116
117/*
118 * Property definitions
119 */
120#define SI4713_GPO_IEN 0x0001
121#define SI4713_DIG_INPUT_FORMAT 0x0101
122#define SI4713_DIG_INPUT_SAMPLE_RATE 0x0103
123#define SI4713_REFCLK_FREQ 0x0201
124#define SI4713_REFCLK_PRESCALE 0x0202
125#define SI4713_TX_COMPONENT_ENABLE 0x2100
126#define SI4713_TX_AUDIO_DEVIATION 0x2101
127#define SI4713_TX_PILOT_DEVIATION 0x2102
128#define SI4713_TX_RDS_DEVIATION 0x2103
129#define SI4713_TX_LINE_INPUT_LEVEL 0x2104
130#define SI4713_TX_LINE_INPUT_MUTE 0x2105
131#define SI4713_TX_PREEMPHASIS 0x2106
132#define SI4713_TX_PILOT_FREQUENCY 0x2107
133#define SI4713_TX_ACOMP_ENABLE 0x2200
134#define SI4713_TX_ACOMP_THRESHOLD 0x2201
135#define SI4713_TX_ACOMP_ATTACK_TIME 0x2202
136#define SI4713_TX_ACOMP_RELEASE_TIME 0x2203
137#define SI4713_TX_ACOMP_GAIN 0x2204
138#define SI4713_TX_LIMITER_RELEASE_TIME 0x2205
139#define SI4713_TX_ASQ_INTERRUPT_SOURCE 0x2300
140#define SI4713_TX_ASQ_LEVEL_LOW 0x2301
141#define SI4713_TX_ASQ_DURATION_LOW 0x2302
142#define SI4713_TX_ASQ_LEVEL_HIGH 0x2303
143#define SI4713_TX_ASQ_DURATION_HIGH 0x2304
144#define SI4713_TX_RDS_INTERRUPT_SOURCE 0x2C00
145#define SI4713_TX_RDS_PI 0x2C01
146#define SI4713_TX_RDS_PS_MIX 0x2C02
147#define SI4713_TX_RDS_PS_MISC 0x2C03
148#define SI4713_TX_RDS_PS_REPEAT_COUNT 0x2C04
149#define SI4713_TX_RDS_PS_MESSAGE_COUNT 0x2C05
150#define SI4713_TX_RDS_PS_AF 0x2C06
151#define SI4713_TX_RDS_FIFO_SIZE 0x2C07
152
153#define PREEMPHASIS_USA 75
154#define PREEMPHASIS_EU 50
155#define PREEMPHASIS_DISABLED 0
156#define FMPE_USA 0x00
157#define FMPE_EU 0x01
158#define FMPE_DISABLED 0x02
159
160#define POWER_UP 0x01
161#define POWER_DOWN 0x00
162
163struct rds_info {
164 u32 pi;
165#define MAX_RDS_PTY 31
166 u32 pty;
167#define MAX_RDS_DEVIATION 90000
168 u32 deviation;
169/*
170 * PSNAME is known to be defined as 8 character sized (RDS Spec).
171 * However, there is receivers which scroll PSNAME 8xN sized.
172 */
173#define MAX_RDS_PS_NAME 96
174 u8 ps_name[MAX_RDS_PS_NAME + 1];
175/*
176 * MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group)
177 * character sized (RDS Spec).
178 * However, there is receivers which scroll them as well.
179 */
180#define MAX_RDS_RADIO_TEXT 384
181 u8 radio_text[MAX_RDS_RADIO_TEXT + 1];
182 u32 enabled;
183};
184
185struct limiter_info {
186#define MAX_LIMITER_RELEASE_TIME 102390
187 u32 release_time;
188#define MAX_LIMITER_DEVIATION 90000
189 u32 deviation;
190 u32 enabled;
191};
192
193struct pilot_info {
194#define MAX_PILOT_DEVIATION 90000
195 u32 deviation;
196#define MAX_PILOT_FREQUENCY 19000
197 u32 frequency;
198 u32 enabled;
199};
200
201struct acomp_info {
202#define MAX_ACOMP_RELEASE_TIME 1000000
203 u32 release_time;
204#define MAX_ACOMP_ATTACK_TIME 5000
205 u32 attack_time;
206#define MAX_ACOMP_THRESHOLD 0
207#define MIN_ACOMP_THRESHOLD (-40)
208 s32 threshold;
209#define MAX_ACOMP_GAIN 20
210 u32 gain;
211 u32 enabled;
212};
213
214/*
215 * si4713_device - private data
216 */
217struct si4713_device {
218 /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
219 struct v4l2_subdev sd;
220 /* private data structures */
221 struct mutex mutex;
222 struct completion work;
223 struct si4713_platform_data *platform_data;
224 struct rds_info rds_info;
225 struct limiter_info limiter_info;
226 struct pilot_info pilot_info;
227 struct acomp_info acomp_info;
228 u32 frequency;
229 u32 preemphasis;
230 u32 mute;
231 u32 power_level;
232 u32 power_state;
233 u32 antenna_capacitor;
234 u32 stereo;
235 u32 tune_rnl;
236};
237#endif /* ifndef SI4713_I2C_H */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index dcf9fa9264bb..1d758525d236 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -203,9 +203,9 @@ config VIDEO_CS53L32A
203 module will be called cs53l32a. 203 module will be called cs53l32a.
204 204
205config VIDEO_M52790 205config VIDEO_M52790
206 tristate "Mitsubishi M52790 A/V switch" 206 tristate "Mitsubishi M52790 A/V switch"
207 depends on VIDEO_V4L2 && I2C 207 depends on VIDEO_V4L2 && I2C
208 ---help--- 208 ---help---
209 Support for the Mitsubishi M52790 A/V switch. 209 Support for the Mitsubishi M52790 A/V switch.
210 210
211 To compile this driver as a module, choose M here: the 211 To compile this driver as a module, choose M here: the
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index 14baffc22192..b8a4b52e8d47 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -151,7 +151,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
151 dprintk(2, "%s()\n", __func__); 151 dprintk(2, "%s()\n", __func__);
152 152
153 if (dev->urb_streaming) { 153 if (dev->urb_streaming) {
154 dprintk(2, "%s: iso xfer already running!\n", __func__); 154 dprintk(2, "%s: bulk xfer already running!\n", __func__);
155 return 0; 155 return 0;
156 } 156 }
157 157
diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c
index 13e494365e70..cbdb65c34f21 100644
--- a/drivers/media/video/au0828/au0828-i2c.c
+++ b/drivers/media/video/au0828/au0828-i2c.c
@@ -320,7 +320,6 @@ static struct i2c_algorithm au0828_i2c_algo_template = {
320static struct i2c_adapter au0828_i2c_adap_template = { 320static struct i2c_adapter au0828_i2c_adap_template = {
321 .name = DRIVER_NAME, 321 .name = DRIVER_NAME,
322 .owner = THIS_MODULE, 322 .owner = THIS_MODULE,
323 .id = I2C_HW_B_AU0828,
324 .algo = &au0828_i2c_algo_template, 323 .algo = &au0828_i2c_algo_template,
325}; 324};
326 325
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index ca6558c394be..b42251fa96ba 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -1274,6 +1274,7 @@ struct tvcard bttv_tvcards[] = {
1274 .pll = PLL_28, 1274 .pll = PLL_28,
1275 .tuner_type = TUNER_TEMIC_PAL, 1275 .tuner_type = TUNER_TEMIC_PAL,
1276 .tuner_addr = ADDR_UNSET, 1276 .tuner_addr = ADDR_UNSET,
1277 .has_remote = 1,
1277 }, 1278 },
1278 1279
1279 /* ---- card 0x3c ---------------------------------- */ 1280 /* ---- card 0x3c ---------------------------------- */
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 8cc6dd28d6a7..939d1e512974 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2652,6 +2652,8 @@ static int bttv_querycap(struct file *file, void *priv,
2652 V4L2_CAP_VBI_CAPTURE | 2652 V4L2_CAP_VBI_CAPTURE |
2653 V4L2_CAP_READWRITE | 2653 V4L2_CAP_READWRITE |
2654 V4L2_CAP_STREAMING; 2654 V4L2_CAP_STREAMING;
2655 if (btv->has_saa6588)
2656 cap->capabilities |= V4L2_CAP_RDS_CAPTURE;
2655 if (no_overlay <= 0) 2657 if (no_overlay <= 0)
2656 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY; 2658 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
2657 2659
@@ -4593,14 +4595,10 @@ static int bttv_resume(struct pci_dev *pci_dev)
4593#endif 4595#endif
4594 4596
4595static struct pci_device_id bttv_pci_tbl[] = { 4597static struct pci_device_id bttv_pci_tbl[] = {
4596 {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848, 4598 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT848), 0},
4597 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 4599 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT849), 0},
4598 {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849, 4600 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT878), 0},
4599 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 4601 {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT879), 0},
4600 {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878,
4601 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
4602 {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT879,
4603 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
4604 {0,} 4602 {0,}
4605}; 4603};
4606 4604
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index ebd1ee9dc871..beda363418b0 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -352,7 +352,6 @@ int __devinit init_bttv_i2c(struct bttv *btv)
352 /* bt878 */ 352 /* bt878 */
353 strlcpy(btv->c.i2c_adap.name, "bt878", 353 strlcpy(btv->c.i2c_adap.name, "bt878",
354 sizeof(btv->c.i2c_adap.name)); 354 sizeof(btv->c.i2c_adap.name));
355 btv->c.i2c_adap.id = I2C_HW_B_BT848; /* FIXME */
356 btv->c.i2c_adap.algo = &bttv_algo; 355 btv->c.i2c_adap.algo = &bttv_algo;
357 } else { 356 } else {
358 /* bt848 */ 357 /* bt848 */
@@ -362,7 +361,6 @@ int __devinit init_bttv_i2c(struct bttv *btv)
362 361
363 strlcpy(btv->c.i2c_adap.name, "bttv", 362 strlcpy(btv->c.i2c_adap.name, "bttv",
364 sizeof(btv->c.i2c_adap.name)); 363 sizeof(btv->c.i2c_adap.name));
365 btv->c.i2c_adap.id = I2C_HW_B_BT848;
366 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template, 364 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
367 sizeof(bttv_i2c_algo_bit_template)); 365 sizeof(bttv_i2c_algo_bit_template));
368 btv->i2c_algo.udelay = i2c_udelay; 366 btv->i2c_algo.udelay = i2c_udelay;
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 2f289d981fe6..ebd51afe8761 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -245,7 +245,7 @@ static void bttv_ir_stop(struct bttv *btv)
245int bttv_input_init(struct bttv *btv) 245int bttv_input_init(struct bttv *btv)
246{ 246{
247 struct card_ir *ir; 247 struct card_ir *ir;
248 IR_KEYTAB_TYPE *ir_codes = NULL; 248 struct ir_scancode_table *ir_codes = NULL;
249 struct input_dev *input_dev; 249 struct input_dev *input_dev;
250 int ir_type = IR_TYPE_OTHER; 250 int ir_type = IR_TYPE_OTHER;
251 int err = -ENOMEM; 251 int err = -ENOMEM;
@@ -263,7 +263,7 @@ int bttv_input_init(struct bttv *btv)
263 case BTTV_BOARD_AVERMEDIA: 263 case BTTV_BOARD_AVERMEDIA:
264 case BTTV_BOARD_AVPHONE98: 264 case BTTV_BOARD_AVPHONE98:
265 case BTTV_BOARD_AVERMEDIA98: 265 case BTTV_BOARD_AVERMEDIA98:
266 ir_codes = ir_codes_avermedia; 266 ir_codes = &ir_codes_avermedia_table;
267 ir->mask_keycode = 0xf88000; 267 ir->mask_keycode = 0xf88000;
268 ir->mask_keydown = 0x010000; 268 ir->mask_keydown = 0x010000;
269 ir->polling = 50; // ms 269 ir->polling = 50; // ms
@@ -271,14 +271,14 @@ int bttv_input_init(struct bttv *btv)
271 271
272 case BTTV_BOARD_AVDVBT_761: 272 case BTTV_BOARD_AVDVBT_761:
273 case BTTV_BOARD_AVDVBT_771: 273 case BTTV_BOARD_AVDVBT_771:
274 ir_codes = ir_codes_avermedia_dvbt; 274 ir_codes = &ir_codes_avermedia_dvbt_table;
275 ir->mask_keycode = 0x0f00c0; 275 ir->mask_keycode = 0x0f00c0;
276 ir->mask_keydown = 0x000020; 276 ir->mask_keydown = 0x000020;
277 ir->polling = 50; // ms 277 ir->polling = 50; // ms
278 break; 278 break;
279 279
280 case BTTV_BOARD_PXELVWPLTVPAK: 280 case BTTV_BOARD_PXELVWPLTVPAK:
281 ir_codes = ir_codes_pixelview; 281 ir_codes = &ir_codes_pixelview_table;
282 ir->mask_keycode = 0x003e00; 282 ir->mask_keycode = 0x003e00;
283 ir->mask_keyup = 0x010000; 283 ir->mask_keyup = 0x010000;
284 ir->polling = 50; // ms 284 ir->polling = 50; // ms
@@ -286,54 +286,55 @@ int bttv_input_init(struct bttv *btv)
286 case BTTV_BOARD_PV_M4900: 286 case BTTV_BOARD_PV_M4900:
287 case BTTV_BOARD_PV_BT878P_9B: 287 case BTTV_BOARD_PV_BT878P_9B:
288 case BTTV_BOARD_PV_BT878P_PLUS: 288 case BTTV_BOARD_PV_BT878P_PLUS:
289 ir_codes = ir_codes_pixelview; 289 ir_codes = &ir_codes_pixelview_table;
290 ir->mask_keycode = 0x001f00; 290 ir->mask_keycode = 0x001f00;
291 ir->mask_keyup = 0x008000; 291 ir->mask_keyup = 0x008000;
292 ir->polling = 50; // ms 292 ir->polling = 50; // ms
293 break; 293 break;
294 294
295 case BTTV_BOARD_WINFAST2000: 295 case BTTV_BOARD_WINFAST2000:
296 ir_codes = ir_codes_winfast; 296 ir_codes = &ir_codes_winfast_table;
297 ir->mask_keycode = 0x1f8; 297 ir->mask_keycode = 0x1f8;
298 break; 298 break;
299 case BTTV_BOARD_MAGICTVIEW061: 299 case BTTV_BOARD_MAGICTVIEW061:
300 case BTTV_BOARD_MAGICTVIEW063: 300 case BTTV_BOARD_MAGICTVIEW063:
301 ir_codes = ir_codes_winfast; 301 ir_codes = &ir_codes_winfast_table;
302 ir->mask_keycode = 0x0008e000; 302 ir->mask_keycode = 0x0008e000;
303 ir->mask_keydown = 0x00200000; 303 ir->mask_keydown = 0x00200000;
304 break; 304 break;
305 case BTTV_BOARD_APAC_VIEWCOMP: 305 case BTTV_BOARD_APAC_VIEWCOMP:
306 ir_codes = ir_codes_apac_viewcomp; 306 ir_codes = &ir_codes_apac_viewcomp_table;
307 ir->mask_keycode = 0x001f00; 307 ir->mask_keycode = 0x001f00;
308 ir->mask_keyup = 0x008000; 308 ir->mask_keyup = 0x008000;
309 ir->polling = 50; // ms 309 ir->polling = 50; // ms
310 break; 310 break;
311 case BTTV_BOARD_ASKEY_CPH03X:
311 case BTTV_BOARD_CONCEPTRONIC_CTVFMI2: 312 case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
312 case BTTV_BOARD_CONTVFMI: 313 case BTTV_BOARD_CONTVFMI:
313 ir_codes = ir_codes_pixelview; 314 ir_codes = &ir_codes_pixelview_table;
314 ir->mask_keycode = 0x001F00; 315 ir->mask_keycode = 0x001F00;
315 ir->mask_keyup = 0x006000; 316 ir->mask_keyup = 0x006000;
316 ir->polling = 50; // ms 317 ir->polling = 50; // ms
317 break; 318 break;
318 case BTTV_BOARD_NEBULA_DIGITV: 319 case BTTV_BOARD_NEBULA_DIGITV:
319 ir_codes = ir_codes_nebula; 320 ir_codes = &ir_codes_nebula_table;
320 btv->custom_irq = bttv_rc5_irq; 321 btv->custom_irq = bttv_rc5_irq;
321 ir->rc5_gpio = 1; 322 ir->rc5_gpio = 1;
322 break; 323 break;
323 case BTTV_BOARD_MACHTV_MAGICTV: 324 case BTTV_BOARD_MACHTV_MAGICTV:
324 ir_codes = ir_codes_apac_viewcomp; 325 ir_codes = &ir_codes_apac_viewcomp_table;
325 ir->mask_keycode = 0x001F00; 326 ir->mask_keycode = 0x001F00;
326 ir->mask_keyup = 0x004000; 327 ir->mask_keyup = 0x004000;
327 ir->polling = 50; /* ms */ 328 ir->polling = 50; /* ms */
328 break; 329 break;
329 case BTTV_BOARD_KOZUMI_KTV_01C: 330 case BTTV_BOARD_KOZUMI_KTV_01C:
330 ir_codes = ir_codes_pctv_sedna; 331 ir_codes = &ir_codes_pctv_sedna_table;
331 ir->mask_keycode = 0x001f00; 332 ir->mask_keycode = 0x001f00;
332 ir->mask_keyup = 0x006000; 333 ir->mask_keyup = 0x006000;
333 ir->polling = 50; /* ms */ 334 ir->polling = 50; /* ms */
334 break; 335 break;
335 case BTTV_BOARD_ENLTV_FM_2: 336 case BTTV_BOARD_ENLTV_FM_2:
336 ir_codes = ir_codes_encore_enltv2; 337 ir_codes = &ir_codes_encore_enltv2_table;
337 ir->mask_keycode = 0x00fd00; 338 ir->mask_keycode = 0x00fd00;
338 ir->mask_keyup = 0x000080; 339 ir->mask_keyup = 0x000080;
339 ir->polling = 1; /* ms */ 340 ir->polling = 1; /* ms */
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index c4d181dde1ca..9c149a781294 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -490,7 +490,6 @@ static int cafe_smbus_setup(struct cafe_camera *cam)
490 int ret; 490 int ret;
491 491
492 cafe_smbus_enable_irq(cam); 492 cafe_smbus_enable_irq(cam);
493 adap->id = I2C_HW_SMBUS_CAFE;
494 adap->owner = THIS_MODULE; 493 adap->owner = THIS_MODULE;
495 adap->algo = &cafe_smbus_algo; 494 adap->algo = &cafe_smbus_algo;
496 strcpy(adap->name, "cafe_ccic"); 495 strcpy(adap->name, "cafe_ccic");
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index 36f2d76006fd..f11e47a58286 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -56,7 +56,8 @@ static const struct cx18_card cx18_card_hvr1600_esmt = {
56 .hw_audio_ctrl = CX18_HW_418_AV, 56 .hw_audio_ctrl = CX18_HW_418_AV,
57 .hw_muxer = CX18_HW_CS5345, 57 .hw_muxer = CX18_HW_CS5345,
58 .hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER | 58 .hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
59 CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL, 59 CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL |
60 CX18_HW_Z8F0811_IR_HAUP,
60 .video_inputs = { 61 .video_inputs = {
61 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 }, 62 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
62 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 }, 63 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
@@ -102,7 +103,8 @@ static const struct cx18_card cx18_card_hvr1600_samsung = {
102 .hw_audio_ctrl = CX18_HW_418_AV, 103 .hw_audio_ctrl = CX18_HW_418_AV,
103 .hw_muxer = CX18_HW_CS5345, 104 .hw_muxer = CX18_HW_CS5345,
104 .hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER | 105 .hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
105 CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL, 106 CX18_HW_CS5345 | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL |
107 CX18_HW_Z8F0811_IR_HAUP,
106 .video_inputs = { 108 .video_inputs = {
107 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 }, 109 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE7 },
108 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 }, 110 { CX18_CARD_INPUT_SVIDEO1, 1, CX18_AV_SVIDEO1 },
@@ -204,7 +206,7 @@ static const struct cx18_card cx18_card_mpc718 = {
204 .v4l2_capabilities = CX18_CAP_ENCODER, 206 .v4l2_capabilities = CX18_CAP_ENCODER,
205 .hw_audio_ctrl = CX18_HW_418_AV, 207 .hw_audio_ctrl = CX18_HW_418_AV,
206 .hw_muxer = CX18_HW_GPIO_MUX, 208 .hw_muxer = CX18_HW_GPIO_MUX,
207 .hw_all = CX18_HW_418_AV | CX18_HW_TUNER | 209 .hw_all = CX18_HW_TVEEPROM | CX18_HW_418_AV | CX18_HW_TUNER |
208 CX18_HW_GPIO_MUX | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL, 210 CX18_HW_GPIO_MUX | CX18_HW_DVB | CX18_HW_GPIO_RESET_CTRL,
209 .video_inputs = { 211 .video_inputs = {
210 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 }, 212 { CX18_CARD_INPUT_VID_TUNER, 0, CX18_AV_COMPOSITE2 },
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h
index 3c552b6b7c4d..444e3c7c563e 100644
--- a/drivers/media/video/cx18/cx18-cards.h
+++ b/drivers/media/video/cx18/cx18-cards.h
@@ -22,13 +22,17 @@
22 */ 22 */
23 23
24/* hardware flags */ 24/* hardware flags */
25#define CX18_HW_TUNER (1 << 0) 25#define CX18_HW_TUNER (1 << 0)
26#define CX18_HW_TVEEPROM (1 << 1) 26#define CX18_HW_TVEEPROM (1 << 1)
27#define CX18_HW_CS5345 (1 << 2) 27#define CX18_HW_CS5345 (1 << 2)
28#define CX18_HW_DVB (1 << 3) 28#define CX18_HW_DVB (1 << 3)
29#define CX18_HW_418_AV (1 << 4) 29#define CX18_HW_418_AV (1 << 4)
30#define CX18_HW_GPIO_MUX (1 << 5) 30#define CX18_HW_GPIO_MUX (1 << 5)
31#define CX18_HW_GPIO_RESET_CTRL (1 << 6) 31#define CX18_HW_GPIO_RESET_CTRL (1 << 6)
32#define CX18_HW_Z8F0811_IR_TX_HAUP (1 << 7)
33#define CX18_HW_Z8F0811_IR_RX_HAUP (1 << 8)
34#define CX18_HW_Z8F0811_IR_HAUP (CX18_HW_Z8F0811_IR_RX_HAUP | \
35 CX18_HW_Z8F0811_IR_TX_HAUP)
32 36
33/* video inputs */ 37/* video inputs */
34#define CX18_CARD_INPUT_VID_TUNER 1 38#define CX18_CARD_INPUT_VID_TUNER 1
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 92026e82e10e..dd0224f328ad 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -268,6 +268,20 @@ static void cx18_iounmap(struct cx18 *cx)
268 } 268 }
269} 269}
270 270
271static void cx18_eeprom_dump(struct cx18 *cx, unsigned char *eedata, int len)
272{
273 int i;
274
275 CX18_INFO("eeprom dump:\n");
276 for (i = 0; i < len; i++) {
277 if (0 == (i % 16))
278 CX18_INFO("eeprom %02x:", i);
279 printk(KERN_CONT " %02x", eedata[i]);
280 if (15 == (i % 16))
281 printk(KERN_CONT "\n");
282 }
283}
284
271/* Hauppauge card? get values from tveeprom */ 285/* Hauppauge card? get values from tveeprom */
272void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv) 286void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv)
273{ 287{
@@ -279,8 +293,26 @@ void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv)
279 c.adapter = &cx->i2c_adap[0]; 293 c.adapter = &cx->i2c_adap[0];
280 c.addr = 0xA0 >> 1; 294 c.addr = 0xA0 >> 1;
281 295
282 tveeprom_read(&c, eedata, sizeof(eedata)); 296 memset(tv, 0, sizeof(*tv));
283 tveeprom_hauppauge_analog(&c, tv, eedata); 297 if (tveeprom_read(&c, eedata, sizeof(eedata)))
298 return;
299
300 switch (cx->card->type) {
301 case CX18_CARD_HVR_1600_ESMT:
302 case CX18_CARD_HVR_1600_SAMSUNG:
303 tveeprom_hauppauge_analog(&c, tv, eedata);
304 break;
305 case CX18_CARD_YUAN_MPC718:
306 tv->model = 0x718;
307 cx18_eeprom_dump(cx, eedata, sizeof(eedata));
308 CX18_INFO("eeprom PCI ID: %02x%02x:%02x%02x\n",
309 eedata[2], eedata[1], eedata[4], eedata[3]);
310 break;
311 default:
312 tv->model = 0xffffffff;
313 cx18_eeprom_dump(cx, eedata, sizeof(eedata));
314 break;
315 }
284} 316}
285 317
286static void cx18_process_eeprom(struct cx18 *cx) 318static void cx18_process_eeprom(struct cx18 *cx)
@@ -298,6 +330,11 @@ static void cx18_process_eeprom(struct cx18 *cx)
298 case 74000 ... 74999: 330 case 74000 ... 74999:
299 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); 331 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
300 break; 332 break;
333 case 0x718:
334 return;
335 case 0xffffffff:
336 CX18_INFO("Unknown EEPROM encoding\n");
337 return;
301 case 0: 338 case 0:
302 CX18_ERR("Invalid EEPROM\n"); 339 CX18_ERR("Invalid EEPROM\n");
303 return; 340 return;
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 29969c18949c..04d9c2508b86 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -690,7 +690,7 @@ int cx18_v4l2_open(struct file *filp)
690 int res; 690 int res;
691 struct video_device *video_dev = video_devdata(filp); 691 struct video_device *video_dev = video_devdata(filp);
692 struct cx18_stream *s = video_get_drvdata(video_dev); 692 struct cx18_stream *s = video_get_drvdata(video_dev);
693 struct cx18 *cx = s->cx;; 693 struct cx18 *cx = s->cx;
694 694
695 mutex_lock(&cx->serialize_lock); 695 mutex_lock(&cx->serialize_lock);
696 if (cx18_init_on_first_open(cx)) { 696 if (cx18_init_on_first_open(cx)) {
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index 8591e4fc359f..da395fef50df 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -28,6 +28,7 @@
28#include "cx18-gpio.h" 28#include "cx18-gpio.h"
29#include "cx18-i2c.h" 29#include "cx18-i2c.h"
30#include "cx18-irq.h" 30#include "cx18-irq.h"
31#include <media/ir-kbd-i2c.h>
31 32
32#define CX18_REG_I2C_1_WR 0xf15000 33#define CX18_REG_I2C_1_WR 0xf15000
33#define CX18_REG_I2C_1_RD 0xf15008 34#define CX18_REG_I2C_1_RD 0xf15008
@@ -40,16 +41,20 @@
40#define GETSDL_BIT 0x0008 41#define GETSDL_BIT 0x0008
41 42
42#define CX18_CS5345_I2C_ADDR 0x4c 43#define CX18_CS5345_I2C_ADDR 0x4c
44#define CX18_Z8F0811_IR_TX_I2C_ADDR 0x70
45#define CX18_Z8F0811_IR_RX_I2C_ADDR 0x71
43 46
44/* This array should match the CX18_HW_ defines */ 47/* This array should match the CX18_HW_ defines */
45static const u8 hw_addrs[] = { 48static const u8 hw_addrs[] = {
46 0, /* CX18_HW_TUNER */ 49 0, /* CX18_HW_TUNER */
47 0, /* CX18_HW_TVEEPROM */ 50 0, /* CX18_HW_TVEEPROM */
48 CX18_CS5345_I2C_ADDR, /* CX18_HW_CS5345 */ 51 CX18_CS5345_I2C_ADDR, /* CX18_HW_CS5345 */
49 0, /* CX18_HW_DVB */ 52 0, /* CX18_HW_DVB */
50 0, /* CX18_HW_418_AV */ 53 0, /* CX18_HW_418_AV */
51 0, /* CX18_HW_GPIO_MUX */ 54 0, /* CX18_HW_GPIO_MUX */
52 0, /* CX18_HW_GPIO_RESET_CTRL */ 55 0, /* CX18_HW_GPIO_RESET_CTRL */
56 CX18_Z8F0811_IR_TX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_TX_HAUP */
57 CX18_Z8F0811_IR_RX_I2C_ADDR, /* CX18_HW_Z8F0811_IR_RX_HAUP */
53}; 58};
54 59
55/* This array should match the CX18_HW_ defines */ 60/* This array should match the CX18_HW_ defines */
@@ -62,6 +67,8 @@ static const u8 hw_bus[] = {
62 0, /* CX18_HW_418_AV */ 67 0, /* CX18_HW_418_AV */
63 0, /* CX18_HW_GPIO_MUX */ 68 0, /* CX18_HW_GPIO_MUX */
64 0, /* CX18_HW_GPIO_RESET_CTRL */ 69 0, /* CX18_HW_GPIO_RESET_CTRL */
70 0, /* CX18_HW_Z8F0811_IR_TX_HAUP */
71 0, /* CX18_HW_Z8F0811_IR_RX_HAUP */
65}; 72};
66 73
67/* This array should match the CX18_HW_ defines */ 74/* This array should match the CX18_HW_ defines */
@@ -73,6 +80,8 @@ static const char * const hw_modules[] = {
73 NULL, /* CX18_HW_418_AV */ 80 NULL, /* CX18_HW_418_AV */
74 NULL, /* CX18_HW_GPIO_MUX */ 81 NULL, /* CX18_HW_GPIO_MUX */
75 NULL, /* CX18_HW_GPIO_RESET_CTRL */ 82 NULL, /* CX18_HW_GPIO_RESET_CTRL */
83 NULL, /* CX18_HW_Z8F0811_IR_TX_HAUP */
84 NULL, /* CX18_HW_Z8F0811_IR_RX_HAUP */
76}; 85};
77 86
78/* This array should match the CX18_HW_ defines */ 87/* This array should match the CX18_HW_ defines */
@@ -84,8 +93,38 @@ static const char * const hw_devicenames[] = {
84 "cx23418_AV", 93 "cx23418_AV",
85 "gpio_mux", 94 "gpio_mux",
86 "gpio_reset_ctrl", 95 "gpio_reset_ctrl",
96 "ir_tx_z8f0811_haup",
97 "ir_rx_z8f0811_haup",
87}; 98};
88 99
100static const struct IR_i2c_init_data z8f0811_ir_init_data = {
101 .ir_codes = &ir_codes_hauppauge_new_table,
102 .internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR,
103 .type = IR_TYPE_RC5,
104 .name = "CX23418 Z8F0811 Hauppauge",
105};
106
107static int cx18_i2c_new_ir(struct i2c_adapter *adap, u32 hw, const char *type,
108 u8 addr)
109{
110 struct i2c_board_info info;
111 unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
112
113 memset(&info, 0, sizeof(struct i2c_board_info));
114 strlcpy(info.type, type, I2C_NAME_SIZE);
115
116 /* Our default information for ir-kbd-i2c.c to use */
117 switch (hw) {
118 case CX18_HW_Z8F0811_IR_RX_HAUP:
119 info.platform_data = &z8f0811_ir_init_data;
120 break;
121 default:
122 break;
123 }
124
125 return i2c_new_probed_device(adap, &info, addr_list) == NULL ? -1 : 0;
126}
127
89int cx18_i2c_register(struct cx18 *cx, unsigned idx) 128int cx18_i2c_register(struct cx18 *cx, unsigned idx)
90{ 129{
91 struct v4l2_subdev *sd; 130 struct v4l2_subdev *sd;
@@ -115,11 +154,14 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
115 return sd != NULL ? 0 : -1; 154 return sd != NULL ? 0 : -1;
116 } 155 }
117 156
157 if (hw & CX18_HW_Z8F0811_IR_HAUP)
158 return cx18_i2c_new_ir(adap, hw, type, hw_addrs[idx]);
159
118 /* Is it not an I2C device or one we do not wish to register? */ 160 /* Is it not an I2C device or one we do not wish to register? */
119 if (!hw_addrs[idx]) 161 if (!hw_addrs[idx])
120 return -1; 162 return -1;
121 163
122 /* It's an I2C device other than an analog tuner */ 164 /* It's an I2C device other than an analog tuner or IR chip */
123 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, mod, type, hw_addrs[idx]); 165 sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, mod, type, hw_addrs[idx]);
124 if (sd != NULL) 166 if (sd != NULL)
125 sd->grp_id = hw; 167 sd->grp_id = hw;
@@ -190,7 +232,6 @@ static int cx18_getsda(void *data)
190/* template for i2c-bit-algo */ 232/* template for i2c-bit-algo */
191static struct i2c_adapter cx18_i2c_adap_template = { 233static struct i2c_adapter cx18_i2c_adap_template = {
192 .name = "cx18 i2c driver", 234 .name = "cx18 i2c driver",
193 .id = I2C_HW_B_CX2341X,
194 .algo = NULL, /* set by i2c-algo-bit */ 235 .algo = NULL, /* set by i2c-algo-bit */
195 .algo_data = NULL, /* filled from template */ 236 .algo_data = NULL, /* filled from template */
196 .owner = THIS_MODULE, 237 .owner = THIS_MODULE,
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index d7b1921e6666..fc76e4d6ffa7 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -605,7 +605,7 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
605 if (ret) 605 if (ret)
606 return ret; 606 return ret;
607 607
608 if (inp < 0 || inp >= cx->nof_inputs) 608 if (inp >= cx->nof_inputs)
609 return -EINVAL; 609 return -EINVAL;
610 610
611 if (inp == cx->active_input) { 611 if (inp == cx->active_input) {
diff --git a/drivers/media/video/cx231xx/cx231xx-conf-reg.h b/drivers/media/video/cx231xx/cx231xx-conf-reg.h
index a6f398a175c5..31a8759f6e54 100644
--- a/drivers/media/video/cx231xx/cx231xx-conf-reg.h
+++ b/drivers/media/video/cx231xx/cx231xx-conf-reg.h
@@ -60,10 +60,10 @@
60#define PWR_RESETOUT_EN 0x100 /* bit8 */ 60#define PWR_RESETOUT_EN 0x100 /* bit8 */
61 61
62enum AV_MODE{ 62enum AV_MODE{
63 POLARIS_AVMODE_DEFAULT = 0, 63 POLARIS_AVMODE_DEFAULT = 0,
64 POLARIS_AVMODE_DIGITAL = 0x10, 64 POLARIS_AVMODE_DIGITAL = 0x10,
65 POLARIS_AVMODE_ANALOGT_TV = 0x20, 65 POLARIS_AVMODE_ANALOGT_TV = 0x20,
66 POLARIS_AVMODE_ENXTERNAL_AV = 0x30, 66 POLARIS_AVMODE_ENXTERNAL_AV = 0x30,
67 67
68}; 68};
69 69
diff --git a/drivers/media/video/cx231xx/cx231xx-i2c.c b/drivers/media/video/cx231xx/cx231xx-i2c.c
index 33219dc4d649..58d9cc0867b9 100644
--- a/drivers/media/video/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/video/cx231xx/cx231xx-i2c.c
@@ -432,7 +432,6 @@ static struct i2c_algorithm cx231xx_algo = {
432static struct i2c_adapter cx231xx_adap_template = { 432static struct i2c_adapter cx231xx_adap_template = {
433 .owner = THIS_MODULE, 433 .owner = THIS_MODULE,
434 .name = "cx231xx", 434 .name = "cx231xx",
435 .id = I2C_HW_B_CX231XX,
436 .algo = &cx231xx_algo, 435 .algo = &cx231xx_algo,
437}; 436};
438 437
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index 609bae6098d3..36503725d973 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -923,8 +923,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
923 923
924 f->fmt.pix.width = dev->width; 924 f->fmt.pix.width = dev->width;
925 f->fmt.pix.height = dev->height; 925 f->fmt.pix.height = dev->height;
926 f->fmt.pix.pixelformat = dev->format->fourcc;; 926 f->fmt.pix.pixelformat = dev->format->fourcc;
927 f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3;; 927 f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3;
928 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; 928 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height;
929 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 929 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
930 930
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h
index a0f823ac6b8d..64e2ddd3c401 100644
--- a/drivers/media/video/cx231xx/cx231xx.h
+++ b/drivers/media/video/cx231xx/cx231xx.h
@@ -282,7 +282,7 @@ struct cx231xx_board {
282 282
283 struct cx231xx_input input[MAX_CX231XX_INPUT]; 283 struct cx231xx_input input[MAX_CX231XX_INPUT];
284 struct cx231xx_input radio; 284 struct cx231xx_input radio;
285 IR_KEYTAB_TYPE *ir_codes; 285 struct ir_scancode_table *ir_codes;
286}; 286};
287 287
288/* device states */ 288/* device states */
diff --git a/drivers/media/video/cx23885/cimax2.c b/drivers/media/video/cx23885/cimax2.c
index 08582e58bdbf..0316257b7345 100644
--- a/drivers/media/video/cx23885/cimax2.c
+++ b/drivers/media/video/cx23885/cimax2.c
@@ -443,6 +443,7 @@ int netup_ci_init(struct cx23885_tsport *port)
443 goto err; 443 goto err;
444 444
445 INIT_WORK(&state->work, netup_read_ci_status); 445 INIT_WORK(&state->work, netup_read_ci_status);
446 schedule_work(&state->work);
446 447
447 ci_dbg_print("%s: CI initialized!\n", __func__); 448 ci_dbg_print("%s: CI initialized!\n", __func__);
448 449
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 1a1048b18f70..6c3b51ce3372 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -630,6 +630,39 @@ int mc417_memory_read(struct cx23885_dev *dev, u32 address, u32 *value)
630 return retval; 630 return retval;
631} 631}
632 632
633void mc417_gpio_set(struct cx23885_dev *dev, u32 mask)
634{
635 u32 val;
636
637 /* Set the gpio value */
638 mc417_register_read(dev, 0x900C, &val);
639 val |= (mask & 0x000ffff);
640 mc417_register_write(dev, 0x900C, val);
641}
642
643void mc417_gpio_clear(struct cx23885_dev *dev, u32 mask)
644{
645 u32 val;
646
647 /* Clear the gpio value */
648 mc417_register_read(dev, 0x900C, &val);
649 val &= ~(mask & 0x0000ffff);
650 mc417_register_write(dev, 0x900C, val);
651}
652
653void mc417_gpio_enable(struct cx23885_dev *dev, u32 mask, int asoutput)
654{
655 u32 val;
656
657 /* Enable GPIO direction bits */
658 mc417_register_read(dev, 0x9020, &val);
659 if (asoutput)
660 val |= (mask & 0x0000ffff);
661 else
662 val &= ~(mask & 0x0000ffff);
663
664 mc417_register_write(dev, 0x9020, val);
665}
633/* ------------------------------------------------------------------ */ 666/* ------------------------------------------------------------------ */
634 667
635/* MPEG encoder API */ 668/* MPEG encoder API */
@@ -955,25 +988,8 @@ static int cx23885_load_firmware(struct cx23885_dev *dev)
955 retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS, 988 retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS,
956 IVTV_CMD_HW_BLOCKS_RST); 989 IVTV_CMD_HW_BLOCKS_RST);
957 990
958 /* Restore GPIO settings, make sure EIO14 is enabled as an output. */ 991 /* F/W power up disturbs the GPIOs, restore state */
959 dprintk(2, "%s: GPIO output EIO 0-15 was = 0x%x\n", 992 retval |= mc417_register_write(dev, 0x9020, gpio_output);
960 __func__, gpio_output);
961 /* Power-up seems to have GPIOs AFU. This was causing digital side
962 * to fail at power-up. Seems GPIOs should be set to 0x10ff0411 at
963 * power-up.
964 * gpio_output |= (1<<14);
965 */
966 /* Note: GPIO14 is specific to the HVR1800 here */
967 gpio_output = 0x10ff0411 | (1<<14);
968 retval |= mc417_register_write(dev, 0x9020, gpio_output | (1<<14));
969 dprintk(2, "%s: GPIO output EIO 0-15 now = 0x%x\n",
970 __func__, gpio_output);
971
972 dprintk(1, "%s: GPIO value EIO 0-15 was = 0x%x\n",
973 __func__, value);
974 value |= (1<<14);
975 dprintk(1, "%s: GPIO value EIO 0-15 now = 0x%x\n",
976 __func__, value);
977 retval |= mc417_register_write(dev, 0x900C, value); 993 retval |= mc417_register_write(dev, 0x900C, value);
978 994
979 retval |= mc417_register_read(dev, IVTV_REG_VPU, &value); 995 retval |= mc417_register_read(dev, IVTV_REG_VPU, &value);
@@ -1788,9 +1804,6 @@ int cx23885_417_register(struct cx23885_dev *dev)
1788 return err; 1804 return err;
1789 } 1805 }
1790 1806
1791 /* Initialize MC417 registers */
1792 cx23885_mc417_init(dev);
1793
1794 printk(KERN_INFO "%s: registered device video%d [mpeg]\n", 1807 printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
1795 dev->name, dev->v4l_device->num); 1808 dev->name, dev->v4l_device->num);
1796 1809
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index ce29b5e34a11..3143d85ef31d 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -201,6 +201,15 @@ struct cx23885_board cx23885_boards[] = {
201 .name = "Mygica X8506 DMB-TH", 201 .name = "Mygica X8506 DMB-TH",
202 .portb = CX23885_MPEG_DVB, 202 .portb = CX23885_MPEG_DVB,
203 }, 203 },
204 [CX23885_BOARD_MAGICPRO_PROHDTVE2] = {
205 .name = "Magic-Pro ProHDTV Extreme 2",
206 .portb = CX23885_MPEG_DVB,
207 },
208 [CX23885_BOARD_HAUPPAUGE_HVR1850] = {
209 .name = "Hauppauge WinTV-HVR1850",
210 .portb = CX23885_MPEG_ENCODER,
211 .portc = CX23885_MPEG_DVB,
212 },
204}; 213};
205const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); 214const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
206 215
@@ -324,6 +333,14 @@ struct cx23885_subid cx23885_subids[] = {
324 .subvendor = 0x14f1, 333 .subvendor = 0x14f1,
325 .subdevice = 0x8651, 334 .subdevice = 0x8651,
326 .card = CX23885_BOARD_MYGICA_X8506, 335 .card = CX23885_BOARD_MYGICA_X8506,
336 }, {
337 .subvendor = 0x14f1,
338 .subdevice = 0x8657,
339 .card = CX23885_BOARD_MAGICPRO_PROHDTVE2,
340 }, {
341 .subvendor = 0x0070,
342 .subdevice = 0x8541,
343 .card = CX23885_BOARD_HAUPPAUGE_HVR1850,
327 }, 344 },
328}; 345};
329const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); 346const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -483,8 +500,13 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
483 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height) 500 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
484 * DVB-T and MPEG2 HW Encoder */ 501 * DVB-T and MPEG2 HW Encoder */
485 break; 502 break;
503 case 85021:
504 /* WinTV-HVR1850 (PCIe, OEM, RCA in, IR, FM,
505 Dual channel ATSC and MPEG2 HW Encoder */
506 break;
486 default: 507 default:
487 printk(KERN_WARNING "%s: warning: unknown hauppauge model #%d\n", 508 printk(KERN_WARNING "%s: warning: "
509 "unknown hauppauge model #%d\n",
488 dev->name, tv.model); 510 dev->name, tv.model);
489 break; 511 break;
490 } 512 }
@@ -574,13 +596,23 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
574 /* CX23417 GPIO's */ 596 /* CX23417 GPIO's */
575 /* EIO15 Zilog Reset */ 597 /* EIO15 Zilog Reset */
576 /* EIO14 S5H1409/CX24227 Reset */ 598 /* EIO14 S5H1409/CX24227 Reset */
599 mc417_gpio_enable(dev, GPIO_15 | GPIO_14, 1);
600
601 /* Put the demod into reset and protect the eeprom */
602 mc417_gpio_clear(dev, GPIO_15 | GPIO_14);
603 mdelay(100);
604
605 /* Bring the demod and blaster out of reset */
606 mc417_gpio_set(dev, GPIO_15 | GPIO_14);
607 mdelay(100);
577 608
578 /* Force the TDA8295A into reset and back */ 609 /* Force the TDA8295A into reset and back */
579 cx_set(GP0_IO, 0x00040004); 610 cx23885_gpio_enable(dev, GPIO_2, 1);
611 cx23885_gpio_set(dev, GPIO_2);
580 mdelay(20); 612 mdelay(20);
581 cx_clear(GP0_IO, 0x00000004); 613 cx23885_gpio_clear(dev, GPIO_2);
582 mdelay(20); 614 mdelay(20);
583 cx_set(GP0_IO, 0x00040004); 615 cx23885_gpio_set(dev, GPIO_2);
584 mdelay(20); 616 mdelay(20);
585 break; 617 break;
586 case CX23885_BOARD_HAUPPAUGE_HVR1200: 618 case CX23885_BOARD_HAUPPAUGE_HVR1200:
@@ -715,14 +747,45 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
715 cx23885_gpio_set(dev, GPIO_9); 747 cx23885_gpio_set(dev, GPIO_9);
716 break; 748 break;
717 case CX23885_BOARD_MYGICA_X8506: 749 case CX23885_BOARD_MYGICA_X8506:
750 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
718 /* GPIO-1 reset XC5000 */ 751 /* GPIO-1 reset XC5000 */
719 /* GPIO-2 reset LGS8GL5 */ 752 /* GPIO-2 reset LGS8GL5 / LGS8G75 */
720 cx_set(GP0_IO, 0x00060000); 753 cx_set(GP0_IO, 0x00060000);
721 cx_clear(GP0_IO, 0x00000006); 754 cx_clear(GP0_IO, 0x00000006);
722 mdelay(100); 755 mdelay(100);
723 cx_set(GP0_IO, 0x00060006); 756 cx_set(GP0_IO, 0x00060006);
724 mdelay(100); 757 mdelay(100);
725 break; 758 break;
759 case CX23885_BOARD_HAUPPAUGE_HVR1850:
760 /* GPIO-0 656_CLK */
761 /* GPIO-1 656_D0 */
762 /* GPIO-2 Wake# */
763 /* GPIO-3-10 cx23417 data0-7 */
764 /* GPIO-11-14 cx23417 addr0-3 */
765 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
766 /* GPIO-19 IR_RX */
767 /* GPIO-20 C_IR_TX */
768 /* GPIO-21 I2S DAT */
769 /* GPIO-22 I2S WCLK */
770 /* GPIO-23 I2S BCLK */
771 /* ALT GPIO: EXP GPIO LATCH */
772
773 /* CX23417 GPIO's */
774 /* GPIO-14 S5H1411/CX24228 Reset */
775 /* GPIO-13 EEPROM write protect */
776 mc417_gpio_enable(dev, GPIO_14 | GPIO_13, 1);
777
778 /* Put the demod into reset and protect the eeprom */
779 mc417_gpio_clear(dev, GPIO_14 | GPIO_13);
780 mdelay(100);
781
782 /* Bring the demod out of reset */
783 mc417_gpio_set(dev, GPIO_14);
784 mdelay(100);
785
786 /* CX24228 GPIO */
787 /* Connected to IF / Mux */
788 break;
726 } 789 }
727} 790}
728 791
@@ -739,6 +802,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
739 case CX23885_BOARD_HAUPPAUGE_HVR1275: 802 case CX23885_BOARD_HAUPPAUGE_HVR1275:
740 case CX23885_BOARD_HAUPPAUGE_HVR1255: 803 case CX23885_BOARD_HAUPPAUGE_HVR1255:
741 case CX23885_BOARD_HAUPPAUGE_HVR1210: 804 case CX23885_BOARD_HAUPPAUGE_HVR1210:
805 case CX23885_BOARD_HAUPPAUGE_HVR1850:
742 /* FIXME: Implement me */ 806 /* FIXME: Implement me */
743 break; 807 break;
744 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: 808 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
@@ -778,6 +842,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
778 case CX23885_BOARD_HAUPPAUGE_HVR1275: 842 case CX23885_BOARD_HAUPPAUGE_HVR1275:
779 case CX23885_BOARD_HAUPPAUGE_HVR1255: 843 case CX23885_BOARD_HAUPPAUGE_HVR1255:
780 case CX23885_BOARD_HAUPPAUGE_HVR1210: 844 case CX23885_BOARD_HAUPPAUGE_HVR1210:
845 case CX23885_BOARD_HAUPPAUGE_HVR1850:
781 if (dev->i2c_bus[0].i2c_rc == 0) 846 if (dev->i2c_bus[0].i2c_rc == 0)
782 hauppauge_eeprom(dev, eeprom+0xc0); 847 hauppauge_eeprom(dev, eeprom+0xc0);
783 break; 848 break;
@@ -827,6 +892,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
827 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; 892 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
828 break; 893 break;
829 case CX23885_BOARD_MYGICA_X8506: 894 case CX23885_BOARD_MYGICA_X8506:
895 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
830 ts1->gen_ctrl_val = 0x5; /* Parallel */ 896 ts1->gen_ctrl_val = 0x5; /* Parallel */
831 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ 897 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
832 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; 898 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
@@ -844,6 +910,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
844 case CX23885_BOARD_HAUPPAUGE_HVR1275: 910 case CX23885_BOARD_HAUPPAUGE_HVR1275:
845 case CX23885_BOARD_HAUPPAUGE_HVR1255: 911 case CX23885_BOARD_HAUPPAUGE_HVR1255:
846 case CX23885_BOARD_HAUPPAUGE_HVR1210: 912 case CX23885_BOARD_HAUPPAUGE_HVR1210:
913 case CX23885_BOARD_HAUPPAUGE_HVR1850:
847 default: 914 default:
848 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */ 915 ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */
849 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ 916 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index bf7bb1c412fb..40d438d7234d 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -713,12 +713,26 @@ static void cx23885_dev_checkrevision(struct cx23885_dev *dev)
713 dev->hwrevision = 0xa1; 713 dev->hwrevision = 0xa1;
714 break; 714 break;
715 case 0x02: 715 case 0x02:
716 /* CX23885-13Z */ 716 /* CX23885-13Z/14Z */
717 dev->hwrevision = 0xb0; 717 dev->hwrevision = 0xb0;
718 break; 718 break;
719 case 0x03: 719 case 0x03:
720 /* CX23888-22Z */ 720 if (dev->pci->device == 0x8880) {
721 dev->hwrevision = 0xc0; 721 /* CX23888-21Z/22Z */
722 dev->hwrevision = 0xc0;
723 } else {
724 /* CX23885-14Z */
725 dev->hwrevision = 0xa4;
726 }
727 break;
728 case 0x04:
729 if (dev->pci->device == 0x8880) {
730 /* CX23888-31Z */
731 dev->hwrevision = 0xd0;
732 } else {
733 /* CX23885-15Z, CX23888-31Z */
734 dev->hwrevision = 0xa5;
735 }
722 break; 736 break;
723 case 0x0e: 737 case 0x0e:
724 /* CX23887-15Z */ 738 /* CX23887-15Z */
@@ -756,6 +770,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
756 770
757 /* Configure the internal memory */ 771 /* Configure the internal memory */
758 if (dev->pci->device == 0x8880) { 772 if (dev->pci->device == 0x8880) {
773 /* Could be 887 or 888, assume a default */
759 dev->bridge = CX23885_BRIDGE_887; 774 dev->bridge = CX23885_BRIDGE_887;
760 /* Apply a sensible clock frequency for the PCIe bridge */ 775 /* Apply a sensible clock frequency for the PCIe bridge */
761 dev->clk_freq = 25000000; 776 dev->clk_freq = 25000000;
@@ -868,6 +883,14 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
868 dprintk(1, "%s() radio_type = 0x%x radio_addr = 0x%x\n", 883 dprintk(1, "%s() radio_type = 0x%x radio_addr = 0x%x\n",
869 __func__, dev->radio_type, dev->radio_addr); 884 __func__, dev->radio_type, dev->radio_addr);
870 885
886 /* The cx23417 encoder has GPIO's that need to be initialised
887 * before DVB, so that demodulators and tuners are out of
888 * reset before DVB uses them.
889 */
890 if ((cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) ||
891 (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER))
892 cx23885_mc417_init(dev);
893
871 /* init hardware */ 894 /* init hardware */
872 cx23885_reset(dev); 895 cx23885_reset(dev);
873 896
@@ -1250,6 +1273,7 @@ static int cx23885_start_dma(struct cx23885_tsport *port,
1250 switch (dev->bridge) { 1273 switch (dev->bridge) {
1251 case CX23885_BRIDGE_885: 1274 case CX23885_BRIDGE_885:
1252 case CX23885_BRIDGE_887: 1275 case CX23885_BRIDGE_887:
1276 case CX23885_BRIDGE_888:
1253 /* enable irqs */ 1277 /* enable irqs */
1254 dprintk(1, "%s() enabling TS int's and DMA\n", __func__); 1278 dprintk(1, "%s() enabling TS int's and DMA\n", __func__);
1255 cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); 1279 cx_set(port->reg_ts_int_msk, port->ts_int_msk_val);
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index 86ac529e62be..022fad798fc2 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -396,7 +396,7 @@ static struct stv0900_reg stv0900_ts_regs[] = {
396 396
397static struct stv0900_config netup_stv0900_config = { 397static struct stv0900_config netup_stv0900_config = {
398 .demod_address = 0x68, 398 .demod_address = 0x68,
399 .xtal = 27000000, 399 .xtal = 8000000,
400 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 400 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
401 .diseqc_mode = 2,/* 2/3 PWM */ 401 .diseqc_mode = 2,/* 2/3 PWM */
402 .ts_config_regs = stv0900_ts_regs, 402 .ts_config_regs = stv0900_ts_regs,
@@ -408,14 +408,14 @@ static struct stv0900_config netup_stv0900_config = {
408 408
409static struct stv6110_config netup_stv6110_tunerconfig_a = { 409static struct stv6110_config netup_stv6110_tunerconfig_a = {
410 .i2c_address = 0x60, 410 .i2c_address = 0x60,
411 .mclk = 27000000, 411 .mclk = 16000000,
412 .iq_wiring = 0, 412 .clk_div = 1,
413}; 413};
414 414
415static struct stv6110_config netup_stv6110_tunerconfig_b = { 415static struct stv6110_config netup_stv6110_tunerconfig_b = {
416 .i2c_address = 0x63, 416 .i2c_address = 0x63,
417 .mclk = 27000000, 417 .mclk = 16000000,
418 .iq_wiring = 1, 418 .clk_div = 1,
419}; 419};
420 420
421static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 421static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
@@ -487,6 +487,26 @@ static int cx23885_dvb_set_frontend(struct dvb_frontend *fe,
487 port->set_frontend_save(fe, param) : -ENODEV; 487 port->set_frontend_save(fe, param) : -ENODEV;
488} 488}
489 489
490static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
491 .prod = LGS8GXX_PROD_LGS8G75,
492 .demod_address = 0x19,
493 .serial_ts = 0,
494 .ts_clk_pol = 1,
495 .ts_clk_gated = 1,
496 .if_clk_freq = 30400, /* 30.4 MHz */
497 .if_freq = 6500, /* 6.50 MHz */
498 .if_neg_center = 1,
499 .ext_adc = 0,
500 .adc_signed = 1,
501 .adc_vpp = 2, /* 1.6 Vpp */
502 .if_neg_edge = 1,
503};
504
505static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
506 .i2c_address = 0x61,
507 .if_khz = 6500,
508};
509
490static int dvb_register(struct cx23885_tsport *port) 510static int dvb_register(struct cx23885_tsport *port)
491{ 511{
492 struct cx23885_dev *dev = port->dev; 512 struct cx23885_dev *dev = port->dev;
@@ -833,6 +853,30 @@ static int dvb_register(struct cx23885_tsport *port)
833 &mygica_x8506_xc5000_config); 853 &mygica_x8506_xc5000_config);
834 } 854 }
835 break; 855 break;
856 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
857 i2c_bus = &dev->i2c_bus[0];
858 i2c_bus2 = &dev->i2c_bus[1];
859 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
860 &magicpro_prohdtve2_lgs8g75_config,
861 &i2c_bus->i2c_adap);
862 if (fe0->dvb.frontend != NULL) {
863 dvb_attach(xc5000_attach,
864 fe0->dvb.frontend,
865 &i2c_bus2->i2c_adap,
866 &magicpro_prohdtve2_xc5000_config);
867 }
868 break;
869 case CX23885_BOARD_HAUPPAUGE_HVR1850:
870 i2c_bus = &dev->i2c_bus[0];
871 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
872 &hcw_s5h1411_config,
873 &i2c_bus->i2c_adap);
874 if (fe0->dvb.frontend != NULL)
875 dvb_attach(tda18271_attach, fe0->dvb.frontend,
876 0x60, &dev->i2c_bus[0].i2c_adap,
877 &hauppauge_tda18271_config);
878 break;
879
836 default: 880 default:
837 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 881 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
838 " isn't supported yet\n", 882 " isn't supported yet\n",
diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c
index 384dec34134f..4172cb387420 100644
--- a/drivers/media/video/cx23885/cx23885-i2c.c
+++ b/drivers/media/video/cx23885/cx23885-i2c.c
@@ -283,7 +283,6 @@ static struct i2c_algorithm cx23885_i2c_algo_template = {
283static struct i2c_adapter cx23885_i2c_adap_template = { 283static struct i2c_adapter cx23885_i2c_adap_template = {
284 .name = "cx23885", 284 .name = "cx23885",
285 .owner = THIS_MODULE, 285 .owner = THIS_MODULE,
286 .id = I2C_HW_B_CX23885,
287 .algo = &cx23885_i2c_algo_template, 286 .algo = &cx23885_i2c_algo_template,
288}; 287};
289 288
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index 214a55e943b7..86f26947bb78 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -76,6 +76,8 @@
76#define CX23885_BOARD_HAUPPAUGE_HVR1255 20 76#define CX23885_BOARD_HAUPPAUGE_HVR1255 20
77#define CX23885_BOARD_HAUPPAUGE_HVR1210 21 77#define CX23885_BOARD_HAUPPAUGE_HVR1210 21
78#define CX23885_BOARD_MYGICA_X8506 22 78#define CX23885_BOARD_MYGICA_X8506 22
79#define CX23885_BOARD_MAGICPRO_PROHDTVE2 23
80#define CX23885_BOARD_HAUPPAUGE_HVR1850 24
79 81
80#define GPIO_0 0x00000001 82#define GPIO_0 0x00000001
81#define GPIO_1 0x00000002 83#define GPIO_1 0x00000002
@@ -87,6 +89,12 @@
87#define GPIO_7 0x00000080 89#define GPIO_7 0x00000080
88#define GPIO_8 0x00000100 90#define GPIO_8 0x00000100
89#define GPIO_9 0x00000200 91#define GPIO_9 0x00000200
92#define GPIO_10 0x00000400
93#define GPIO_11 0x00000800
94#define GPIO_12 0x00001000
95#define GPIO_13 0x00002000
96#define GPIO_14 0x00004000
97#define GPIO_15 0x00008000
90 98
91/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */ 99/* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */
92#define CX23885_NORMS (\ 100#define CX23885_NORMS (\
@@ -331,6 +339,7 @@ struct cx23885_dev {
331 CX23885_BRIDGE_UNDEFINED = 0, 339 CX23885_BRIDGE_UNDEFINED = 0,
332 CX23885_BRIDGE_885 = 885, 340 CX23885_BRIDGE_885 = 885,
333 CX23885_BRIDGE_887 = 887, 341 CX23885_BRIDGE_887 = 887,
342 CX23885_BRIDGE_888 = 888,
334 } bridge; 343 } bridge;
335 344
336 /* Analog video */ 345 /* Analog video */
@@ -395,7 +404,7 @@ struct sram_channel {
395 u32 cmds_start; 404 u32 cmds_start;
396 u32 ctrl_start; 405 u32 ctrl_start;
397 u32 cdt; 406 u32 cdt;
398 u32 fifo_start;; 407 u32 fifo_start;
399 u32 fifo_size; 408 u32 fifo_size;
400 u32 ptr1_reg; 409 u32 ptr1_reg;
401 u32 ptr2_reg; 410 u32 ptr2_reg;
@@ -504,6 +513,9 @@ extern void cx23885_417_check_encoder(struct cx23885_dev *dev);
504extern void cx23885_mc417_init(struct cx23885_dev *dev); 513extern void cx23885_mc417_init(struct cx23885_dev *dev);
505extern int mc417_memory_read(struct cx23885_dev *dev, u32 address, u32 *value); 514extern int mc417_memory_read(struct cx23885_dev *dev, u32 address, u32 *value);
506extern int mc417_memory_write(struct cx23885_dev *dev, u32 address, u32 value); 515extern int mc417_memory_write(struct cx23885_dev *dev, u32 address, u32 value);
516extern void mc417_gpio_set(struct cx23885_dev *dev, u32 mask);
517extern void mc417_gpio_clear(struct cx23885_dev *dev, u32 mask);
518extern void mc417_gpio_enable(struct cx23885_dev *dev, u32 mask, int asoutput);
507 519
508 520
509/* ----------------------------------------------------------- */ 521/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 0be51b65f098..1aeaf18a9bea 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -321,6 +321,15 @@ static void cx23885_initialize(struct i2c_client *client)
321 /* Select AFE clock pad output source */ 321 /* Select AFE clock pad output source */
322 cx25840_write(client, 0x144, 0x05); 322 cx25840_write(client, 0x144, 0x05);
323 323
324 /* Drive GPIO2 direction and values for HVR1700
325 * where an onboard mux selects the output of demodulator
326 * vs the 417. Failure to set this results in no DTV.
327 * It's safe to set this across all Hauppauge boards
328 * currently, regardless of the board type.
329 */
330 cx25840_write(client, 0x160, 0x1d);
331 cx25840_write(client, 0x164, 0x00);
332
324 /* Do the firmware load in a work handler to prevent. 333 /* Do the firmware load in a work handler to prevent.
325 Otherwise the kernel is blocked waiting for the 334 Otherwise the kernel is blocked waiting for the
326 bit-banging i2c interface to finish uploading the 335 bit-banging i2c interface to finish uploading the
@@ -1578,12 +1587,6 @@ static int cx25840_probe(struct i2c_client *client,
1578 state->id = id; 1587 state->id = id;
1579 state->rev = device_id; 1588 state->rev = device_id;
1580 1589
1581 if (state->is_cx23885) {
1582 /* Drive GPIO2 direction and values */
1583 cx25840_write(client, 0x160, 0x1d);
1584 cx25840_write(client, 0x164, 0x00);
1585 }
1586
1587 return 0; 1590 return 0;
1588} 1591}
1589 1592
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
index 0df53b0d75d9..1f483c1d0dbe 100644
--- a/drivers/media/video/cx25840/cx25840-firmware.c
+++ b/drivers/media/video/cx25840/cx25840-firmware.c
@@ -23,10 +23,6 @@
23 23
24#include "cx25840-core.h" 24#include "cx25840-core.h"
25 25
26#define FWFILE "v4l-cx25840.fw"
27#define FWFILE_CX23885 "v4l-cx23885-avcore-01.fw"
28#define FWFILE_CX231XX "v4l-cx231xx-avcore-01.fw"
29
30/* 26/*
31 * Mike Isely <isely@pobox.com> - The FWSEND parameter controls the 27 * Mike Isely <isely@pobox.com> - The FWSEND parameter controls the
32 * size of the firmware chunks sent down the I2C bus to the chip. 28 * size of the firmware chunks sent down the I2C bus to the chip.
@@ -40,11 +36,11 @@
40 36
41#define FWDEV(x) &((x)->dev) 37#define FWDEV(x) &((x)->dev)
42 38
43static char *firmware = FWFILE; 39static char *firmware = "";
44 40
45module_param(firmware, charp, 0444); 41module_param(firmware, charp, 0444);
46 42
47MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]"); 43MODULE_PARM_DESC(firmware, "Firmware image to load");
48 44
49static void start_fw_load(struct i2c_client *client) 45static void start_fw_load(struct i2c_client *client)
50{ 46{
@@ -65,6 +61,19 @@ static void end_fw_load(struct i2c_client *client)
65 cx25840_write(client, 0x803, 0x03); 61 cx25840_write(client, 0x803, 0x03);
66} 62}
67 63
64static const char *get_fw_name(struct i2c_client *client)
65{
66 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
67
68 if (firmware[0])
69 return firmware;
70 if (state->is_cx23885)
71 return "v4l-cx23885-avcore-01.fw";
72 if (state->is_cx231xx)
73 return "v4l-cx231xx-avcore-01.fw";
74 return "v4l-cx25840.fw";
75}
76
68static int check_fw_load(struct i2c_client *client, int size) 77static int check_fw_load(struct i2c_client *client, int size)
69{ 78{
70 /* DL_ADDR_HB DL_ADDR_LB */ 79 /* DL_ADDR_HB DL_ADDR_LB */
@@ -72,11 +81,13 @@ static int check_fw_load(struct i2c_client *client, int size)
72 s |= cx25840_read(client, 0x800); 81 s |= cx25840_read(client, 0x800);
73 82
74 if (size != s) { 83 if (size != s) {
75 v4l_err(client, "firmware %s load failed\n", firmware); 84 v4l_err(client, "firmware %s load failed\n",
85 get_fw_name(client));
76 return -EINVAL; 86 return -EINVAL;
77 } 87 }
78 88
79 v4l_info(client, "loaded %s firmware (%d bytes)\n", firmware, size); 89 v4l_info(client, "loaded %s firmware (%d bytes)\n",
90 get_fw_name(client), size);
80 return 0; 91 return 0;
81} 92}
82 93
@@ -96,21 +107,24 @@ int cx25840_loadfw(struct i2c_client *client)
96 const struct firmware *fw = NULL; 107 const struct firmware *fw = NULL;
97 u8 buffer[FWSEND]; 108 u8 buffer[FWSEND];
98 const u8 *ptr; 109 const u8 *ptr;
110 const char *fwname = get_fw_name(client);
99 int size, retval; 111 int size, retval;
100 int MAX_BUF_SIZE = FWSEND; 112 int MAX_BUF_SIZE = FWSEND;
113 u32 gpio_oe = 0, gpio_da = 0;
101 114
102 if (state->is_cx23885) 115 if (state->is_cx23885) {
103 firmware = FWFILE_CX23885; 116 /* Preserve the GPIO OE and output bits */
104 else if (state->is_cx231xx) 117 gpio_oe = cx25840_read(client, 0x160);
105 firmware = FWFILE_CX231XX; 118 gpio_da = cx25840_read(client, 0x164);
119 }
106 120
107 if ((state->is_cx231xx) && MAX_BUF_SIZE > 16) { 121 if ((state->is_cx231xx) && MAX_BUF_SIZE > 16) {
108 v4l_err(client, " Firmware download size changed to 16 bytes max length\n"); 122 v4l_err(client, " Firmware download size changed to 16 bytes max length\n");
109 MAX_BUF_SIZE = 16; /* cx231xx cannot accept more than 16 bytes at a time */ 123 MAX_BUF_SIZE = 16; /* cx231xx cannot accept more than 16 bytes at a time */
110 } 124 }
111 125
112 if (request_firmware(&fw, firmware, FWDEV(client)) != 0) { 126 if (request_firmware(&fw, fwname, FWDEV(client)) != 0) {
113 v4l_err(client, "unable to open firmware %s\n", firmware); 127 v4l_err(client, "unable to open firmware %s\n", fwname);
114 return -EINVAL; 128 return -EINVAL;
115 } 129 }
116 130
@@ -142,5 +156,11 @@ int cx25840_loadfw(struct i2c_client *client)
142 size = fw->size; 156 size = fw->size;
143 release_firmware(fw); 157 release_firmware(fw);
144 158
159 if (state->is_cx23885) {
160 /* Restore GPIO configuration after f/w load */
161 cx25840_write(client, 0x160, gpio_oe);
162 cx25840_write(client, 0x164, gpio_da);
163 }
164
145 return check_fw_load(client, size); 165 return check_fw_load(client, size);
146} 166}
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index 39465301ec94..e5f07fbd5a35 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1283,6 +1283,51 @@ static const struct cx88_board cx88_boards[] = {
1283 }, 1283 },
1284 .mpeg = CX88_MPEG_DVB, 1284 .mpeg = CX88_MPEG_DVB,
1285 }, 1285 },
1286 [CX88_BOARD_WINFAST_DTV2000H_J] = {
1287 .name = "WinFast DTV2000 H rev. J",
1288 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3,
1289 .radio_type = UNSET,
1290 .tuner_addr = ADDR_UNSET,
1291 .radio_addr = ADDR_UNSET,
1292 .tda9887_conf = TDA9887_PRESENT,
1293 .input = {{
1294 .type = CX88_VMUX_TELEVISION,
1295 .vmux = 0,
1296 .gpio0 = 0x00017300,
1297 .gpio1 = 0x00008207,
1298 .gpio2 = 0x00000000,
1299 .gpio3 = 0x02000000,
1300 },{
1301 .type = CX88_VMUX_TELEVISION,
1302 .vmux = 0,
1303 .gpio0 = 0x00018300,
1304 .gpio1 = 0x0000f207,
1305 .gpio2 = 0x00017304,
1306 .gpio3 = 0x02000000,
1307 },{
1308 .type = CX88_VMUX_COMPOSITE1,
1309 .vmux = 1,
1310 .gpio0 = 0x00018301,
1311 .gpio1 = 0x0000f207,
1312 .gpio2 = 0x00017304,
1313 .gpio3 = 0x02000000,
1314 },{
1315 .type = CX88_VMUX_SVIDEO,
1316 .vmux = 2,
1317 .gpio0 = 0x00018301,
1318 .gpio1 = 0x0000f207,
1319 .gpio2 = 0x00017304,
1320 .gpio3 = 0x02000000,
1321 }},
1322 .radio = {
1323 .type = CX88_RADIO,
1324 .gpio0 = 0x00015702,
1325 .gpio1 = 0x0000f207,
1326 .gpio2 = 0x00015702,
1327 .gpio3 = 0x02000000,
1328 },
1329 .mpeg = CX88_MPEG_DVB,
1330 },
1286 [CX88_BOARD_GENIATECH_DVBS] = { 1331 [CX88_BOARD_GENIATECH_DVBS] = {
1287 .name = "Geniatech DVB-S", 1332 .name = "Geniatech DVB-S",
1288 .tuner_type = TUNER_ABSENT, 1333 .tuner_type = TUNER_ABSENT,
@@ -1908,7 +1953,8 @@ static const struct cx88_board cx88_boards[] = {
1908 .radio_addr = ADDR_UNSET, 1953 .radio_addr = ADDR_UNSET,
1909 .input = {{ 1954 .input = {{
1910 .type = CX88_VMUX_DVB, 1955 .type = CX88_VMUX_DVB,
1911 .vmux = 1, 1956 .vmux = 0,
1957 .gpio0 = 0x8080,
1912 } }, 1958 } },
1913 .mpeg = CX88_MPEG_DVB, 1959 .mpeg = CX88_MPEG_DVB,
1914 }, 1960 },
@@ -2282,6 +2328,10 @@ static const struct cx88_subid cx88_subids[] = {
2282 .subdevice = 0x665e, 2328 .subdevice = 0x665e,
2283 .card = CX88_BOARD_WINFAST_DTV2000H, 2329 .card = CX88_BOARD_WINFAST_DTV2000H,
2284 },{ 2330 },{
2331 .subvendor = 0x107d,
2332 .subdevice = 0x6f2b,
2333 .card = CX88_BOARD_WINFAST_DTV2000H_J,
2334 },{
2285 .subvendor = 0x18ac, 2335 .subvendor = 0x18ac,
2286 .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */ 2336 .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */
2287 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q, 2337 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
@@ -3162,7 +3212,11 @@ static void cx88_card_setup(struct cx88_core *core)
3162 case CX88_BOARD_PROF_6200: 3212 case CX88_BOARD_PROF_6200:
3163 case CX88_BOARD_PROF_7300: 3213 case CX88_BOARD_PROF_7300:
3164 case CX88_BOARD_SATTRADE_ST4200: 3214 case CX88_BOARD_SATTRADE_ST4200:
3215 cx_write(MO_GP0_IO, 0x8000);
3216 msleep(100);
3165 cx_write(MO_SRST_IO, 0); 3217 cx_write(MO_SRST_IO, 0);
3218 msleep(10);
3219 cx_write(MO_GP0_IO, 0x8080);
3166 msleep(100); 3220 msleep(100);
3167 cx_write(MO_SRST_IO, 1); 3221 cx_write(MO_SRST_IO, 1);
3168 msleep(100); 3222 msleep(100);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index e237b507659b..6e5d142b5b00 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -424,17 +424,16 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
424 struct cx8802_dev *dev= fe->dvb->priv; 424 struct cx8802_dev *dev= fe->dvb->priv;
425 struct cx88_core *core = dev->core; 425 struct cx88_core *core = dev->core;
426 426
427 cx_set(MO_GP0_IO, 0x6040);
427 switch (voltage) { 428 switch (voltage) {
428 case SEC_VOLTAGE_13: 429 case SEC_VOLTAGE_13:
429 printk("LNB Voltage SEC_VOLTAGE_13\n"); 430 cx_clear(MO_GP0_IO, 0x20);
430 cx_write(MO_GP0_IO, 0x00006040);
431 break; 431 break;
432 case SEC_VOLTAGE_18: 432 case SEC_VOLTAGE_18:
433 printk("LNB Voltage SEC_VOLTAGE_18\n"); 433 cx_set(MO_GP0_IO, 0x20);
434 cx_write(MO_GP0_IO, 0x00006060);
435 break; 434 break;
436 case SEC_VOLTAGE_OFF: 435 case SEC_VOLTAGE_OFF:
437 printk("LNB Voltage SEC_VOLTAGE_off\n"); 436 cx_clear(MO_GP0_IO, 0x20);
438 break; 437 break;
439 } 438 }
440 439
@@ -499,9 +498,9 @@ static struct zl10353_config cx88_pinnacle_hybrid_pctv = {
499}; 498};
500 499
501static struct zl10353_config cx88_geniatech_x8000_mt = { 500static struct zl10353_config cx88_geniatech_x8000_mt = {
502 .demod_address = (0x1e >> 1), 501 .demod_address = (0x1e >> 1),
503 .no_tuner = 1, 502 .no_tuner = 1,
504 .disable_i2c_gate_ctrl = 1, 503 .disable_i2c_gate_ctrl = 1,
505}; 504};
506 505
507static struct s5h1411_config dvico_fusionhdtv7_config = { 506static struct s5h1411_config dvico_fusionhdtv7_config = {
@@ -696,6 +695,7 @@ static int dvb_register(struct cx8802_dev *dev)
696 } 695 }
697 break; 696 break;
698 case CX88_BOARD_WINFAST_DTV2000H: 697 case CX88_BOARD_WINFAST_DTV2000H:
698 case CX88_BOARD_WINFAST_DTV2000H_J:
699 case CX88_BOARD_HAUPPAUGE_HVR1100: 699 case CX88_BOARD_HAUPPAUGE_HVR1100:
700 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 700 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
701 case CX88_BOARD_HAUPPAUGE_HVR1300: 701 case CX88_BOARD_HAUPPAUGE_HVR1300:
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index d91f5c51206d..78b3635178af 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/delay.h> 26#include <linux/hrtimer.h>
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/module.h> 29#include <linux/module.h>
@@ -48,7 +48,7 @@ struct cx88_IR {
48 48
49 /* poll external decoder */ 49 /* poll external decoder */
50 int polling; 50 int polling;
51 struct delayed_work work; 51 struct hrtimer timer;
52 u32 gpio_addr; 52 u32 gpio_addr;
53 u32 last_gpio; 53 u32 last_gpio;
54 u32 mask_keycode; 54 u32 mask_keycode;
@@ -144,19 +144,28 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
144 } 144 }
145} 145}
146 146
147static void cx88_ir_work(struct work_struct *work) 147static enum hrtimer_restart cx88_ir_work(struct hrtimer *timer)
148{ 148{
149 struct cx88_IR *ir = container_of(work, struct cx88_IR, work.work); 149 unsigned long missed;
150 struct cx88_IR *ir = container_of(timer, struct cx88_IR, timer);
150 151
151 cx88_ir_handle_key(ir); 152 cx88_ir_handle_key(ir);
152 schedule_delayed_work(&ir->work, msecs_to_jiffies(ir->polling)); 153 missed = hrtimer_forward_now(&ir->timer,
154 ktime_set(0, ir->polling * 1000000));
155 if (missed > 1)
156 ir_dprintk("Missed ticks %ld\n", missed - 1);
157
158 return HRTIMER_RESTART;
153} 159}
154 160
155void cx88_ir_start(struct cx88_core *core, struct cx88_IR *ir) 161void cx88_ir_start(struct cx88_core *core, struct cx88_IR *ir)
156{ 162{
157 if (ir->polling) { 163 if (ir->polling) {
158 INIT_DELAYED_WORK(&ir->work, cx88_ir_work); 164 hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
159 schedule_delayed_work(&ir->work, 0); 165 ir->timer.function = cx88_ir_work;
166 hrtimer_start(&ir->timer,
167 ktime_set(0, ir->polling * 1000000),
168 HRTIMER_MODE_REL);
160 } 169 }
161 if (ir->sampling) { 170 if (ir->sampling) {
162 core->pci_irqmask |= PCI_INT_IR_SMPINT; 171 core->pci_irqmask |= PCI_INT_IR_SMPINT;
@@ -173,7 +182,7 @@ void cx88_ir_stop(struct cx88_core *core, struct cx88_IR *ir)
173 } 182 }
174 183
175 if (ir->polling) 184 if (ir->polling)
176 cancel_delayed_work_sync(&ir->work); 185 hrtimer_cancel(&ir->timer);
177} 186}
178 187
179/* ---------------------------------------------------------------------- */ 188/* ---------------------------------------------------------------------- */
@@ -182,7 +191,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
182{ 191{
183 struct cx88_IR *ir; 192 struct cx88_IR *ir;
184 struct input_dev *input_dev; 193 struct input_dev *input_dev;
185 IR_KEYTAB_TYPE *ir_codes = NULL; 194 struct ir_scancode_table *ir_codes = NULL;
186 int ir_type = IR_TYPE_OTHER; 195 int ir_type = IR_TYPE_OTHER;
187 int err = -ENOMEM; 196 int err = -ENOMEM;
188 197
@@ -198,14 +207,14 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
198 case CX88_BOARD_DNTV_LIVE_DVB_T: 207 case CX88_BOARD_DNTV_LIVE_DVB_T:
199 case CX88_BOARD_KWORLD_DVB_T: 208 case CX88_BOARD_KWORLD_DVB_T:
200 case CX88_BOARD_KWORLD_DVB_T_CX22702: 209 case CX88_BOARD_KWORLD_DVB_T_CX22702:
201 ir_codes = ir_codes_dntv_live_dvb_t; 210 ir_codes = &ir_codes_dntv_live_dvb_t_table;
202 ir->gpio_addr = MO_GP1_IO; 211 ir->gpio_addr = MO_GP1_IO;
203 ir->mask_keycode = 0x1f; 212 ir->mask_keycode = 0x1f;
204 ir->mask_keyup = 0x60; 213 ir->mask_keyup = 0x60;
205 ir->polling = 50; /* ms */ 214 ir->polling = 50; /* ms */
206 break; 215 break;
207 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 216 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
208 ir_codes = ir_codes_cinergy_1400; 217 ir_codes = &ir_codes_cinergy_1400_table;
209 ir_type = IR_TYPE_PD; 218 ir_type = IR_TYPE_PD;
210 ir->sampling = 0xeb04; /* address */ 219 ir->sampling = 0xeb04; /* address */
211 break; 220 break;
@@ -220,13 +229,14 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
220 case CX88_BOARD_PCHDTV_HD3000: 229 case CX88_BOARD_PCHDTV_HD3000:
221 case CX88_BOARD_PCHDTV_HD5500: 230 case CX88_BOARD_PCHDTV_HD5500:
222 case CX88_BOARD_HAUPPAUGE_IRONLY: 231 case CX88_BOARD_HAUPPAUGE_IRONLY:
223 ir_codes = ir_codes_hauppauge_new; 232 ir_codes = &ir_codes_hauppauge_new_table;
224 ir_type = IR_TYPE_RC5; 233 ir_type = IR_TYPE_RC5;
225 ir->sampling = 1; 234 ir->sampling = 1;
226 break; 235 break;
227 case CX88_BOARD_WINFAST_DTV2000H: 236 case CX88_BOARD_WINFAST_DTV2000H:
237 case CX88_BOARD_WINFAST_DTV2000H_J:
228 case CX88_BOARD_WINFAST_DTV1800H: 238 case CX88_BOARD_WINFAST_DTV1800H:
229 ir_codes = ir_codes_winfast; 239 ir_codes = &ir_codes_winfast_table;
230 ir->gpio_addr = MO_GP0_IO; 240 ir->gpio_addr = MO_GP0_IO;
231 ir->mask_keycode = 0x8f8; 241 ir->mask_keycode = 0x8f8;
232 ir->mask_keyup = 0x100; 242 ir->mask_keyup = 0x100;
@@ -235,14 +245,14 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
235 case CX88_BOARD_WINFAST2000XP_EXPERT: 245 case CX88_BOARD_WINFAST2000XP_EXPERT:
236 case CX88_BOARD_WINFAST_DTV1000: 246 case CX88_BOARD_WINFAST_DTV1000:
237 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: 247 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
238 ir_codes = ir_codes_winfast; 248 ir_codes = &ir_codes_winfast_table;
239 ir->gpio_addr = MO_GP0_IO; 249 ir->gpio_addr = MO_GP0_IO;
240 ir->mask_keycode = 0x8f8; 250 ir->mask_keycode = 0x8f8;
241 ir->mask_keyup = 0x100; 251 ir->mask_keyup = 0x100;
242 ir->polling = 1; /* ms */ 252 ir->polling = 1; /* ms */
243 break; 253 break;
244 case CX88_BOARD_IODATA_GVBCTV7E: 254 case CX88_BOARD_IODATA_GVBCTV7E:
245 ir_codes = ir_codes_iodata_bctv7e; 255 ir_codes = &ir_codes_iodata_bctv7e_table;
246 ir->gpio_addr = MO_GP0_IO; 256 ir->gpio_addr = MO_GP0_IO;
247 ir->mask_keycode = 0xfd; 257 ir->mask_keycode = 0xfd;
248 ir->mask_keydown = 0x02; 258 ir->mask_keydown = 0x02;
@@ -250,7 +260,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
250 break; 260 break;
251 case CX88_BOARD_PROLINK_PLAYTVPVR: 261 case CX88_BOARD_PROLINK_PLAYTVPVR:
252 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO: 262 case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
253 ir_codes = ir_codes_pixelview; 263 ir_codes = &ir_codes_pixelview_table;
254 ir->gpio_addr = MO_GP1_IO; 264 ir->gpio_addr = MO_GP1_IO;
255 ir->mask_keycode = 0x1f; 265 ir->mask_keycode = 0x1f;
256 ir->mask_keyup = 0x80; 266 ir->mask_keyup = 0x80;
@@ -258,28 +268,28 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
258 break; 268 break;
259 case CX88_BOARD_PROLINK_PV_8000GT: 269 case CX88_BOARD_PROLINK_PV_8000GT:
260 case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME: 270 case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME:
261 ir_codes = ir_codes_pixelview_new; 271 ir_codes = &ir_codes_pixelview_new_table;
262 ir->gpio_addr = MO_GP1_IO; 272 ir->gpio_addr = MO_GP1_IO;
263 ir->mask_keycode = 0x3f; 273 ir->mask_keycode = 0x3f;
264 ir->mask_keyup = 0x80; 274 ir->mask_keyup = 0x80;
265 ir->polling = 1; /* ms */ 275 ir->polling = 1; /* ms */
266 break; 276 break;
267 case CX88_BOARD_KWORLD_LTV883: 277 case CX88_BOARD_KWORLD_LTV883:
268 ir_codes = ir_codes_pixelview; 278 ir_codes = &ir_codes_pixelview_table;
269 ir->gpio_addr = MO_GP1_IO; 279 ir->gpio_addr = MO_GP1_IO;
270 ir->mask_keycode = 0x1f; 280 ir->mask_keycode = 0x1f;
271 ir->mask_keyup = 0x60; 281 ir->mask_keyup = 0x60;
272 ir->polling = 1; /* ms */ 282 ir->polling = 1; /* ms */
273 break; 283 break;
274 case CX88_BOARD_ADSTECH_DVB_T_PCI: 284 case CX88_BOARD_ADSTECH_DVB_T_PCI:
275 ir_codes = ir_codes_adstech_dvb_t_pci; 285 ir_codes = &ir_codes_adstech_dvb_t_pci_table;
276 ir->gpio_addr = MO_GP1_IO; 286 ir->gpio_addr = MO_GP1_IO;
277 ir->mask_keycode = 0xbf; 287 ir->mask_keycode = 0xbf;
278 ir->mask_keyup = 0x40; 288 ir->mask_keyup = 0x40;
279 ir->polling = 50; /* ms */ 289 ir->polling = 50; /* ms */
280 break; 290 break;
281 case CX88_BOARD_MSI_TVANYWHERE_MASTER: 291 case CX88_BOARD_MSI_TVANYWHERE_MASTER:
282 ir_codes = ir_codes_msi_tvanywhere; 292 ir_codes = &ir_codes_msi_tvanywhere_table;
283 ir->gpio_addr = MO_GP1_IO; 293 ir->gpio_addr = MO_GP1_IO;
284 ir->mask_keycode = 0x1f; 294 ir->mask_keycode = 0x1f;
285 ir->mask_keyup = 0x40; 295 ir->mask_keyup = 0x40;
@@ -287,40 +297,40 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
287 break; 297 break;
288 case CX88_BOARD_AVERTV_303: 298 case CX88_BOARD_AVERTV_303:
289 case CX88_BOARD_AVERTV_STUDIO_303: 299 case CX88_BOARD_AVERTV_STUDIO_303:
290 ir_codes = ir_codes_avertv_303; 300 ir_codes = &ir_codes_avertv_303_table;
291 ir->gpio_addr = MO_GP2_IO; 301 ir->gpio_addr = MO_GP2_IO;
292 ir->mask_keycode = 0xfb; 302 ir->mask_keycode = 0xfb;
293 ir->mask_keydown = 0x02; 303 ir->mask_keydown = 0x02;
294 ir->polling = 50; /* ms */ 304 ir->polling = 50; /* ms */
295 break; 305 break;
296 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 306 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
297 ir_codes = ir_codes_dntv_live_dvbt_pro; 307 ir_codes = &ir_codes_dntv_live_dvbt_pro_table;
298 ir_type = IR_TYPE_PD; 308 ir_type = IR_TYPE_PD;
299 ir->sampling = 0xff00; /* address */ 309 ir->sampling = 0xff00; /* address */
300 break; 310 break;
301 case CX88_BOARD_NORWOOD_MICRO: 311 case CX88_BOARD_NORWOOD_MICRO:
302 ir_codes = ir_codes_norwood; 312 ir_codes = &ir_codes_norwood_table;
303 ir->gpio_addr = MO_GP1_IO; 313 ir->gpio_addr = MO_GP1_IO;
304 ir->mask_keycode = 0x0e; 314 ir->mask_keycode = 0x0e;
305 ir->mask_keyup = 0x80; 315 ir->mask_keyup = 0x80;
306 ir->polling = 50; /* ms */ 316 ir->polling = 50; /* ms */
307 break; 317 break;
308 case CX88_BOARD_NPGTECH_REALTV_TOP10FM: 318 case CX88_BOARD_NPGTECH_REALTV_TOP10FM:
309 ir_codes = ir_codes_npgtech; 319 ir_codes = &ir_codes_npgtech_table;
310 ir->gpio_addr = MO_GP0_IO; 320 ir->gpio_addr = MO_GP0_IO;
311 ir->mask_keycode = 0xfa; 321 ir->mask_keycode = 0xfa;
312 ir->polling = 50; /* ms */ 322 ir->polling = 50; /* ms */
313 break; 323 break;
314 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 324 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
315 ir_codes = ir_codes_pinnacle_pctv_hd; 325 ir_codes = &ir_codes_pinnacle_pctv_hd_table;
316 ir_type = IR_TYPE_RC5; 326 ir_type = IR_TYPE_RC5;
317 ir->sampling = 1; 327 ir->sampling = 1;
318 break; 328 break;
319 case CX88_BOARD_POWERCOLOR_REAL_ANGEL: 329 case CX88_BOARD_POWERCOLOR_REAL_ANGEL:
320 ir_codes = ir_codes_powercolor_real_angel; 330 ir_codes = &ir_codes_powercolor_real_angel_table;
321 ir->gpio_addr = MO_GP2_IO; 331 ir->gpio_addr = MO_GP2_IO;
322 ir->mask_keycode = 0x7e; 332 ir->mask_keycode = 0x7e;
323 ir->polling = 100; /* ms */ 333 ir->polling = 100; /* ms */
324 break; 334 break;
325 } 335 }
326 336
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 9d83762163f5..d5cea41f4207 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -237,6 +237,7 @@ extern struct sram_channel cx88_sram_channels[];
237#define CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII 79 237#define CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII 79
238#define CX88_BOARD_HAUPPAUGE_IRONLY 80 238#define CX88_BOARD_HAUPPAUGE_IRONLY 80
239#define CX88_BOARD_WINFAST_DTV1800H 81 239#define CX88_BOARD_WINFAST_DTV1800H 81
240#define CX88_BOARD_WINFAST_DTV2000H_J 82
240 241
241enum cx88_itype { 242enum cx88_itype {
242 CX88_VMUX_COMPOSITE1 = 1, 243 CX88_VMUX_COMPOSITE1 = 1,
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 1c2e544eda73..7e3c78239fa9 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -299,6 +299,7 @@ struct em28xx_board em28xx_boards[] = {
299 [EM2820_BOARD_TERRATEC_CINERGY_250] = { 299 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
300 .name = "Terratec Cinergy 250 USB", 300 .name = "Terratec Cinergy 250 USB",
301 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 301 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
302 .has_ir_i2c = 1,
302 .tda9887_conf = TDA9887_PRESENT, 303 .tda9887_conf = TDA9887_PRESENT,
303 .decoder = EM28XX_SAA711X, 304 .decoder = EM28XX_SAA711X,
304 .input = { { 305 .input = { {
@@ -318,6 +319,7 @@ struct em28xx_board em28xx_boards[] = {
318 [EM2820_BOARD_PINNACLE_USB_2] = { 319 [EM2820_BOARD_PINNACLE_USB_2] = {
319 .name = "Pinnacle PCTV USB 2", 320 .name = "Pinnacle PCTV USB 2",
320 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 321 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
322 .has_ir_i2c = 1,
321 .tda9887_conf = TDA9887_PRESENT, 323 .tda9887_conf = TDA9887_PRESENT,
322 .decoder = EM28XX_SAA711X, 324 .decoder = EM28XX_SAA711X,
323 .input = { { 325 .input = { {
@@ -342,6 +344,7 @@ struct em28xx_board em28xx_boards[] = {
342 TDA9887_PORT2_ACTIVE, 344 TDA9887_PORT2_ACTIVE,
343 .decoder = EM28XX_TVP5150, 345 .decoder = EM28XX_TVP5150,
344 .has_msp34xx = 1, 346 .has_msp34xx = 1,
347 .has_ir_i2c = 1,
345 .input = { { 348 .input = { {
346 .type = EM28XX_VMUX_TELEVISION, 349 .type = EM28XX_VMUX_TELEVISION,
347 .vmux = TVP5150_COMPOSITE0, 350 .vmux = TVP5150_COMPOSITE0,
@@ -558,6 +561,27 @@ struct em28xx_board em28xx_boards[] = {
558 .amux = EM28XX_AMUX_LINE_IN, 561 .amux = EM28XX_AMUX_LINE_IN,
559 } }, 562 } },
560 }, 563 },
564 [EM2861_BOARD_GADMEI_UTV330PLUS] = {
565 .name = "Gadmei UTV330+",
566 .tuner_type = TUNER_TNF_5335MF,
567 .tda9887_conf = TDA9887_PRESENT,
568 .ir_codes = &ir_codes_gadmei_rm008z_table,
569 .decoder = EM28XX_SAA711X,
570 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ,
571 .input = { {
572 .type = EM28XX_VMUX_TELEVISION,
573 .vmux = SAA7115_COMPOSITE2,
574 .amux = EM28XX_AMUX_VIDEO,
575 }, {
576 .type = EM28XX_VMUX_COMPOSITE1,
577 .vmux = SAA7115_COMPOSITE0,
578 .amux = EM28XX_AMUX_LINE_IN,
579 }, {
580 .type = EM28XX_VMUX_SVIDEO,
581 .vmux = SAA7115_SVIDEO3,
582 .amux = EM28XX_AMUX_LINE_IN,
583 } },
584 },
561 [EM2860_BOARD_TERRATEC_HYBRID_XS] = { 585 [EM2860_BOARD_TERRATEC_HYBRID_XS] = {
562 .name = "Terratec Cinergy A Hybrid XS", 586 .name = "Terratec Cinergy A Hybrid XS",
563 .valid = EM28XX_BOARD_NOT_VALIDATED, 587 .valid = EM28XX_BOARD_NOT_VALIDATED,
@@ -715,7 +739,7 @@ struct em28xx_board em28xx_boards[] = {
715 .mts_firmware = 1, 739 .mts_firmware = 1,
716 .has_dvb = 1, 740 .has_dvb = 1,
717 .dvb_gpio = hauppauge_wintv_hvr_900_digital, 741 .dvb_gpio = hauppauge_wintv_hvr_900_digital,
718 .ir_codes = ir_codes_hauppauge_new, 742 .ir_codes = &ir_codes_hauppauge_new_table,
719 .decoder = EM28XX_TVP5150, 743 .decoder = EM28XX_TVP5150,
720 .input = { { 744 .input = { {
721 .type = EM28XX_VMUX_TELEVISION, 745 .type = EM28XX_VMUX_TELEVISION,
@@ -740,7 +764,7 @@ struct em28xx_board em28xx_boards[] = {
740 .tuner_type = TUNER_XC2028, 764 .tuner_type = TUNER_XC2028,
741 .tuner_gpio = default_tuner_gpio, 765 .tuner_gpio = default_tuner_gpio,
742 .mts_firmware = 1, 766 .mts_firmware = 1,
743 .ir_codes = ir_codes_hauppauge_new, 767 .ir_codes = &ir_codes_hauppauge_new_table,
744 .decoder = EM28XX_TVP5150, 768 .decoder = EM28XX_TVP5150,
745 .input = { { 769 .input = { {
746 .type = EM28XX_VMUX_TELEVISION, 770 .type = EM28XX_VMUX_TELEVISION,
@@ -766,7 +790,7 @@ struct em28xx_board em28xx_boards[] = {
766 .mts_firmware = 1, 790 .mts_firmware = 1,
767 .has_dvb = 1, 791 .has_dvb = 1,
768 .dvb_gpio = hauppauge_wintv_hvr_900_digital, 792 .dvb_gpio = hauppauge_wintv_hvr_900_digital,
769 .ir_codes = ir_codes_hauppauge_new, 793 .ir_codes = &ir_codes_hauppauge_new_table,
770 .decoder = EM28XX_TVP5150, 794 .decoder = EM28XX_TVP5150,
771 .input = { { 795 .input = { {
772 .type = EM28XX_VMUX_TELEVISION, 796 .type = EM28XX_VMUX_TELEVISION,
@@ -792,7 +816,7 @@ struct em28xx_board em28xx_boards[] = {
792 .mts_firmware = 1, 816 .mts_firmware = 1,
793 .has_dvb = 1, 817 .has_dvb = 1,
794 .dvb_gpio = hauppauge_wintv_hvr_900_digital, 818 .dvb_gpio = hauppauge_wintv_hvr_900_digital,
795 .ir_codes = ir_codes_hauppauge_new, 819 .ir_codes = &ir_codes_hauppauge_new_table,
796 .decoder = EM28XX_TVP5150, 820 .decoder = EM28XX_TVP5150,
797 .input = { { 821 .input = { {
798 .type = EM28XX_VMUX_TELEVISION, 822 .type = EM28XX_VMUX_TELEVISION,
@@ -818,7 +842,7 @@ struct em28xx_board em28xx_boards[] = {
818 .mts_firmware = 1, 842 .mts_firmware = 1,
819 .has_dvb = 1, 843 .has_dvb = 1,
820 .dvb_gpio = hauppauge_wintv_hvr_900_digital, 844 .dvb_gpio = hauppauge_wintv_hvr_900_digital,
821 .ir_codes = ir_codes_pinnacle_pctv_hd, 845 .ir_codes = &ir_codes_pinnacle_pctv_hd_table,
822 .decoder = EM28XX_TVP5150, 846 .decoder = EM28XX_TVP5150,
823 .input = { { 847 .input = { {
824 .type = EM28XX_VMUX_TELEVISION, 848 .type = EM28XX_VMUX_TELEVISION,
@@ -844,7 +868,7 @@ struct em28xx_board em28xx_boards[] = {
844 .mts_firmware = 1, 868 .mts_firmware = 1,
845 .has_dvb = 1, 869 .has_dvb = 1,
846 .dvb_gpio = hauppauge_wintv_hvr_900_digital, 870 .dvb_gpio = hauppauge_wintv_hvr_900_digital,
847 .ir_codes = ir_codes_ati_tv_wonder_hd_600, 871 .ir_codes = &ir_codes_ati_tv_wonder_hd_600_table,
848 .decoder = EM28XX_TVP5150, 872 .decoder = EM28XX_TVP5150,
849 .input = { { 873 .input = { {
850 .type = EM28XX_VMUX_TELEVISION, 874 .type = EM28XX_VMUX_TELEVISION,
@@ -870,6 +894,8 @@ struct em28xx_board em28xx_boards[] = {
870 .decoder = EM28XX_TVP5150, 894 .decoder = EM28XX_TVP5150,
871 .has_dvb = 1, 895 .has_dvb = 1,
872 .dvb_gpio = default_digital, 896 .dvb_gpio = default_digital,
897 .ir_codes = &ir_codes_terratec_cinergy_xs_table,
898 .xclk = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
873 .input = { { 899 .input = { {
874 .type = EM28XX_VMUX_TELEVISION, 900 .type = EM28XX_VMUX_TELEVISION,
875 .vmux = TVP5150_COMPOSITE0, 901 .vmux = TVP5150_COMPOSITE0,
@@ -937,6 +963,7 @@ struct em28xx_board em28xx_boards[] = {
937 [EM2800_BOARD_TERRATEC_CINERGY_200] = { 963 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
938 .name = "Terratec Cinergy 200 USB", 964 .name = "Terratec Cinergy 200 USB",
939 .is_em2800 = 1, 965 .is_em2800 = 1,
966 .has_ir_i2c = 1,
940 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 967 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
941 .tda9887_conf = TDA9887_PRESENT, 968 .tda9887_conf = TDA9887_PRESENT,
942 .decoder = EM28XX_SAA711X, 969 .decoder = EM28XX_SAA711X,
@@ -1010,7 +1037,8 @@ struct em28xx_board em28xx_boards[] = {
1010 } }, 1037 } },
1011 }, 1038 },
1012 [EM2820_BOARD_PINNACLE_DVC_90] = { 1039 [EM2820_BOARD_PINNACLE_DVC_90] = {
1013 .name = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker", 1040 .name = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker "
1041 "/ Kworld DVD Maker 2",
1014 .tuner_type = TUNER_ABSENT, /* capture only board */ 1042 .tuner_type = TUNER_ABSENT, /* capture only board */
1015 .decoder = EM28XX_SAA711X, 1043 .decoder = EM28XX_SAA711X,
1016 .input = { { 1044 .input = { {
@@ -1420,7 +1448,7 @@ struct em28xx_board em28xx_boards[] = {
1420 .mts_firmware = 1, 1448 .mts_firmware = 1,
1421 .decoder = EM28XX_TVP5150, 1449 .decoder = EM28XX_TVP5150,
1422 .tuner_gpio = default_tuner_gpio, 1450 .tuner_gpio = default_tuner_gpio,
1423 .ir_codes = ir_codes_kaiomy, 1451 .ir_codes = &ir_codes_kaiomy_table,
1424 .input = { { 1452 .input = { {
1425 .type = EM28XX_VMUX_TELEVISION, 1453 .type = EM28XX_VMUX_TELEVISION,
1426 .vmux = TVP5150_COMPOSITE0, 1454 .vmux = TVP5150_COMPOSITE0,
@@ -1520,7 +1548,7 @@ struct em28xx_board em28xx_boards[] = {
1520 .mts_firmware = 1, 1548 .mts_firmware = 1,
1521 .has_dvb = 1, 1549 .has_dvb = 1,
1522 .dvb_gpio = evga_indtube_digital, 1550 .dvb_gpio = evga_indtube_digital,
1523 .ir_codes = ir_codes_evga_indtube, 1551 .ir_codes = &ir_codes_evga_indtube_table,
1524 .input = { { 1552 .input = { {
1525 .type = EM28XX_VMUX_TELEVISION, 1553 .type = EM28XX_VMUX_TELEVISION,
1526 .vmux = TVP5150_COMPOSITE0, 1554 .vmux = TVP5150_COMPOSITE0,
@@ -1591,6 +1619,8 @@ struct usb_device_id em28xx_id_table[] = {
1591 .driver_info = EM2870_BOARD_KWORLD_355U }, 1619 .driver_info = EM2870_BOARD_KWORLD_355U },
1592 { USB_DEVICE(0x1b80, 0xe302), 1620 { USB_DEVICE(0x1b80, 0xe302),
1593 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kaiser Baas Video to DVD maker */ 1621 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kaiser Baas Video to DVD maker */
1622 { USB_DEVICE(0x1b80, 0xe304),
1623 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kworld DVD Maker 2 */
1594 { USB_DEVICE(0x0ccd, 0x0036), 1624 { USB_DEVICE(0x0ccd, 0x0036),
1595 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 }, 1625 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1596 { USB_DEVICE(0x0ccd, 0x004c), 1626 { USB_DEVICE(0x0ccd, 0x004c),
@@ -1649,6 +1679,8 @@ struct usb_device_id em28xx_id_table[] = {
1649 .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U }, 1679 .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1650 { USB_DEVICE(0x04bb, 0x0515), 1680 { USB_DEVICE(0x04bb, 0x0515),
1651 .driver_info = EM2820_BOARD_IODATA_GVMVP_SZ }, 1681 .driver_info = EM2820_BOARD_IODATA_GVMVP_SZ },
1682 { USB_DEVICE(0xeb1a, 0x50a6),
1683 .driver_info = EM2860_BOARD_GADMEI_UTV330 },
1652 { }, 1684 { },
1653}; 1685};
1654MODULE_DEVICE_TABLE(usb, em28xx_id_table); 1686MODULE_DEVICE_TABLE(usb, em28xx_id_table);
@@ -1661,7 +1693,7 @@ static struct em28xx_hash_table em28xx_eeprom_hash[] = {
1661 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF}, 1693 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1662 {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF}, 1694 {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
1663 {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028}, 1695 {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1664 {0x9567eb1a, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028}, 1696 {0x166a0441, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
1665 {0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028}, 1697 {0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028},
1666 {0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028}, 1698 {0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028},
1667}; 1699};
@@ -1672,6 +1704,7 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = {
1672 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC}, 1704 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1673 {0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT}, 1705 {0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT},
1674 {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC}, 1706 {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC},
1707 {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
1675}; 1708};
1676 1709
1677/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */ 1710/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */
@@ -2170,8 +2203,6 @@ static int em28xx_hint_board(struct em28xx *dev)
2170/* ----------------------------------------------------------------------- */ 2203/* ----------------------------------------------------------------------- */
2171void em28xx_register_i2c_ir(struct em28xx *dev) 2204void em28xx_register_i2c_ir(struct em28xx *dev)
2172{ 2205{
2173 struct i2c_board_info info;
2174 struct IR_i2c_init_data init_data;
2175 const unsigned short addr_list[] = { 2206 const unsigned short addr_list[] = {
2176 0x30, 0x47, I2C_CLIENT_END 2207 0x30, 0x47, I2C_CLIENT_END
2177 }; 2208 };
@@ -2179,45 +2210,33 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
2179 if (disable_ir) 2210 if (disable_ir)
2180 return; 2211 return;
2181 2212
2182 memset(&info, 0, sizeof(struct i2c_board_info)); 2213 memset(&dev->info, 0, sizeof(&dev->info));
2183 memset(&init_data, 0, sizeof(struct IR_i2c_init_data)); 2214 memset(&dev->init_data, 0, sizeof(dev->init_data));
2184 strlcpy(info.type, "ir_video", I2C_NAME_SIZE); 2215 strlcpy(dev->info.type, "ir_video", I2C_NAME_SIZE);
2185 2216
2186 /* detect & configure */ 2217 /* detect & configure */
2187 switch (dev->model) { 2218 switch (dev->model) {
2188 case (EM2800_BOARD_UNKNOWN): 2219 case EM2800_BOARD_TERRATEC_CINERGY_200:
2189 break; 2220 case EM2820_BOARD_TERRATEC_CINERGY_250:
2190 case (EM2820_BOARD_UNKNOWN): 2221 dev->init_data.ir_codes = &ir_codes_em_terratec_table;
2191 break; 2222 dev->init_data.get_key = em28xx_get_key_terratec;
2192 case (EM2800_BOARD_TERRATEC_CINERGY_200): 2223 dev->init_data.name = "i2c IR (EM28XX Terratec)";
2193 case (EM2820_BOARD_TERRATEC_CINERGY_250):
2194 init_data.ir_codes = ir_codes_em_terratec;
2195 init_data.get_key = em28xx_get_key_terratec;
2196 init_data.name = "i2c IR (EM28XX Terratec)";
2197 break;
2198 case (EM2820_BOARD_PINNACLE_USB_2):
2199 init_data.ir_codes = ir_codes_pinnacle_grey;
2200 init_data.get_key = em28xx_get_key_pinnacle_usb_grey;
2201 init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
2202 break;
2203 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
2204 init_data.ir_codes = ir_codes_hauppauge_new;
2205 init_data.get_key = em28xx_get_key_em_haup;
2206 init_data.name = "i2c IR (EM2840 Hauppauge)";
2207 break; 2224 break;
2208 case (EM2820_BOARD_MSI_VOX_USB_2): 2225 case EM2820_BOARD_PINNACLE_USB_2:
2226 dev->init_data.ir_codes = &ir_codes_pinnacle_grey_table;
2227 dev->init_data.get_key = em28xx_get_key_pinnacle_usb_grey;
2228 dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
2209 break; 2229 break;
2210 case (EM2800_BOARD_LEADTEK_WINFAST_USBII): 2230 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2211 break; 2231 dev->init_data.ir_codes = &ir_codes_hauppauge_new_table;
2212 case (EM2800_BOARD_KWORLD_USB2800): 2232 dev->init_data.get_key = em28xx_get_key_em_haup;
2213 break; 2233 dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
2214 case (EM2800_BOARD_GRABBEEX_USB2800):
2215 break; 2234 break;
2216 } 2235 }
2217 2236
2218 if (init_data.name) 2237 if (dev->init_data.name)
2219 info.platform_data = &init_data; 2238 dev->info.platform_data = &dev->init_data;
2220 i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); 2239 i2c_new_probed_device(&dev->i2c_adap, &dev->info, addr_list);
2221} 2240}
2222 2241
2223void em28xx_card_setup(struct em28xx *dev) 2242void em28xx_card_setup(struct em28xx *dev)
@@ -2253,7 +2272,7 @@ void em28xx_card_setup(struct em28xx *dev)
2253 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: 2272 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2254 { 2273 {
2255 struct tveeprom tv; 2274 struct tveeprom tv;
2256#ifdef CONFIG_MODULES 2275#if defined(CONFIG_MODULES) && defined(MODULE)
2257 request_module("tveeprom"); 2276 request_module("tveeprom");
2258#endif 2277#endif
2259 /* Call first TVeeprom */ 2278 /* Call first TVeeprom */
@@ -2267,10 +2286,6 @@ void em28xx_card_setup(struct em28xx *dev)
2267 dev->i2s_speed = 2048000; 2286 dev->i2s_speed = 2048000;
2268 dev->board.has_msp34xx = 1; 2287 dev->board.has_msp34xx = 1;
2269 } 2288 }
2270#ifdef CONFIG_MODULES
2271 if (tv.has_ir)
2272 request_module("ir-kbd-i2c");
2273#endif
2274 break; 2289 break;
2275 } 2290 }
2276 case EM2882_BOARD_KWORLD_ATSC_315U: 2291 case EM2882_BOARD_KWORLD_ATSC_315U:
@@ -2311,6 +2326,10 @@ void em28xx_card_setup(struct em28xx *dev)
2311 break; 2326 break;
2312 } 2327 }
2313 2328
2329#if defined(CONFIG_MODULES) && defined(MODULE)
2330 if (dev->board.has_ir_i2c && !disable_ir)
2331 request_module("ir-kbd-i2c");
2332#endif
2314 if (dev->board.has_snapshot_button) 2333 if (dev->board.has_snapshot_button)
2315 em28xx_register_snapshot_button(dev); 2334 em28xx_register_snapshot_button(dev);
2316 2335
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 27e33a287dfc..71474d31e155 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -459,7 +459,6 @@ static struct i2c_algorithm em28xx_algo = {
459static struct i2c_adapter em28xx_adap_template = { 459static struct i2c_adapter em28xx_adap_template = {
460 .owner = THIS_MODULE, 460 .owner = THIS_MODULE,
461 .name = "em28xx", 461 .name = "em28xx",
462 .id = I2C_HW_B_EM28XX,
463 .algo = &em28xx_algo, 462 .algo = &em28xx_algo,
464}; 463};
465 464
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index ab079d9256c4..a6bdbc21410e 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -124,7 +124,7 @@ static struct em28xx_fmt format[] = {
124 124
125/* supported controls */ 125/* supported controls */
126/* Common to all boards */ 126/* Common to all boards */
127static struct v4l2_queryctrl em28xx_qctrl[] = { 127static struct v4l2_queryctrl ac97_qctrl[] = {
128 { 128 {
129 .id = V4L2_CID_AUDIO_VOLUME, 129 .id = V4L2_CID_AUDIO_VOLUME,
130 .type = V4L2_CTRL_TYPE_INTEGER, 130 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -133,7 +133,7 @@ static struct v4l2_queryctrl em28xx_qctrl[] = {
133 .maximum = 0x1f, 133 .maximum = 0x1f,
134 .step = 0x1, 134 .step = 0x1,
135 .default_value = 0x1f, 135 .default_value = 0x1f,
136 .flags = 0, 136 .flags = V4L2_CTRL_FLAG_SLIDER,
137 }, { 137 }, {
138 .id = V4L2_CID_AUDIO_MUTE, 138 .id = V4L2_CID_AUDIO_MUTE,
139 .type = V4L2_CTRL_TYPE_BOOLEAN, 139 .type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -609,10 +609,29 @@ static void res_free(struct em28xx_fh *fh)
609} 609}
610 610
611/* 611/*
612 * em28xx_get_ctrl() 612 * ac97_queryctrl()
613 * return the current saturation, brightness or contrast, mute state 613 * return the ac97 supported controls
614 */ 614 */
615static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl) 615static int ac97_queryctrl(struct v4l2_queryctrl *qc)
616{
617 int i;
618
619 for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++) {
620 if (qc->id && qc->id == ac97_qctrl[i].id) {
621 memcpy(qc, &(ac97_qctrl[i]), sizeof(*qc));
622 return 0;
623 }
624 }
625
626 /* Control is not ac97 related */
627 return 1;
628}
629
630/*
631 * ac97_get_ctrl()
632 * return the current values for ac97 mute and volume
633 */
634static int ac97_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)
616{ 635{
617 switch (ctrl->id) { 636 switch (ctrl->id) {
618 case V4L2_CID_AUDIO_MUTE: 637 case V4L2_CID_AUDIO_MUTE:
@@ -622,29 +641,41 @@ static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)
622 ctrl->value = dev->volume; 641 ctrl->value = dev->volume;
623 return 0; 642 return 0;
624 default: 643 default:
625 return -EINVAL; 644 /* Control is not ac97 related */
645 return 1;
626 } 646 }
627} 647}
628 648
629/* 649/*
630 * em28xx_set_ctrl() 650 * ac97_set_ctrl()
631 * mute or set new saturation, brightness or contrast 651 * set values for ac97 mute and volume
632 */ 652 */
633static int em28xx_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl) 653static int ac97_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl)
634{ 654{
655 int i;
656
657 for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++)
658 if (ctrl->id == ac97_qctrl[i].id)
659 goto handle;
660
661 /* Announce that hasn't handle it */
662 return 1;
663
664handle:
665 if (ctrl->value < ac97_qctrl[i].minimum ||
666 ctrl->value > ac97_qctrl[i].maximum)
667 return -ERANGE;
668
635 switch (ctrl->id) { 669 switch (ctrl->id) {
636 case V4L2_CID_AUDIO_MUTE: 670 case V4L2_CID_AUDIO_MUTE:
637 if (ctrl->value != dev->mute) { 671 dev->mute = ctrl->value;
638 dev->mute = ctrl->value; 672 break;
639 return em28xx_audio_analog_set(dev);
640 }
641 return 0;
642 case V4L2_CID_AUDIO_VOLUME: 673 case V4L2_CID_AUDIO_VOLUME:
643 dev->volume = ctrl->value; 674 dev->volume = ctrl->value;
644 return em28xx_audio_analog_set(dev); 675 break;
645 default:
646 return -EINVAL;
647 } 676 }
677
678 return em28xx_audio_analog_set(dev);
648} 679}
649 680
650static int check_dev(struct em28xx *dev) 681static int check_dev(struct em28xx *dev)
@@ -974,6 +1005,9 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
974 struct em28xx_fh *fh = priv; 1005 struct em28xx_fh *fh = priv;
975 struct em28xx *dev = fh->dev; 1006 struct em28xx *dev = fh->dev;
976 1007
1008 if (!dev->audio_mode.has_audio)
1009 return -EINVAL;
1010
977 switch (a->index) { 1011 switch (a->index) {
978 case EM28XX_AMUX_VIDEO: 1012 case EM28XX_AMUX_VIDEO:
979 strcpy(a->name, "Television"); 1013 strcpy(a->name, "Television");
@@ -1015,6 +1049,9 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
1015 struct em28xx *dev = fh->dev; 1049 struct em28xx *dev = fh->dev;
1016 1050
1017 1051
1052 if (!dev->audio_mode.has_audio)
1053 return -EINVAL;
1054
1018 if (a->index >= MAX_EM28XX_INPUT) 1055 if (a->index >= MAX_EM28XX_INPUT)
1019 return -EINVAL; 1056 return -EINVAL;
1020 if (0 == INPUT(a->index)->type) 1057 if (0 == INPUT(a->index)->type)
@@ -1038,7 +1075,6 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1038 struct em28xx_fh *fh = priv; 1075 struct em28xx_fh *fh = priv;
1039 struct em28xx *dev = fh->dev; 1076 struct em28xx *dev = fh->dev;
1040 int id = qc->id; 1077 int id = qc->id;
1041 int i;
1042 int rc; 1078 int rc;
1043 1079
1044 rc = check_dev(dev); 1080 rc = check_dev(dev);
@@ -1049,15 +1085,14 @@ static int vidioc_queryctrl(struct file *file, void *priv,
1049 1085
1050 qc->id = id; 1086 qc->id = id;
1051 1087
1052 if (!dev->board.has_msp34xx) { 1088 /* enumberate AC97 controls */
1053 for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { 1089 if (dev->audio_mode.ac97 != EM28XX_NO_AC97) {
1054 if (qc->id && qc->id == em28xx_qctrl[i].id) { 1090 rc = ac97_queryctrl(qc);
1055 memcpy(qc, &(em28xx_qctrl[i]), sizeof(*qc)); 1091 if (!rc)
1056 return 0; 1092 return 0;
1057 }
1058 }
1059 } 1093 }
1060 1094
1095 /* enumberate V4L2 device controls */
1061 mutex_lock(&dev->lock); 1096 mutex_lock(&dev->lock);
1062 v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc); 1097 v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc);
1063 mutex_unlock(&dev->lock); 1098 mutex_unlock(&dev->lock);
@@ -1082,14 +1117,16 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
1082 1117
1083 mutex_lock(&dev->lock); 1118 mutex_lock(&dev->lock);
1084 1119
1085 if (dev->board.has_msp34xx) 1120 /* Set an AC97 control */
1121 if (dev->audio_mode.ac97 != EM28XX_NO_AC97)
1122 rc = ac97_get_ctrl(dev, ctrl);
1123 else
1124 rc = 1;
1125
1126 /* It were not an AC97 control. Sends it to the v4l2 dev interface */
1127 if (rc == 1) {
1086 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl); 1128 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl);
1087 else { 1129 rc = 0;
1088 rc = em28xx_get_ctrl(dev, ctrl);
1089 if (rc < 0) {
1090 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl);
1091 rc = 0;
1092 }
1093 } 1130 }
1094 1131
1095 mutex_unlock(&dev->lock); 1132 mutex_unlock(&dev->lock);
@@ -1101,7 +1138,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1101{ 1138{
1102 struct em28xx_fh *fh = priv; 1139 struct em28xx_fh *fh = priv;
1103 struct em28xx *dev = fh->dev; 1140 struct em28xx *dev = fh->dev;
1104 u8 i;
1105 int rc; 1141 int rc;
1106 1142
1107 rc = check_dev(dev); 1143 rc = check_dev(dev);
@@ -1110,28 +1146,31 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1110 1146
1111 mutex_lock(&dev->lock); 1147 mutex_lock(&dev->lock);
1112 1148
1113 if (dev->board.has_msp34xx) 1149 /* Set an AC97 control */
1114 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl); 1150 if (dev->audio_mode.ac97 != EM28XX_NO_AC97)
1115 else { 1151 rc = ac97_set_ctrl(dev, ctrl);
1152 else
1116 rc = 1; 1153 rc = 1;
1117 for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {
1118 if (ctrl->id == em28xx_qctrl[i].id) {
1119 if (ctrl->value < em28xx_qctrl[i].minimum ||
1120 ctrl->value > em28xx_qctrl[i].maximum) {
1121 rc = -ERANGE;
1122 break;
1123 }
1124
1125 rc = em28xx_set_ctrl(dev, ctrl);
1126 break;
1127 }
1128 }
1129 }
1130 1154
1131 /* Control not found - try to send it to the attached devices */ 1155 /* It isn't an AC97 control. Sends it to the v4l2 dev interface */
1132 if (rc == 1) { 1156 if (rc == 1) {
1133 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl); 1157 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_ctrl, ctrl);
1134 rc = 0; 1158
1159 /*
1160 * In the case of non-AC97 volume controls, we still need
1161 * to do some setups at em28xx, in order to mute/unmute
1162 * and to adjust audio volume. However, the value ranges
1163 * should be checked by the corresponding V4L subdriver.
1164 */
1165 switch (ctrl->id) {
1166 case V4L2_CID_AUDIO_MUTE:
1167 dev->mute = ctrl->value;
1168 rc = em28xx_audio_analog_set(dev);
1169 break;
1170 case V4L2_CID_AUDIO_VOLUME:
1171 dev->volume = ctrl->value;
1172 rc = em28xx_audio_analog_set(dev);
1173 }
1135 } 1174 }
1136 1175
1137 mutex_unlock(&dev->lock); 1176 mutex_unlock(&dev->lock);
@@ -1275,8 +1314,9 @@ static int vidioc_g_register(struct file *file, void *priv,
1275 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg); 1314 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg);
1276 return 0; 1315 return 0;
1277 case V4L2_CHIP_MATCH_I2C_ADDR: 1316 case V4L2_CHIP_MATCH_I2C_ADDR:
1278 /* Not supported yet */ 1317 /* TODO: is this correct? */
1279 return -EINVAL; 1318 v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg);
1319 return 0;
1280 default: 1320 default:
1281 if (!v4l2_chip_match_host(&reg->match)) 1321 if (!v4l2_chip_match_host(&reg->match))
1282 return -EINVAL; 1322 return -EINVAL;
@@ -1327,8 +1367,9 @@ static int vidioc_s_register(struct file *file, void *priv,
1327 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); 1367 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg);
1328 return 0; 1368 return 0;
1329 case V4L2_CHIP_MATCH_I2C_ADDR: 1369 case V4L2_CHIP_MATCH_I2C_ADDR:
1330 /* Not supported yet */ 1370 /* TODO: is this correct? */
1331 return -EINVAL; 1371 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg);
1372 return 0;
1332 default: 1373 default:
1333 if (!v4l2_chip_match_host(&reg->match)) 1374 if (!v4l2_chip_match_host(&reg->match))
1334 return -EINVAL; 1375 return -EINVAL;
@@ -1431,9 +1472,11 @@ static int vidioc_querycap(struct file *file, void *priv,
1431 cap->capabilities = 1472 cap->capabilities =
1432 V4L2_CAP_SLICED_VBI_CAPTURE | 1473 V4L2_CAP_SLICED_VBI_CAPTURE |
1433 V4L2_CAP_VIDEO_CAPTURE | 1474 V4L2_CAP_VIDEO_CAPTURE |
1434 V4L2_CAP_AUDIO |
1435 V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; 1475 V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
1436 1476
1477 if (dev->audio_mode.has_audio)
1478 cap->capabilities |= V4L2_CAP_AUDIO;
1479
1437 if (dev->tuner_type != TUNER_ABSENT) 1480 if (dev->tuner_type != TUNER_ABSENT)
1438 cap->capabilities |= V4L2_CAP_TUNER; 1481 cap->capabilities |= V4L2_CAP_TUNER;
1439 1482
@@ -1654,9 +1697,9 @@ static int radio_queryctrl(struct file *file, void *priv,
1654 qc->id >= V4L2_CID_LASTP1) 1697 qc->id >= V4L2_CID_LASTP1)
1655 return -EINVAL; 1698 return -EINVAL;
1656 1699
1657 for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { 1700 for (i = 0; i < ARRAY_SIZE(ac97_qctrl); i++) {
1658 if (qc->id && qc->id == em28xx_qctrl[i].id) { 1701 if (qc->id && qc->id == ac97_qctrl[i].id) {
1659 memcpy(qc, &(em28xx_qctrl[i]), sizeof(*qc)); 1702 memcpy(qc, &(ac97_qctrl[i]), sizeof(*qc));
1660 return 0; 1703 return 0;
1661 } 1704 }
1662 } 1705 }
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index a2add61f7d59..0f2ba9a40d17 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -108,6 +108,7 @@
108#define EM2882_BOARD_KWORLD_ATSC_315U 69 108#define EM2882_BOARD_KWORLD_ATSC_315U 69
109#define EM2882_BOARD_EVGA_INDTUBE 70 109#define EM2882_BOARD_EVGA_INDTUBE 70
110#define EM2820_BOARD_SILVERCREST_WEBCAM 71 110#define EM2820_BOARD_SILVERCREST_WEBCAM 71
111#define EM2861_BOARD_GADMEI_UTV330PLUS 72
111 112
112/* Limits minimum and default number of buffers */ 113/* Limits minimum and default number of buffers */
113#define EM28XX_MIN_BUF 4 114#define EM28XX_MIN_BUF 4
@@ -398,6 +399,7 @@ struct em28xx_board {
398 unsigned int has_snapshot_button:1; 399 unsigned int has_snapshot_button:1;
399 unsigned int is_webcam:1; 400 unsigned int is_webcam:1;
400 unsigned int valid:1; 401 unsigned int valid:1;
402 unsigned int has_ir_i2c:1;
401 403
402 unsigned char xclk, i2c_speed; 404 unsigned char xclk, i2c_speed;
403 unsigned char radio_addr; 405 unsigned char radio_addr;
@@ -408,7 +410,7 @@ struct em28xx_board {
408 410
409 struct em28xx_input input[MAX_EM28XX_INPUT]; 411 struct em28xx_input input[MAX_EM28XX_INPUT];
410 struct em28xx_input radio; 412 struct em28xx_input radio;
411 IR_KEYTAB_TYPE *ir_codes; 413 struct ir_scancode_table *ir_codes;
412}; 414};
413 415
414struct em28xx_eeprom { 416struct em28xx_eeprom {
@@ -595,6 +597,10 @@ struct em28xx {
595 struct delayed_work sbutton_query_work; 597 struct delayed_work sbutton_query_work;
596 598
597 struct em28xx_dvb *dvb; 599 struct em28xx_dvb *dvb;
600
601 /* I2C keyboard data */
602 struct i2c_board_info info;
603 struct IR_i2c_init_data init_data;
598}; 604};
599 605
600struct em28xx_ops { 606struct em28xx_ops {
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig
index e994dcac43ff..8897283b0bb4 100644
--- a/drivers/media/video/gspca/Kconfig
+++ b/drivers/media/video/gspca/Kconfig
@@ -47,6 +47,15 @@ config USB_GSPCA_FINEPIX
47 To compile this driver as a module, choose M here: the 47 To compile this driver as a module, choose M here: the
48 module will be called gspca_finepix. 48 module will be called gspca_finepix.
49 49
50config USB_GSPCA_JEILINJ
51 tristate "Jeilin JPEG USB V4L2 driver"
52 depends on VIDEO_V4L2 && USB_GSPCA
53 help
54 Say Y here if you want support for cameras based on this Jeilin chip.
55
56 To compile this driver as a module, choose M here: the
57 module will be called gspca_jeilinj.
58
50config USB_GSPCA_MARS 59config USB_GSPCA_MARS
51 tristate "Mars USB Camera Driver" 60 tristate "Mars USB Camera Driver"
52 depends on VIDEO_V4L2 && USB_GSPCA 61 depends on VIDEO_V4L2 && USB_GSPCA
@@ -103,9 +112,9 @@ config USB_GSPCA_PAC7311
103 module will be called gspca_pac7311. 112 module will be called gspca_pac7311.
104 113
105config USB_GSPCA_SN9C20X 114config USB_GSPCA_SN9C20X
106 tristate "SN9C20X USB Camera Driver" 115 tristate "SN9C20X USB Camera Driver"
107 depends on VIDEO_V4L2 && USB_GSPCA 116 depends on VIDEO_V4L2 && USB_GSPCA
108 help 117 help
109 Say Y here if you want support for cameras based on the 118 Say Y here if you want support for cameras based on the
110 sn9c20x chips (SN9C201 and SN9C202). 119 sn9c20x chips (SN9C201 and SN9C202).
111 120
@@ -113,10 +122,10 @@ config USB_GSPCA_SN9C20X
113 module will be called gspca_sn9c20x. 122 module will be called gspca_sn9c20x.
114 123
115config USB_GSPCA_SN9C20X_EVDEV 124config USB_GSPCA_SN9C20X_EVDEV
116 bool "Enable evdev support" 125 bool "Enable evdev support"
117 depends on USB_GSPCA_SN9C20X && INPUT 126 depends on USB_GSPCA_SN9C20X && INPUT
118 ---help--- 127 ---help---
119 Say Y here in order to enable evdev support for sn9c20x webcam button. 128 Say Y here in order to enable evdev support for sn9c20x webcam button.
120 129
121config USB_GSPCA_SONIXB 130config USB_GSPCA_SONIXB
122 tristate "SONIX Bayer USB Camera Driver" 131 tristate "SONIX Bayer USB Camera Driver"
diff --git a/drivers/media/video/gspca/Makefile b/drivers/media/video/gspca/Makefile
index f6d3b86e9ad5..035616b5e867 100644
--- a/drivers/media/video/gspca/Makefile
+++ b/drivers/media/video/gspca/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_USB_GSPCA) += gspca_main.o
2obj-$(CONFIG_USB_GSPCA_CONEX) += gspca_conex.o 2obj-$(CONFIG_USB_GSPCA_CONEX) += gspca_conex.o
3obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o 3obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o
4obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o 4obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o
5obj-$(CONFIG_USB_GSPCA_JEILINJ) += gspca_jeilinj.o
5obj-$(CONFIG_USB_GSPCA_MARS) += gspca_mars.o 6obj-$(CONFIG_USB_GSPCA_MARS) += gspca_mars.o
6obj-$(CONFIG_USB_GSPCA_MR97310A) += gspca_mr97310a.o 7obj-$(CONFIG_USB_GSPCA_MR97310A) += gspca_mr97310a.o
7obj-$(CONFIG_USB_GSPCA_OV519) += gspca_ov519.o 8obj-$(CONFIG_USB_GSPCA_OV519) += gspca_ov519.o
@@ -30,6 +31,7 @@ gspca_main-objs := gspca.o
30gspca_conex-objs := conex.o 31gspca_conex-objs := conex.o
31gspca_etoms-objs := etoms.o 32gspca_etoms-objs := etoms.o
32gspca_finepix-objs := finepix.o 33gspca_finepix-objs := finepix.o
34gspca_jeilinj-objs := jeilinj.o
33gspca_mars-objs := mars.o 35gspca_mars-objs := mars.o
34gspca_mr97310a-objs := mr97310a.o 36gspca_mr97310a-objs := mr97310a.o
35gspca_ov519-objs := ov519.o 37gspca_ov519-objs := ov519.o
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index 8d48ea1742c2..eca003566ae3 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -820,7 +820,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
820 820
821 cam = &gspca_dev->cam; 821 cam = &gspca_dev->cam;
822 cam->cam_mode = vga_mode; 822 cam->cam_mode = vga_mode;
823 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 823 cam->nmodes = ARRAY_SIZE(vga_mode);
824 824
825 sd->brightness = BRIGHTNESS_DEF; 825 sd->brightness = BRIGHTNESS_DEF;
826 sd->contrast = CONTRAST_DEF; 826 sd->contrast = CONTRAST_DEF;
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index 2c20d06a03e8..c1461e63647f 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -635,10 +635,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
635 sd->sensor = id->driver_info; 635 sd->sensor = id->driver_info;
636 if (sd->sensor == SENSOR_PAS106) { 636 if (sd->sensor == SENSOR_PAS106) {
637 cam->cam_mode = sif_mode; 637 cam->cam_mode = sif_mode;
638 cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; 638 cam->nmodes = ARRAY_SIZE(sif_mode);
639 } else { 639 } else {
640 cam->cam_mode = vga_mode; 640 cam->cam_mode = vga_mode;
641 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 641 cam->nmodes = ARRAY_SIZE(vga_mode);
642 gspca_dev->ctrl_dis = (1 << COLOR_IDX); 642 gspca_dev->ctrl_dis = (1 << COLOR_IDX);
643 } 643 }
644 sd->brightness = BRIGHTNESS_DEF; 644 sd->brightness = BRIGHTNESS_DEF;
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index b8561dfb6c8c..cf6540da1e42 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -47,7 +47,7 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
47MODULE_DESCRIPTION("GSPCA USB Camera Driver"); 47MODULE_DESCRIPTION("GSPCA USB Camera Driver");
48MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
49 49
50#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 6, 0) 50#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 7, 0)
51 51
52#ifdef GSPCA_DEBUG 52#ifdef GSPCA_DEBUG
53int gspca_debug = D_ERR | D_PROBE; 53int gspca_debug = D_ERR | D_PROBE;
@@ -486,6 +486,7 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev)
486 } 486 }
487 PDEBUG(D_STREAM, "use alt %d ep 0x%02x", 487 PDEBUG(D_STREAM, "use alt %d ep 0x%02x",
488 i, ep->desc.bEndpointAddress); 488 i, ep->desc.bEndpointAddress);
489 gspca_dev->alt = i; /* memorize the current alt setting */
489 if (gspca_dev->nbalt > 1) { 490 if (gspca_dev->nbalt > 1) {
490 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, i); 491 ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, i);
491 if (ret < 0) { 492 if (ret < 0) {
@@ -493,7 +494,6 @@ static struct usb_host_endpoint *get_ep(struct gspca_dev *gspca_dev)
493 return NULL; 494 return NULL;
494 } 495 }
495 } 496 }
496 gspca_dev->alt = i; /* memorize the current alt setting */
497 return ep; 497 return ep;
498} 498}
499 499
@@ -512,7 +512,10 @@ static int create_urbs(struct gspca_dev *gspca_dev,
512 if (!gspca_dev->cam.bulk) { /* isoc */ 512 if (!gspca_dev->cam.bulk) { /* isoc */
513 513
514 /* See paragraph 5.9 / table 5-11 of the usb 2.0 spec. */ 514 /* See paragraph 5.9 / table 5-11 of the usb 2.0 spec. */
515 psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); 515 if (gspca_dev->pkt_size == 0)
516 psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
517 else
518 psize = gspca_dev->pkt_size;
516 npkt = gspca_dev->cam.npkt; 519 npkt = gspca_dev->cam.npkt;
517 if (npkt == 0) 520 if (npkt == 0)
518 npkt = 32; /* default value */ 521 npkt = 32; /* default value */
@@ -597,13 +600,18 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
597 /* set the higher alternate setting and 600 /* set the higher alternate setting and
598 * loop until urb submit succeeds */ 601 * loop until urb submit succeeds */
599 gspca_dev->alt = gspca_dev->nbalt; 602 gspca_dev->alt = gspca_dev->nbalt;
603 if (gspca_dev->sd_desc->isoc_init) {
604 ret = gspca_dev->sd_desc->isoc_init(gspca_dev);
605 if (ret < 0)
606 goto out;
607 }
608 ep = get_ep(gspca_dev);
609 if (ep == NULL) {
610 ret = -EIO;
611 goto out;
612 }
600 for (;;) { 613 for (;;) {
601 PDEBUG(D_STREAM, "init transfer alt %d", gspca_dev->alt); 614 PDEBUG(D_STREAM, "init transfer alt %d", gspca_dev->alt);
602 ep = get_ep(gspca_dev);
603 if (ep == NULL) {
604 ret = -EIO;
605 goto out;
606 }
607 ret = create_urbs(gspca_dev, ep); 615 ret = create_urbs(gspca_dev, ep);
608 if (ret < 0) 616 if (ret < 0)
609 goto out; 617 goto out;
@@ -628,21 +636,32 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
628 /* submit the URBs */ 636 /* submit the URBs */
629 for (n = 0; n < gspca_dev->nurbs; n++) { 637 for (n = 0; n < gspca_dev->nurbs; n++) {
630 ret = usb_submit_urb(gspca_dev->urb[n], GFP_KERNEL); 638 ret = usb_submit_urb(gspca_dev->urb[n], GFP_KERNEL);
631 if (ret < 0) { 639 if (ret < 0)
632 PDEBUG(D_ERR|D_STREAM, 640 break;
633 "usb_submit_urb [%d] err %d", n, ret);
634 gspca_dev->streaming = 0;
635 destroy_urbs(gspca_dev);
636 if (ret == -ENOSPC) {
637 msleep(20); /* wait for kill
638 * complete */
639 break; /* try the previous alt */
640 }
641 goto out;
642 }
643 } 641 }
644 if (ret >= 0) 642 if (ret >= 0)
645 break; 643 break;
644 PDEBUG(D_ERR|D_STREAM,
645 "usb_submit_urb alt %d err %d", gspca_dev->alt, ret);
646 gspca_dev->streaming = 0;
647 destroy_urbs(gspca_dev);
648 if (ret != -ENOSPC)
649 goto out;
650
651 /* the bandwidth is not wide enough
652 * negociate or try a lower alternate setting */
653 msleep(20); /* wait for kill complete */
654 if (gspca_dev->sd_desc->isoc_nego) {
655 ret = gspca_dev->sd_desc->isoc_nego(gspca_dev);
656 if (ret < 0)
657 goto out;
658 } else {
659 ep = get_ep(gspca_dev);
660 if (ep == NULL) {
661 ret = -EIO;
662 goto out;
663 }
664 }
646 } 665 }
647out: 666out:
648 mutex_unlock(&gspca_dev->usb_lock); 667 mutex_unlock(&gspca_dev->usb_lock);
@@ -1473,12 +1492,6 @@ static int vidioc_s_parm(struct file *filp, void *priv,
1473 return 0; 1492 return 0;
1474} 1493}
1475 1494
1476static int vidioc_s_std(struct file *filp, void *priv,
1477 v4l2_std_id *parm)
1478{
1479 return 0;
1480}
1481
1482#ifdef CONFIG_VIDEO_V4L1_COMPAT 1495#ifdef CONFIG_VIDEO_V4L1_COMPAT
1483static int vidiocgmbuf(struct file *file, void *priv, 1496static int vidiocgmbuf(struct file *file, void *priv,
1484 struct video_mbuf *mbuf) 1497 struct video_mbuf *mbuf)
@@ -1949,7 +1962,6 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = {
1949 .vidioc_s_jpegcomp = vidioc_s_jpegcomp, 1962 .vidioc_s_jpegcomp = vidioc_s_jpegcomp,
1950 .vidioc_g_parm = vidioc_g_parm, 1963 .vidioc_g_parm = vidioc_g_parm,
1951 .vidioc_s_parm = vidioc_s_parm, 1964 .vidioc_s_parm = vidioc_s_parm,
1952 .vidioc_s_std = vidioc_s_std,
1953 .vidioc_enum_framesizes = vidioc_enum_framesizes, 1965 .vidioc_enum_framesizes = vidioc_enum_framesizes,
1954#ifdef CONFIG_VIDEO_ADV_DEBUG 1966#ifdef CONFIG_VIDEO_ADV_DEBUG
1955 .vidioc_g_register = vidioc_g_register, 1967 .vidioc_g_register = vidioc_g_register,
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 46c4effdfcd5..70b1fd830876 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -98,9 +98,11 @@ struct sd_desc {
98/* mandatory operations */ 98/* mandatory operations */
99 cam_cf_op config; /* called on probe */ 99 cam_cf_op config; /* called on probe */
100 cam_op init; /* called on probe and resume */ 100 cam_op init; /* called on probe and resume */
101 cam_op start; /* called on stream on */ 101 cam_op start; /* called on stream on after URBs creation */
102 cam_pkt_op pkt_scan; 102 cam_pkt_op pkt_scan;
103/* optional operations */ 103/* optional operations */
104 cam_op isoc_init; /* called on stream on before getting the EP */
105 cam_op isoc_nego; /* called when URB submit failed with NOSPC */
104 cam_v_op stopN; /* called on stream off - main alt */ 106 cam_v_op stopN; /* called on stream off - main alt */
105 cam_v_op stop0; /* called on stream off & disconnect - alt 0 */ 107 cam_v_op stop0; /* called on stream off & disconnect - alt 0 */
106 cam_v_op dq_callback; /* called when a frame has been dequeued */ 108 cam_v_op dq_callback; /* called when a frame has been dequeued */
@@ -178,6 +180,7 @@ struct gspca_dev {
178 __u8 iface; /* USB interface number */ 180 __u8 iface; /* USB interface number */
179 __u8 alt; /* USB alternate setting */ 181 __u8 alt; /* USB alternate setting */
180 __u8 nbalt; /* number of USB alternate settings */ 182 __u8 nbalt; /* number of USB alternate settings */
183 u16 pkt_size; /* ISOC packet size */
181}; 184};
182 185
183int gspca_dev_probe(struct usb_interface *intf, 186int gspca_dev_probe(struct usb_interface *intf,
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
new file mode 100644
index 000000000000..dbfa3ed6e8ef
--- /dev/null
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -0,0 +1,388 @@
1/*
2 * Jeilinj subdriver
3 *
4 * Supports some Jeilin dual-mode cameras which use bulk transport and
5 * download raw JPEG data.
6 *
7 * Copyright (C) 2009 Theodore Kilgore
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#define MODULE_NAME "jeilinj"
25
26#include <linux/workqueue.h>
27#include "gspca.h"
28#include "jpeg.h"
29
30MODULE_AUTHOR("Theodore Kilgore <kilgota@auburn.edu>");
31MODULE_DESCRIPTION("GSPCA/JEILINJ USB Camera Driver");
32MODULE_LICENSE("GPL");
33
34/* Default timeouts, in ms */
35#define JEILINJ_CMD_TIMEOUT 500
36#define JEILINJ_DATA_TIMEOUT 1000
37
38/* Maximum transfer size to use. */
39#define JEILINJ_MAX_TRANSFER 0x200
40
41#define FRAME_HEADER_LEN 0x10
42
43/* Structure to hold all of our device specific stuff */
44struct sd {
45 struct gspca_dev gspca_dev; /* !! must be the first item */
46 const struct v4l2_pix_format *cap_mode;
47 /* Driver stuff */
48 struct work_struct work_struct;
49 struct workqueue_struct *work_thread;
50 u8 quality; /* image quality */
51 u8 jpegqual; /* webcam quality */
52 u8 *jpeg_hdr;
53};
54
55 struct jlj_command {
56 unsigned char instruction[2];
57 unsigned char ack_wanted;
58 };
59
60/* AFAICT these cameras will only do 320x240. */
61static struct v4l2_pix_format jlj_mode[] = {
62 { 320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
63 .bytesperline = 320,
64 .sizeimage = 320 * 240,
65 .colorspace = V4L2_COLORSPACE_JPEG,
66 .priv = 0}
67};
68
69/*
70 * cam uses endpoint 0x03 to send commands, 0x84 for read commands,
71 * and 0x82 for bulk transfer.
72 */
73
74/* All commands are two bytes only */
75static int jlj_write2(struct gspca_dev *gspca_dev, unsigned char *command)
76{
77 int retval;
78
79 memcpy(gspca_dev->usb_buf, command, 2);
80 retval = usb_bulk_msg(gspca_dev->dev,
81 usb_sndbulkpipe(gspca_dev->dev, 3),
82 gspca_dev->usb_buf, 2, NULL, 500);
83 if (retval < 0)
84 PDEBUG(D_ERR, "command write [%02x] error %d",
85 gspca_dev->usb_buf[0], retval);
86 return retval;
87}
88
89/* Responses are one byte only */
90static int jlj_read1(struct gspca_dev *gspca_dev, unsigned char response)
91{
92 int retval;
93
94 retval = usb_bulk_msg(gspca_dev->dev,
95 usb_rcvbulkpipe(gspca_dev->dev, 0x84),
96 gspca_dev->usb_buf, 1, NULL, 500);
97 response = gspca_dev->usb_buf[0];
98 if (retval < 0)
99 PDEBUG(D_ERR, "read command [%02x] error %d",
100 gspca_dev->usb_buf[0], retval);
101 return retval;
102}
103
104static int jlj_start(struct gspca_dev *gspca_dev)
105{
106 int i;
107 int retval = -1;
108 u8 response = 0xff;
109 struct jlj_command start_commands[] = {
110 {{0x71, 0x81}, 0},
111 {{0x70, 0x05}, 0},
112 {{0x95, 0x70}, 1},
113 {{0x71, 0x81}, 0},
114 {{0x70, 0x04}, 0},
115 {{0x95, 0x70}, 1},
116 {{0x71, 0x00}, 0},
117 {{0x70, 0x08}, 0},
118 {{0x95, 0x70}, 1},
119 {{0x94, 0x02}, 0},
120 {{0xde, 0x24}, 0},
121 {{0x94, 0x02}, 0},
122 {{0xdd, 0xf0}, 0},
123 {{0x94, 0x02}, 0},
124 {{0xe3, 0x2c}, 0},
125 {{0x94, 0x02}, 0},
126 {{0xe4, 0x00}, 0},
127 {{0x94, 0x02}, 0},
128 {{0xe5, 0x00}, 0},
129 {{0x94, 0x02}, 0},
130 {{0xe6, 0x2c}, 0},
131 {{0x94, 0x03}, 0},
132 {{0xaa, 0x00}, 0},
133 {{0x71, 0x1e}, 0},
134 {{0x70, 0x06}, 0},
135 {{0x71, 0x80}, 0},
136 {{0x70, 0x07}, 0}
137 };
138 for (i = 0; i < ARRAY_SIZE(start_commands); i++) {
139 retval = jlj_write2(gspca_dev, start_commands[i].instruction);
140 if (retval < 0)
141 return retval;
142 if (start_commands[i].ack_wanted)
143 retval = jlj_read1(gspca_dev, response);
144 if (retval < 0)
145 return retval;
146 }
147 PDEBUG(D_ERR, "jlj_start retval is %d", retval);
148 return retval;
149}
150
151static int jlj_stop(struct gspca_dev *gspca_dev)
152{
153 int i;
154 int retval;
155 struct jlj_command stop_commands[] = {
156 {{0x71, 0x00}, 0},
157 {{0x70, 0x09}, 0},
158 {{0x71, 0x80}, 0},
159 {{0x70, 0x05}, 0}
160 };
161 for (i = 0; i < ARRAY_SIZE(stop_commands); i++) {
162 retval = jlj_write2(gspca_dev, stop_commands[i].instruction);
163 if (retval < 0)
164 return retval;
165 }
166 return retval;
167}
168
169/* This function is called as a workqueue function and runs whenever the camera
170 * is streaming data. Because it is a workqueue function it is allowed to sleep
171 * so we can use synchronous USB calls. To avoid possible collisions with other
172 * threads attempting to use the camera's USB interface the gspca usb_lock is
173 * used when performing the one USB control operation inside the workqueue,
174 * which tells the camera to close the stream. In practice the only thing
175 * which needs to be protected against is the usb_set_interface call that
176 * gspca makes during stream_off. Otherwise the camera doesn't provide any
177 * controls that the user could try to change.
178 */
179
180static void jlj_dostream(struct work_struct *work)
181{
182 struct sd *dev = container_of(work, struct sd, work_struct);
183 struct gspca_dev *gspca_dev = &dev->gspca_dev;
184 struct gspca_frame *frame;
185 int blocks_left; /* 0x200-sized blocks remaining in current frame. */
186 int size_in_blocks;
187 int act_len;
188 int discarding = 0; /* true if we failed to get space for frame. */
189 int packet_type;
190 int ret;
191 u8 *buffer;
192
193 buffer = kmalloc(JEILINJ_MAX_TRANSFER, GFP_KERNEL | GFP_DMA);
194 if (!buffer) {
195 PDEBUG(D_ERR, "Couldn't allocate USB buffer");
196 goto quit_stream;
197 }
198 while (gspca_dev->present && gspca_dev->streaming) {
199 if (!gspca_dev->present)
200 goto quit_stream;
201 /* Start a new frame, and add the JPEG header, first thing */
202 frame = gspca_get_i_frame(gspca_dev);
203 if (frame && !discarding)
204 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
205 dev->jpeg_hdr, JPEG_HDR_SZ);
206 else
207 discarding = 1;
208 /*
209 * Now request data block 0. Line 0 reports the size
210 * to download, in blocks of size 0x200, and also tells the
211 * "actual" data size, in bytes, which seems best to ignore.
212 */
213 ret = usb_bulk_msg(gspca_dev->dev,
214 usb_rcvbulkpipe(gspca_dev->dev, 0x82),
215 buffer, JEILINJ_MAX_TRANSFER, &act_len,
216 JEILINJ_DATA_TIMEOUT);
217 PDEBUG(D_STREAM,
218 "Got %d bytes out of %d for Block 0",
219 act_len, JEILINJ_MAX_TRANSFER);
220 if (ret < 0 || act_len < FRAME_HEADER_LEN)
221 goto quit_stream;
222 size_in_blocks = buffer[0x0a];
223 blocks_left = buffer[0x0a] - 1;
224 PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left);
225 packet_type = INTER_PACKET;
226 if (frame && !discarding)
227 /* Toss line 0 of data block 0, keep the rest. */
228 gspca_frame_add(gspca_dev, packet_type,
229 frame, buffer + FRAME_HEADER_LEN,
230 JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN);
231 else
232 discarding = 1;
233 while (blocks_left > 0) {
234 if (!gspca_dev->present)
235 goto quit_stream;
236 ret = usb_bulk_msg(gspca_dev->dev,
237 usb_rcvbulkpipe(gspca_dev->dev, 0x82),
238 buffer, JEILINJ_MAX_TRANSFER, &act_len,
239 JEILINJ_DATA_TIMEOUT);
240 if (ret < 0 || act_len < JEILINJ_MAX_TRANSFER)
241 goto quit_stream;
242 PDEBUG(D_STREAM,
243 "%d blocks remaining for frame", blocks_left);
244 blocks_left -= 1;
245 if (blocks_left == 0)
246 packet_type = LAST_PACKET;
247 else
248 packet_type = INTER_PACKET;
249 if (frame && !discarding)
250 gspca_frame_add(gspca_dev, packet_type,
251 frame, buffer,
252 JEILINJ_MAX_TRANSFER);
253 else
254 discarding = 1;
255 }
256 }
257quit_stream:
258 mutex_lock(&gspca_dev->usb_lock);
259 if (gspca_dev->present)
260 jlj_stop(gspca_dev);
261 mutex_unlock(&gspca_dev->usb_lock);
262 kfree(buffer);
263}
264
265/* This function is called at probe time just before sd_init */
266static int sd_config(struct gspca_dev *gspca_dev,
267 const struct usb_device_id *id)
268{
269 struct cam *cam = &gspca_dev->cam;
270 struct sd *dev = (struct sd *) gspca_dev;
271
272 dev->quality = 85;
273 dev->jpegqual = 85;
274 PDEBUG(D_PROBE,
275 "JEILINJ camera detected"
276 " (vid/pid 0x%04X:0x%04X)", id->idVendor, id->idProduct);
277 cam->cam_mode = jlj_mode;
278 cam->nmodes = 1;
279 cam->bulk = 1;
280 /* We don't use the buffer gspca allocates so make it small. */
281 cam->bulk_size = 32;
282 INIT_WORK(&dev->work_struct, jlj_dostream);
283 return 0;
284}
285
286/* called on streamoff with alt==0 and on disconnect */
287/* the usb_lock is held at entry - restore on exit */
288static void sd_stop0(struct gspca_dev *gspca_dev)
289{
290 struct sd *dev = (struct sd *) gspca_dev;
291
292 /* wait for the work queue to terminate */
293 mutex_unlock(&gspca_dev->usb_lock);
294 /* This waits for jlj_dostream to finish */
295 destroy_workqueue(dev->work_thread);
296 dev->work_thread = NULL;
297 mutex_lock(&gspca_dev->usb_lock);
298 kfree(dev->jpeg_hdr);
299}
300
301/* this function is called at probe and resume time */
302static int sd_init(struct gspca_dev *gspca_dev)
303{
304 return 0;
305}
306
307/* Set up for getting frames. */
308static int sd_start(struct gspca_dev *gspca_dev)
309{
310 struct sd *dev = (struct sd *) gspca_dev;
311 int ret;
312
313 /* create the JPEG header */
314 dev->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
315 jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width,
316 0x21); /* JPEG 422 */
317 jpeg_set_qual(dev->jpeg_hdr, dev->quality);
318 PDEBUG(D_STREAM, "Start streaming at 320x240");
319 ret = jlj_start(gspca_dev);
320 if (ret < 0) {
321 PDEBUG(D_ERR, "Start streaming command failed");
322 return ret;
323 }
324 /* Start the workqueue function to do the streaming */
325 dev->work_thread = create_singlethread_workqueue(MODULE_NAME);
326 queue_work(dev->work_thread, &dev->work_struct);
327
328 return 0;
329}
330
331/* Table of supported USB devices */
332static const __devinitdata struct usb_device_id device_table[] = {
333 {USB_DEVICE(0x0979, 0x0280)},
334 {}
335};
336
337MODULE_DEVICE_TABLE(usb, device_table);
338
339/* sub-driver description */
340static const struct sd_desc sd_desc = {
341 .name = MODULE_NAME,
342 .config = sd_config,
343 .init = sd_init,
344 .start = sd_start,
345 .stop0 = sd_stop0,
346};
347
348/* -- device connect -- */
349static int sd_probe(struct usb_interface *intf,
350 const struct usb_device_id *id)
351{
352 return gspca_dev_probe(intf, id,
353 &sd_desc,
354 sizeof(struct sd),
355 THIS_MODULE);
356}
357
358static struct usb_driver sd_driver = {
359 .name = MODULE_NAME,
360 .id_table = device_table,
361 .probe = sd_probe,
362 .disconnect = gspca_disconnect,
363#ifdef CONFIG_PM
364 .suspend = gspca_suspend,
365 .resume = gspca_resume,
366#endif
367};
368
369/* -- module insert / remove -- */
370static int __init sd_mod_init(void)
371{
372 int ret;
373
374 ret = usb_register(&sd_driver);
375 if (ret < 0)
376 return ret;
377 PDEBUG(D_PROBE, "registered");
378 return 0;
379}
380
381static void __exit sd_mod_exit(void)
382{
383 usb_deregister(&sd_driver);
384 PDEBUG(D_PROBE, "deregistered");
385}
386
387module_init(sd_mod_init);
388module_exit(sd_mod_exit);
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
index 7127321ace8c..6b89f33a4ce0 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
@@ -178,8 +178,10 @@ sensor_found:
178 178
179 sens_priv->settings = 179 sens_priv->settings =
180 kmalloc(sizeof(s32)*ARRAY_SIZE(s5k83a_ctrls), GFP_KERNEL); 180 kmalloc(sizeof(s32)*ARRAY_SIZE(s5k83a_ctrls), GFP_KERNEL);
181 if (!sens_priv->settings) 181 if (!sens_priv->settings) {
182 kfree(sens_priv);
182 return -ENOMEM; 183 return -ENOMEM;
184 }
183 185
184 sd->gspca_dev.cam.cam_mode = s5k83a_modes; 186 sd->gspca_dev.cam.cam_mode = s5k83a_modes;
185 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes); 187 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(s5k83a_modes);
diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c
index 30132513400c..140c8f320e47 100644
--- a/drivers/media/video/gspca/mr97310a.c
+++ b/drivers/media/video/gspca/mr97310a.c
@@ -3,6 +3,21 @@
3 * 3 *
4 * Copyright (C) 2009 Kyle Guinn <elyk03@gmail.com> 4 * Copyright (C) 2009 Kyle Guinn <elyk03@gmail.com>
5 * 5 *
6 * Support for the MR97310A cameras in addition to the Aiptek Pencam VGA+
7 * and for the routines for detecting and classifying these various cameras,
8 *
9 * Copyright (C) 2009 Theodore Kilgore <kilgota@auburn.edu>
10 *
11 * Acknowledgements:
12 *
13 * The MR97311A support in gspca/mars.c has been helpful in understanding some
14 * of the registers in these cameras.
15 *
16 * Hans de Goede <hdgoede@redhat.com> and
17 * Thomas Kaiser <thomas@kaiser-linux.li>
18 * have assisted with their experience. Each of them has also helped by
19 * testing a previously unsupported camera.
20 *
6 * This program is free software; you can redistribute it and/or modify 21 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 22 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 23 * the Free Software Foundation; either version 2 of the License, or
@@ -22,18 +37,108 @@
22 37
23#include "gspca.h" 38#include "gspca.h"
24 39
25MODULE_AUTHOR("Kyle Guinn <elyk03@gmail.com>"); 40#define CAM_TYPE_CIF 0
41#define CAM_TYPE_VGA 1
42
43#define MR97310A_BRIGHTNESS_MIN -254
44#define MR97310A_BRIGHTNESS_MAX 255
45#define MR97310A_BRIGHTNESS_DEFAULT 0
46
47#define MR97310A_EXPOSURE_MIN 300
48#define MR97310A_EXPOSURE_MAX 4095
49#define MR97310A_EXPOSURE_DEFAULT 1000
50
51#define MR97310A_GAIN_MIN 0
52#define MR97310A_GAIN_MAX 31
53#define MR97310A_GAIN_DEFAULT 25
54
55MODULE_AUTHOR("Kyle Guinn <elyk03@gmail.com>,"
56 "Theodore Kilgore <kilgota@auburn.edu>");
26MODULE_DESCRIPTION("GSPCA/Mars-Semi MR97310A USB Camera Driver"); 57MODULE_DESCRIPTION("GSPCA/Mars-Semi MR97310A USB Camera Driver");
27MODULE_LICENSE("GPL"); 58MODULE_LICENSE("GPL");
28 59
60/* global parameters */
61int force_sensor_type = -1;
62module_param(force_sensor_type, int, 0644);
63MODULE_PARM_DESC(force_sensor_type, "Force sensor type (-1 (auto), 0 or 1)");
64
29/* specific webcam descriptor */ 65/* specific webcam descriptor */
30struct sd { 66struct sd {
31 struct gspca_dev gspca_dev; /* !! must be the first item */ 67 struct gspca_dev gspca_dev; /* !! must be the first item */
32 u8 sof_read; 68 u8 sof_read;
69 u8 cam_type; /* 0 is CIF and 1 is VGA */
70 u8 sensor_type; /* We use 0 and 1 here, too. */
71 u8 do_lcd_stop;
72
73 int brightness;
74 u16 exposure;
75 u8 gain;
76};
77
78struct sensor_w_data {
79 u8 reg;
80 u8 flags;
81 u8 data[16];
82 int len;
33}; 83};
34 84
85static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
86static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
87static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val);
88static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val);
89static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val);
90static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val);
91static void setbrightness(struct gspca_dev *gspca_dev);
92static void setexposure(struct gspca_dev *gspca_dev);
93static void setgain(struct gspca_dev *gspca_dev);
94
35/* V4L2 controls supported by the driver */ 95/* V4L2 controls supported by the driver */
36static struct ctrl sd_ctrls[] = { 96static struct ctrl sd_ctrls[] = {
97 {
98#define BRIGHTNESS_IDX 0
99 {
100 .id = V4L2_CID_BRIGHTNESS,
101 .type = V4L2_CTRL_TYPE_INTEGER,
102 .name = "Brightness",
103 .minimum = MR97310A_BRIGHTNESS_MIN,
104 .maximum = MR97310A_BRIGHTNESS_MAX,
105 .step = 1,
106 .default_value = MR97310A_BRIGHTNESS_DEFAULT,
107 .flags = 0,
108 },
109 .set = sd_setbrightness,
110 .get = sd_getbrightness,
111 },
112 {
113#define EXPOSURE_IDX 1
114 {
115 .id = V4L2_CID_EXPOSURE,
116 .type = V4L2_CTRL_TYPE_INTEGER,
117 .name = "Exposure",
118 .minimum = MR97310A_EXPOSURE_MIN,
119 .maximum = MR97310A_EXPOSURE_MAX,
120 .step = 1,
121 .default_value = MR97310A_EXPOSURE_DEFAULT,
122 .flags = 0,
123 },
124 .set = sd_setexposure,
125 .get = sd_getexposure,
126 },
127 {
128#define GAIN_IDX 2
129 {
130 .id = V4L2_CID_GAIN,
131 .type = V4L2_CTRL_TYPE_INTEGER,
132 .name = "Gain",
133 .minimum = MR97310A_GAIN_MIN,
134 .maximum = MR97310A_GAIN_MAX,
135 .step = 1,
136 .default_value = MR97310A_GAIN_DEFAULT,
137 .flags = 0,
138 },
139 .set = sd_setgain,
140 .get = sd_getgain,
141 },
37}; 142};
38 143
39static const struct v4l2_pix_format vga_mode[] = { 144static const struct v4l2_pix_format vga_mode[] = {
@@ -65,7 +170,7 @@ static const struct v4l2_pix_format vga_mode[] = {
65}; 170};
66 171
67/* the bytes to write are in gspca_dev->usb_buf */ 172/* the bytes to write are in gspca_dev->usb_buf */
68static int reg_w(struct gspca_dev *gspca_dev, int len) 173static int mr_write(struct gspca_dev *gspca_dev, int len)
69{ 174{
70 int rc; 175 int rc;
71 176
@@ -78,15 +183,249 @@ static int reg_w(struct gspca_dev *gspca_dev, int len)
78 return rc; 183 return rc;
79} 184}
80 185
186/* the bytes are read into gspca_dev->usb_buf */
187static int mr_read(struct gspca_dev *gspca_dev, int len)
188{
189 int rc;
190
191 rc = usb_bulk_msg(gspca_dev->dev,
192 usb_rcvbulkpipe(gspca_dev->dev, 3),
193 gspca_dev->usb_buf, len, NULL, 500);
194 if (rc < 0)
195 PDEBUG(D_ERR, "reg read [%02x] error %d",
196 gspca_dev->usb_buf[0], rc);
197 return rc;
198}
199
200static int sensor_write_reg(struct gspca_dev *gspca_dev, u8 reg, u8 flags,
201 const u8 *data, int len)
202{
203 gspca_dev->usb_buf[0] = 0x1f;
204 gspca_dev->usb_buf[1] = flags;
205 gspca_dev->usb_buf[2] = reg;
206 memcpy(gspca_dev->usb_buf + 3, data, len);
207
208 return mr_write(gspca_dev, len + 3);
209}
210
211static int sensor_write_regs(struct gspca_dev *gspca_dev,
212 const struct sensor_w_data *data, int len)
213{
214 int i, rc;
215
216 for (i = 0; i < len; i++) {
217 rc = sensor_write_reg(gspca_dev, data[i].reg, data[i].flags,
218 data[i].data, data[i].len);
219 if (rc < 0)
220 return rc;
221 }
222
223 return 0;
224}
225
226static int sensor_write1(struct gspca_dev *gspca_dev, u8 reg, u8 data)
227{
228 struct sd *sd = (struct sd *) gspca_dev;
229 u8 buf, confirm_reg;
230 int rc;
231
232 buf = data;
233 rc = sensor_write_reg(gspca_dev, reg, 0x01, &buf, 1);
234 if (rc < 0)
235 return rc;
236
237 buf = 0x01;
238 confirm_reg = sd->sensor_type ? 0x13 : 0x11;
239 rc = sensor_write_reg(gspca_dev, confirm_reg, 0x00, &buf, 1);
240 if (rc < 0)
241 return rc;
242
243 return 0;
244}
245
246static int cam_get_response16(struct gspca_dev *gspca_dev)
247{
248 __u8 *data = gspca_dev->usb_buf;
249 int err_code;
250
251 data[0] = 0x21;
252 err_code = mr_write(gspca_dev, 1);
253 if (err_code < 0)
254 return err_code;
255
256 err_code = mr_read(gspca_dev, 16);
257 return err_code;
258}
259
260static int zero_the_pointer(struct gspca_dev *gspca_dev)
261{
262 __u8 *data = gspca_dev->usb_buf;
263 int err_code;
264 u8 status = 0;
265 int tries = 0;
266
267 err_code = cam_get_response16(gspca_dev);
268 if (err_code < 0)
269 return err_code;
270
271 err_code = mr_write(gspca_dev, 1);
272 data[0] = 0x19;
273 data[1] = 0x51;
274 err_code = mr_write(gspca_dev, 2);
275 if (err_code < 0)
276 return err_code;
277
278 err_code = cam_get_response16(gspca_dev);
279 if (err_code < 0)
280 return err_code;
281
282 data[0] = 0x19;
283 data[1] = 0xba;
284 err_code = mr_write(gspca_dev, 2);
285 if (err_code < 0)
286 return err_code;
287
288 err_code = cam_get_response16(gspca_dev);
289 if (err_code < 0)
290 return err_code;
291
292 data[0] = 0x19;
293 data[1] = 0x00;
294 err_code = mr_write(gspca_dev, 2);
295 if (err_code < 0)
296 return err_code;
297
298 err_code = cam_get_response16(gspca_dev);
299 if (err_code < 0)
300 return err_code;
301
302 data[0] = 0x19;
303 data[1] = 0x00;
304 err_code = mr_write(gspca_dev, 2);
305 if (err_code < 0)
306 return err_code;
307
308 while (status != 0x0a && tries < 256) {
309 err_code = cam_get_response16(gspca_dev);
310 status = data[0];
311 tries++;
312 if (err_code < 0)
313 return err_code;
314 }
315 if (status != 0x0a)
316 PDEBUG(D_ERR, "status is %02x", status);
317
318 tries = 0;
319 while (tries < 4) {
320 data[0] = 0x19;
321 data[1] = 0x00;
322 err_code = mr_write(gspca_dev, 2);
323 if (err_code < 0)
324 return err_code;
325
326 err_code = cam_get_response16(gspca_dev);
327 status = data[0];
328 tries++;
329 if (err_code < 0)
330 return err_code;
331 }
332
333 data[0] = 0x19;
334 err_code = mr_write(gspca_dev, 1);
335 if (err_code < 0)
336 return err_code;
337
338 err_code = mr_read(gspca_dev, 16);
339 if (err_code < 0)
340 return err_code;
341
342 return 0;
343}
344
345static u8 get_sensor_id(struct gspca_dev *gspca_dev)
346{
347 int err_code;
348
349 gspca_dev->usb_buf[0] = 0x1e;
350 err_code = mr_write(gspca_dev, 1);
351 if (err_code < 0)
352 return err_code;
353
354 err_code = mr_read(gspca_dev, 16);
355 if (err_code < 0)
356 return err_code;
357
358 PDEBUG(D_PROBE, "Byte zero reported is %01x", gspca_dev->usb_buf[0]);
359
360 return gspca_dev->usb_buf[0];
361}
362
81/* this function is called at probe time */ 363/* this function is called at probe time */
82static int sd_config(struct gspca_dev *gspca_dev, 364static int sd_config(struct gspca_dev *gspca_dev,
83 const struct usb_device_id *id) 365 const struct usb_device_id *id)
84{ 366{
367 struct sd *sd = (struct sd *) gspca_dev;
85 struct cam *cam; 368 struct cam *cam;
369 __u8 *data = gspca_dev->usb_buf;
370 int err_code;
86 371
87 cam = &gspca_dev->cam; 372 cam = &gspca_dev->cam;
88 cam->cam_mode = vga_mode; 373 cam->cam_mode = vga_mode;
89 cam->nmodes = ARRAY_SIZE(vga_mode); 374 cam->nmodes = ARRAY_SIZE(vga_mode);
375
376 if (id->idProduct == 0x010e) {
377 sd->cam_type = CAM_TYPE_CIF;
378 cam->nmodes--;
379
380 data[0] = 0x01;
381 data[1] = 0x01;
382 err_code = mr_write(gspca_dev, 2);
383 if (err_code < 0)
384 return err_code;
385
386 msleep(200);
387 data[0] = get_sensor_id(gspca_dev);
388 /*
389 * Known CIF cameras. If you have another to report, please do
390 *
391 * Name byte just read sd->sensor_type
392 * reported by
393 * Sakar Spy-shot 0x28 T. Kilgore 0
394 * Innovage 0xf5 (unstable) T. Kilgore 0
395 * Vivitar Mini 0x53 H. De Goede 0
396 * Vivitar Mini 0x04 / 0x24 E. Rodriguez 0
397 * Vivitar Mini 0x08 T. Kilgore 1
398 * Elta-Media 8212dc 0x23 T. Kaiser 1
399 * Philips dig. keych. 0x37 T. Kilgore 1
400 */
401 if ((data[0] & 0x78) == 8 ||
402 ((data[0] & 0x2) == 0x2 && data[0] != 0x53))
403 sd->sensor_type = 1;
404 else
405 sd->sensor_type = 0;
406
407 PDEBUG(D_PROBE, "MR97310A CIF camera detected, sensor: %d",
408 sd->sensor_type);
409
410 if (force_sensor_type != -1) {
411 sd->sensor_type = !! force_sensor_type;
412 PDEBUG(D_PROBE, "Forcing sensor type to: %d",
413 sd->sensor_type);
414 }
415
416 if (sd->sensor_type == 0)
417 gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX);
418 } else {
419 sd->cam_type = CAM_TYPE_VGA;
420 PDEBUG(D_PROBE, "MR97310A VGA camera detected");
421 gspca_dev->ctrl_dis = (1 << BRIGHTNESS_IDX) |
422 (1 << EXPOSURE_IDX) | (1 << GAIN_IDX);
423 }
424
425 sd->brightness = MR97310A_BRIGHTNESS_DEFAULT;
426 sd->exposure = MR97310A_EXPOSURE_DEFAULT;
427 sd->gain = MR97310A_GAIN_DEFAULT;
428
90 return 0; 429 return 0;
91} 430}
92 431
@@ -96,183 +435,462 @@ static int sd_init(struct gspca_dev *gspca_dev)
96 return 0; 435 return 0;
97} 436}
98 437
99static int sd_start(struct gspca_dev *gspca_dev) 438static int start_cif_cam(struct gspca_dev *gspca_dev)
100{ 439{
101 struct sd *sd = (struct sd *) gspca_dev; 440 struct sd *sd = (struct sd *) gspca_dev;
102 __u8 *data = gspca_dev->usb_buf; 441 __u8 *data = gspca_dev->usb_buf;
103 int err_code; 442 int err_code;
104 443 const __u8 startup_string[] = {
105 sd->sof_read = 0; 444 0x00,
106 445 0x0d,
107 /* Note: register descriptions guessed from MR97113A driver */ 446 0x01,
108 447 0x00, /* Hsize/8 for 352 or 320 */
448 0x00, /* Vsize/4 for 288 or 240 */
449 0x13, /* or 0xbb, depends on sensor */
450 0x00, /* Hstart, depends on res. */
451 0x00, /* reserved ? */
452 0x00, /* Vstart, depends on res. and sensor */
453 0x50, /* 0x54 to get 176 or 160 */
454 0xc0
455 };
456
457 /* Note: Some of the above descriptions guessed from MR97113A driver */
109 data[0] = 0x01; 458 data[0] = 0x01;
110 data[1] = 0x01; 459 data[1] = 0x01;
111 err_code = reg_w(gspca_dev, 2); 460 err_code = mr_write(gspca_dev, 2);
112 if (err_code < 0) 461 if (err_code < 0)
113 return err_code; 462 return err_code;
114 463
115 data[0] = 0x00; 464 memcpy(data, startup_string, 11);
116 data[1] = 0x0d; 465 if (sd->sensor_type)
117 data[2] = 0x01; 466 data[5] = 0xbb;
118 data[5] = 0x2b;
119 data[7] = 0x00;
120 data[9] = 0x50; /* reg 8, no scale down */
121 data[10] = 0xc0;
122 467
123 switch (gspca_dev->width) { 468 switch (gspca_dev->width) {
124 case 160: 469 case 160:
125 data[9] |= 0x0c; /* reg 8, 4:1 scale down */ 470 data[9] |= 0x04; /* reg 8, 2:1 scale down from 320 */
126 /* fall thru */ 471 /* fall thru */
127 case 320: 472 case 320:
128 data[9] |= 0x04; /* reg 8, 2:1 scale down */
129 /* fall thru */
130 case 640:
131 default: 473 default:
132 data[3] = 0x50; /* reg 2, H size */ 474 data[3] = 0x28; /* reg 2, H size/8 */
133 data[4] = 0x78; /* reg 3, V size */ 475 data[4] = 0x3c; /* reg 3, V size/4 */
134 data[6] = 0x04; /* reg 5, H start */ 476 data[6] = 0x14; /* reg 5, H start */
135 data[8] = 0x03; /* reg 7, V start */ 477 data[8] = 0x1a + sd->sensor_type; /* reg 7, V start */
136 break; 478 break;
137
138 case 176: 479 case 176:
139 data[9] |= 0x04; /* reg 8, 2:1 scale down */ 480 data[9] |= 0x04; /* reg 8, 2:1 scale down from 352 */
140 /* fall thru */ 481 /* fall thru */
141 case 352: 482 case 352:
142 data[3] = 0x2c; /* reg 2, H size */ 483 data[3] = 0x2c; /* reg 2, H size/8 */
143 data[4] = 0x48; /* reg 3, V size */ 484 data[4] = 0x48; /* reg 3, V size/4 */
144 data[6] = 0x94; /* reg 5, H start */ 485 data[6] = 0x06; /* reg 5, H start */
145 data[8] = 0x63; /* reg 7, V start */ 486 data[8] = 0x06 + sd->sensor_type; /* reg 7, V start */
146 break; 487 break;
147 } 488 }
148 489 err_code = mr_write(gspca_dev, 11);
149 err_code = reg_w(gspca_dev, 11);
150 if (err_code < 0) 490 if (err_code < 0)
151 return err_code; 491 return err_code;
152 492
153 data[0] = 0x0a; 493 if (!sd->sensor_type) {
154 data[1] = 0x80; 494 const struct sensor_w_data cif_sensor0_init_data[] = {
155 err_code = reg_w(gspca_dev, 2); 495 {0x02, 0x00, {0x03, 0x5a, 0xb5, 0x01,
496 0x0f, 0x14, 0x0f, 0x10}, 8},
497 {0x0c, 0x00, {0x04, 0x01, 0x01, 0x00, 0x1f}, 5},
498 {0x12, 0x00, {0x07}, 1},
499 {0x1f, 0x00, {0x06}, 1},
500 {0x27, 0x00, {0x04}, 1},
501 {0x29, 0x00, {0x0c}, 1},
502 {0x40, 0x00, {0x40, 0x00, 0x04}, 3},
503 {0x50, 0x00, {0x60}, 1},
504 {0x60, 0x00, {0x06}, 1},
505 {0x6b, 0x00, {0x85, 0x85, 0xc8, 0xc8, 0xc8, 0xc8}, 6},
506 {0x72, 0x00, {0x1e, 0x56}, 2},
507 {0x75, 0x00, {0x58, 0x40, 0xa2, 0x02, 0x31, 0x02,
508 0x31, 0x80, 0x00}, 9},
509 {0x11, 0x00, {0x01}, 1},
510 {0, 0, {0}, 0}
511 };
512 err_code = sensor_write_regs(gspca_dev, cif_sensor0_init_data,
513 ARRAY_SIZE(cif_sensor0_init_data));
514 } else { /* sd->sensor_type = 1 */
515 const struct sensor_w_data cif_sensor1_init_data[] = {
516 /* Reg 3,4, 7,8 get set by the controls */
517 {0x02, 0x00, {0x10}, 1},
518 {0x05, 0x01, {0x22}, 1}, /* 5/6 also seen as 65h/32h */
519 {0x06, 0x01, {0x00}, 1},
520 {0x09, 0x02, {0x0e}, 1},
521 {0x0a, 0x02, {0x05}, 1},
522 {0x0b, 0x02, {0x05}, 1},
523 {0x0c, 0x02, {0x0f}, 1},
524 {0x0d, 0x02, {0x07}, 1},
525 {0x0e, 0x02, {0x0c}, 1},
526 {0x0f, 0x00, {0x00}, 1},
527 {0x10, 0x00, {0x06}, 1},
528 {0x11, 0x00, {0x07}, 1},
529 {0x12, 0x00, {0x00}, 1},
530 {0x13, 0x00, {0x01}, 1},
531 {0, 0, {0}, 0}
532 };
533 err_code = sensor_write_regs(gspca_dev, cif_sensor1_init_data,
534 ARRAY_SIZE(cif_sensor1_init_data));
535 }
156 if (err_code < 0) 536 if (err_code < 0)
157 return err_code; 537 return err_code;
158 538
159 data[0] = 0x14; 539 setbrightness(gspca_dev);
160 data[1] = 0x0a; 540 setexposure(gspca_dev);
161 err_code = reg_w(gspca_dev, 2); 541 setgain(gspca_dev);
162 if (err_code < 0)
163 return err_code;
164 542
165 data[0] = 0x1b; 543 msleep(200);
166 data[1] = 0x00;
167 err_code = reg_w(gspca_dev, 2);
168 if (err_code < 0)
169 return err_code;
170 544
171 data[0] = 0x15; 545 data[0] = 0x00;
172 data[1] = 0x16; 546 data[1] = 0x4d; /* ISOC transfering enable... */
173 err_code = reg_w(gspca_dev, 2); 547 err_code = mr_write(gspca_dev, 2);
174 if (err_code < 0) 548 if (err_code < 0)
175 return err_code; 549 return err_code;
176 550
177 data[0] = 0x16; 551 return 0;
178 data[1] = 0x10; 552}
179 err_code = reg_w(gspca_dev, 2);
180 if (err_code < 0)
181 return err_code;
182 553
183 data[0] = 0x17; 554static int start_vga_cam(struct gspca_dev *gspca_dev)
184 data[1] = 0x3a; 555{
185 err_code = reg_w(gspca_dev, 2); 556 struct sd *sd = (struct sd *) gspca_dev;
186 if (err_code < 0) 557 __u8 *data = gspca_dev->usb_buf;
187 return err_code; 558 int err_code;
559 const __u8 startup_string[] = {0x00, 0x0d, 0x01, 0x00, 0x00, 0x2b,
560 0x00, 0x00, 0x00, 0x50, 0xc0};
188 561
189 data[0] = 0x18; 562 /* What some of these mean is explained in start_cif_cam(), above */
190 data[1] = 0x68; 563 sd->sof_read = 0;
191 err_code = reg_w(gspca_dev, 2);
192 if (err_code < 0)
193 return err_code;
194 564
195 data[0] = 0x1f; 565 /*
196 data[1] = 0x00; 566 * We have to know which camera we have, because the register writes
197 data[2] = 0x02; 567 * depend upon the camera. This test, run before we actually enter
198 data[3] = 0x06; 568 * the initialization routine, distinguishes most of the cameras, If
199 data[4] = 0x59; 569 * needed, another routine is done later, too.
200 data[5] = 0x0c; 570 */
201 data[6] = 0x16; 571 memset(data, 0, 16);
202 data[7] = 0x00; 572 data[0] = 0x20;
203 data[8] = 0x07; 573 err_code = mr_write(gspca_dev, 1);
204 data[9] = 0x00;
205 data[10] = 0x01;
206 err_code = reg_w(gspca_dev, 11);
207 if (err_code < 0) 574 if (err_code < 0)
208 return err_code; 575 return err_code;
209 576
210 data[0] = 0x1f; 577 err_code = mr_read(gspca_dev, 16);
211 data[1] = 0x04;
212 data[2] = 0x11;
213 data[3] = 0x01;
214 err_code = reg_w(gspca_dev, 4);
215 if (err_code < 0) 578 if (err_code < 0)
216 return err_code; 579 return err_code;
217 580
218 data[0] = 0x1f; 581 PDEBUG(D_PROBE, "Byte reported is %02x", data[0]);
219 data[1] = 0x00; 582
220 data[2] = 0x0a; 583 msleep(200);
221 data[3] = 0x00; 584 /*
222 data[4] = 0x01; 585 * Known VGA cameras. If you have another to report, please do
223 data[5] = 0x00; 586 *
224 data[6] = 0x00; 587 * Name byte just read sd->sensor_type
225 data[7] = 0x01; 588 * sd->do_lcd_stop
226 data[8] = 0x00; 589 * Aiptek Pencam VGA+ 0x31 0 1
227 data[9] = 0x0a; 590 * ION digital 0x31 0 1
228 err_code = reg_w(gspca_dev, 10); 591 * Argus DC-1620 0x30 1 0
229 if (err_code < 0) 592 * Argus QuickClix 0x30 1 1 (not caught here)
230 return err_code; 593 */
594 sd->sensor_type = data[0] & 1;
595 sd->do_lcd_stop = (~data[0]) & 1;
596
597
231 598
232 data[0] = 0x1f; 599 /* Streaming setup begins here. */
233 data[1] = 0x04; 600
234 data[2] = 0x11; 601
235 data[3] = 0x01; 602 data[0] = 0x01;
236 err_code = reg_w(gspca_dev, 4); 603 data[1] = 0x01;
604 err_code = mr_write(gspca_dev, 2);
237 if (err_code < 0) 605 if (err_code < 0)
238 return err_code; 606 return err_code;
239 607
240 data[0] = 0x1f; 608 /*
241 data[1] = 0x00; 609 * A second test can now resolve any remaining ambiguity in the
242 data[2] = 0x12; 610 * identification of the camera type,
243 data[3] = 0x00; 611 */
244 data[4] = 0x63; 612 if (!sd->sensor_type) {
245 data[5] = 0x00; 613 data[0] = get_sensor_id(gspca_dev);
246 data[6] = 0x70; 614 if (data[0] == 0x7f) {
247 data[7] = 0x00; 615 sd->sensor_type = 1;
248 data[8] = 0x00; 616 PDEBUG(D_PROBE, "sensor_type corrected to 1");
249 err_code = reg_w(gspca_dev, 9); 617 }
618 msleep(200);
619 }
620
621 if (force_sensor_type != -1) {
622 sd->sensor_type = !! force_sensor_type;
623 PDEBUG(D_PROBE, "Forcing sensor type to: %d",
624 sd->sensor_type);
625 }
626
627 /*
628 * Known VGA cameras.
629 * This test is only run if the previous test returned 0x30, but
630 * here is the information for all others, too, just for reference.
631 *
632 * Name byte just read sd->sensor_type
633 *
634 * Aiptek Pencam VGA+ 0xfb (this test not run) 1
635 * ION digital 0xbd (this test not run) 1
636 * Argus DC-1620 0xe5 (no change) 0
637 * Argus QuickClix 0x7f (reclassified) 1
638 */
639 memcpy(data, startup_string, 11);
640 if (!sd->sensor_type) {
641 data[5] = 0x00;
642 data[10] = 0x91;
643 }
644
645 switch (gspca_dev->width) {
646 case 160:
647 data[9] |= 0x0c; /* reg 8, 4:1 scale down */
648 /* fall thru */
649 case 320:
650 data[9] |= 0x04; /* reg 8, 2:1 scale down */
651 /* fall thru */
652 case 640:
653 default:
654 data[3] = 0x50; /* reg 2, H size/8 */
655 data[4] = 0x78; /* reg 3, V size/4 */
656 data[6] = 0x04; /* reg 5, H start */
657 data[8] = 0x03; /* reg 7, V start */
658 if (sd->do_lcd_stop)
659 data[8] = 0x04; /* Bayer tile shifted */
660 break;
661
662 case 176:
663 data[9] |= 0x04; /* reg 8, 2:1 scale down */
664 /* fall thru */
665 case 352:
666 data[3] = 0x2c; /* reg 2, H size */
667 data[4] = 0x48; /* reg 3, V size */
668 data[6] = 0x94; /* reg 5, H start */
669 data[8] = 0x63; /* reg 7, V start */
670 if (sd->do_lcd_stop)
671 data[8] = 0x64; /* Bayer tile shifted */
672 break;
673 }
674
675 err_code = mr_write(gspca_dev, 11);
250 if (err_code < 0) 676 if (err_code < 0)
251 return err_code; 677 return err_code;
252 678
253 data[0] = 0x1f; 679 if (!sd->sensor_type) {
254 data[1] = 0x04; 680 /* The only known sensor_type 0 cam is the Argus DC-1620 */
255 data[2] = 0x11; 681 const struct sensor_w_data vga_sensor0_init_data[] = {
256 data[3] = 0x01; 682 {0x01, 0x00, {0x0c, 0x00, 0x04}, 3},
257 err_code = reg_w(gspca_dev, 4); 683 {0x14, 0x00, {0x01, 0xe4, 0x02, 0x84}, 4},
684 {0x20, 0x00, {0x00, 0x80, 0x00, 0x08}, 4},
685 {0x25, 0x00, {0x03, 0xa9, 0x80}, 3},
686 {0x30, 0x00, {0x30, 0x18, 0x10, 0x18}, 4},
687 {0, 0, {0}, 0}
688 };
689 err_code = sensor_write_regs(gspca_dev, vga_sensor0_init_data,
690 ARRAY_SIZE(vga_sensor0_init_data));
691 } else { /* sd->sensor_type = 1 */
692 const struct sensor_w_data vga_sensor1_init_data[] = {
693 {0x02, 0x00, {0x06, 0x59, 0x0c, 0x16, 0x00,
694 0x07, 0x00, 0x01}, 8},
695 {0x11, 0x04, {0x01}, 1},
696 /*{0x0a, 0x00, {0x00, 0x01, 0x00, 0x00, 0x01, */
697 {0x0a, 0x00, {0x01, 0x06, 0x00, 0x00, 0x01,
698 0x00, 0x0a}, 7},
699 {0x11, 0x04, {0x01}, 1},
700 {0x12, 0x00, {0x00, 0x63, 0x00, 0x70, 0x00, 0x00}, 6},
701 {0x11, 0x04, {0x01}, 1},
702 {0, 0, {0}, 0}
703 };
704 err_code = sensor_write_regs(gspca_dev, vga_sensor1_init_data,
705 ARRAY_SIZE(vga_sensor1_init_data));
706 }
258 if (err_code < 0) 707 if (err_code < 0)
259 return err_code; 708 return err_code;
260 709
710 msleep(200);
261 data[0] = 0x00; 711 data[0] = 0x00;
262 data[1] = 0x4d; /* ISOC transfering enable... */ 712 data[1] = 0x4d; /* ISOC transfering enable... */
263 err_code = reg_w(gspca_dev, 2); 713 err_code = mr_write(gspca_dev, 2);
714
715 return err_code;
716}
717
718static int sd_start(struct gspca_dev *gspca_dev)
719{
720 struct sd *sd = (struct sd *) gspca_dev;
721 int err_code;
722 struct cam *cam;
723
724 cam = &gspca_dev->cam;
725 sd->sof_read = 0;
726 /*
727 * Some of the supported cameras require the memory pointer to be
728 * set to 0, or else they will not stream.
729 */
730 zero_the_pointer(gspca_dev);
731 msleep(200);
732 if (sd->cam_type == CAM_TYPE_CIF) {
733 err_code = start_cif_cam(gspca_dev);
734 } else {
735 err_code = start_vga_cam(gspca_dev);
736 }
264 return err_code; 737 return err_code;
265} 738}
266 739
267static void sd_stopN(struct gspca_dev *gspca_dev) 740static void sd_stopN(struct gspca_dev *gspca_dev)
268{ 741{
742 struct sd *sd = (struct sd *) gspca_dev;
269 int result; 743 int result;
270 744
271 gspca_dev->usb_buf[0] = 1; 745 gspca_dev->usb_buf[0] = 1;
272 gspca_dev->usb_buf[1] = 0; 746 gspca_dev->usb_buf[1] = 0;
273 result = reg_w(gspca_dev, 2); 747 result = mr_write(gspca_dev, 2);
274 if (result < 0) 748 if (result < 0)
275 PDEBUG(D_ERR, "Camera Stop failed"); 749 PDEBUG(D_ERR, "Camera Stop failed");
750
751 /* Not all the cams need this, but even if not, probably a good idea */
752 zero_the_pointer(gspca_dev);
753 if (sd->do_lcd_stop) {
754 gspca_dev->usb_buf[0] = 0x19;
755 gspca_dev->usb_buf[1] = 0x54;
756 result = mr_write(gspca_dev, 2);
757 if (result < 0)
758 PDEBUG(D_ERR, "Camera Stop failed");
759 }
760}
761
762static void setbrightness(struct gspca_dev *gspca_dev)
763{
764 struct sd *sd = (struct sd *) gspca_dev;
765 u8 val;
766
767 if (gspca_dev->ctrl_dis & (1 << BRIGHTNESS_IDX))
768 return;
769
770 /* Note register 7 is also seen as 0x8x or 0xCx in dumps */
771 if (sd->brightness > 0) {
772 sensor_write1(gspca_dev, 7, 0x00);
773 val = sd->brightness;
774 } else {
775 sensor_write1(gspca_dev, 7, 0x01);
776 val = 257 - sd->brightness;
777 }
778 sensor_write1(gspca_dev, 8, val);
779}
780
781static void setexposure(struct gspca_dev *gspca_dev)
782{
783 struct sd *sd = (struct sd *) gspca_dev;
784 u8 val;
785
786 if (gspca_dev->ctrl_dis & (1 << EXPOSURE_IDX))
787 return;
788
789 if (sd->sensor_type) {
790 val = sd->exposure >> 4;
791 sensor_write1(gspca_dev, 3, val);
792 val = sd->exposure & 0xf;
793 sensor_write1(gspca_dev, 4, val);
794 } else {
795 u8 clockdiv;
796 int exposure;
797
798 /* We have both a clock divider and an exposure register.
799 We first calculate the clock divider, as that determines
800 the maximum exposure and then we calculayte the exposure
801 register setting (which goes from 0 - 511).
802
803 Note our 0 - 4095 exposure is mapped to 0 - 511
804 milliseconds exposure time */
805 clockdiv = (60 * sd->exposure + 7999) / 8000;
806
807 /* Limit framerate to not exceed usb bandwidth */
808 if (clockdiv < 3 && gspca_dev->width >= 320)
809 clockdiv = 3;
810 else if (clockdiv < 2)
811 clockdiv = 2;
812
813 /* Frame exposure time in ms = 1000 * clockdiv / 60 ->
814 exposure = (sd->exposure / 8) * 511 / (1000 * clockdiv / 60) */
815 exposure = (60 * 511 * sd->exposure) / (8000 * clockdiv);
816 if (exposure > 511)
817 exposure = 511;
818
819 /* exposure register value is reversed! */
820 exposure = 511 - exposure;
821
822 sensor_write1(gspca_dev, 0x02, clockdiv);
823 sensor_write1(gspca_dev, 0x0e, exposure & 0xff);
824 sensor_write1(gspca_dev, 0x0f, exposure >> 8);
825 }
826}
827
828static void setgain(struct gspca_dev *gspca_dev)
829{
830 struct sd *sd = (struct sd *) gspca_dev;
831
832 if (gspca_dev->ctrl_dis & (1 << GAIN_IDX))
833 return;
834
835 if (sd->sensor_type) {
836 sensor_write1(gspca_dev, 0x0e, sd->gain);
837 } else {
838 sensor_write1(gspca_dev, 0x10, sd->gain);
839 }
840}
841
842static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
843{
844 struct sd *sd = (struct sd *) gspca_dev;
845
846 sd->brightness = val;
847 if (gspca_dev->streaming)
848 setbrightness(gspca_dev);
849 return 0;
850}
851
852static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
853{
854 struct sd *sd = (struct sd *) gspca_dev;
855
856 *val = sd->brightness;
857 return 0;
858}
859
860static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val)
861{
862 struct sd *sd = (struct sd *) gspca_dev;
863
864 sd->exposure = val;
865 if (gspca_dev->streaming)
866 setexposure(gspca_dev);
867 return 0;
868}
869
870static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val)
871{
872 struct sd *sd = (struct sd *) gspca_dev;
873
874 *val = sd->exposure;
875 return 0;
876}
877
878static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val)
879{
880 struct sd *sd = (struct sd *) gspca_dev;
881
882 sd->gain = val;
883 if (gspca_dev->streaming)
884 setgain(gspca_dev);
885 return 0;
886}
887
888static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val)
889{
890 struct sd *sd = (struct sd *) gspca_dev;
891
892 *val = sd->gain;
893 return 0;
276} 894}
277 895
278/* Include pac common sof detection functions */ 896/* Include pac common sof detection functions */
@@ -320,8 +938,9 @@ static const struct sd_desc sd_desc = {
320 938
321/* -- module initialisation -- */ 939/* -- module initialisation -- */
322static const __devinitdata struct usb_device_id device_table[] = { 940static const __devinitdata struct usb_device_id device_table[] = {
323 {USB_DEVICE(0x08ca, 0x0111)}, 941 {USB_DEVICE(0x08ca, 0x0111)}, /* Aiptek Pencam VGA+ */
324 {USB_DEVICE(0x093a, 0x010f)}, 942 {USB_DEVICE(0x093a, 0x010f)}, /* All other known MR97310A VGA cams */
943 {USB_DEVICE(0x093a, 0x010e)}, /* All known MR97310A CIF cams */
325 {} 944 {}
326}; 945};
327MODULE_DEVICE_TABLE(usb, device_table); 946MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index 95a97ab684cd..96659433d248 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -35,25 +35,17 @@ MODULE_LICENSE("GPL");
35 35
36#define PAC207_BRIGHTNESS_MIN 0 36#define PAC207_BRIGHTNESS_MIN 0
37#define PAC207_BRIGHTNESS_MAX 255 37#define PAC207_BRIGHTNESS_MAX 255
38#define PAC207_BRIGHTNESS_DEFAULT 4 /* power on default: 4 */ 38#define PAC207_BRIGHTNESS_DEFAULT 46
39 39
40/* An exposure value of 4 also works (3 does not) but then we need to lower 40#define PAC207_EXPOSURE_MIN 3
41 the compression balance setting when in 352x288 mode, otherwise the usb
42 bandwidth is not enough and packets get dropped resulting in corrupt
43 frames. The problem with this is that when the compression balance gets
44 lowered below 0x80, the pac207 starts using a different compression
45 algorithm for some lines, these lines get prefixed with a 0x2dd2 prefix
46 and currently we do not know how to decompress these lines, so for now
47 we use a minimum exposure value of 5 */
48#define PAC207_EXPOSURE_MIN 5
49#define PAC207_EXPOSURE_MAX 26 41#define PAC207_EXPOSURE_MAX 26
50#define PAC207_EXPOSURE_DEFAULT 5 /* power on default: 3 ?? */ 42#define PAC207_EXPOSURE_DEFAULT 5 /* power on default: 3 */
51#define PAC207_EXPOSURE_KNEE 11 /* 4 = 30 fps, 11 = 8, 15 = 6 */ 43#define PAC207_EXPOSURE_KNEE 8 /* 4 = 30 fps, 11 = 8, 15 = 6 */
52 44
53#define PAC207_GAIN_MIN 0 45#define PAC207_GAIN_MIN 0
54#define PAC207_GAIN_MAX 31 46#define PAC207_GAIN_MAX 31
55#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */ 47#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */
56#define PAC207_GAIN_KNEE 20 48#define PAC207_GAIN_KNEE 31
57 49
58#define PAC207_AUTOGAIN_DEADZONE 30 50#define PAC207_AUTOGAIN_DEADZONE 30
59 51
@@ -166,16 +158,12 @@ static const struct v4l2_pix_format sif_mode[] = {
166}; 158};
167 159
168static const __u8 pac207_sensor_init[][8] = { 160static const __u8 pac207_sensor_init[][8] = {
169 {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0xf0}, 161 {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0x84},
170 {0x00, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30}, 162 {0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30},
171 {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00}, 163 {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00},
172 {0x00, 0x00, 0x32, 0x00, 0x96, 0x00, 0xa2, 0x02},
173 {0x32, 0x00, 0x96, 0x00, 0xA2, 0x02, 0xaf, 0x00}, 164 {0x32, 0x00, 0x96, 0x00, 0xA2, 0x02, 0xaf, 0x00},
174}; 165};
175 166
176 /* 48 reg_72 Rate Control end BalSize_4a =0x36 */
177static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 };
178
179static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, 167static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
180 const u8 *buffer, u16 length) 168 const u8 *buffer, u16 length)
181{ 169{
@@ -274,7 +262,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
274 * Bit_1=LED, 262 * Bit_1=LED,
275 * Bit_2=Compression test mode enable */ 263 * Bit_2=Compression test mode enable */
276 pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ 264 pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */
277 pac207_write_reg(gspca_dev, 0x11, 0x30); /* Analog Bias */
278 265
279 return 0; 266 return 0;
280} 267}
@@ -289,15 +276,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
289 pac207_write_regs(gspca_dev, 0x0002, pac207_sensor_init[0], 8); 276 pac207_write_regs(gspca_dev, 0x0002, pac207_sensor_init[0], 8);
290 pac207_write_regs(gspca_dev, 0x000a, pac207_sensor_init[1], 8); 277 pac207_write_regs(gspca_dev, 0x000a, pac207_sensor_init[1], 8);
291 pac207_write_regs(gspca_dev, 0x0012, pac207_sensor_init[2], 8); 278 pac207_write_regs(gspca_dev, 0x0012, pac207_sensor_init[2], 8);
292 pac207_write_regs(gspca_dev, 0x0040, pac207_sensor_init[3], 8); 279 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[3], 8);
293 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[4], 8);
294 pac207_write_regs(gspca_dev, 0x0048, PacReg72, 4);
295 280
296 /* Compression Balance */ 281 /* Compression Balance */
297 if (gspca_dev->width == 176) 282 if (gspca_dev->width == 176)
298 pac207_write_reg(gspca_dev, 0x4a, 0xff); 283 pac207_write_reg(gspca_dev, 0x4a, 0xff);
299 else 284 else
300 pac207_write_reg(gspca_dev, 0x4a, 0x88); 285 pac207_write_reg(gspca_dev, 0x4a, 0x30);
301 pac207_write_reg(gspca_dev, 0x4b, 0x00); /* Sram test value */ 286 pac207_write_reg(gspca_dev, 0x4b, 0x00); /* Sram test value */
302 pac207_write_reg(gspca_dev, 0x08, sd->brightness); 287 pac207_write_reg(gspca_dev, 0x08, sd->brightness);
303 288
@@ -346,7 +331,7 @@ static void pac207_do_auto_gain(struct gspca_dev *gspca_dev)
346 if (sd->autogain_ignore_frames > 0) 331 if (sd->autogain_ignore_frames > 0)
347 sd->autogain_ignore_frames--; 332 sd->autogain_ignore_frames--;
348 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, 333 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum,
349 100 + sd->brightness / 2, PAC207_AUTOGAIN_DEADZONE, 334 100, PAC207_AUTOGAIN_DEADZONE,
350 PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE)) 335 PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE))
351 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; 336 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
352} 337}
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index e1e3a3a50484..052714484e83 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -1057,6 +1057,7 @@ static struct sd_desc sd_desc = {
1057 1057
1058/* -- module initialisation -- */ 1058/* -- module initialisation -- */
1059static __devinitdata struct usb_device_id device_table[] = { 1059static __devinitdata struct usb_device_id device_table[] = {
1060 {USB_DEVICE(0x06f8, 0x3009), .driver_info = SENSOR_PAC7302},
1060 {USB_DEVICE(0x093a, 0x2600), .driver_info = SENSOR_PAC7311}, 1061 {USB_DEVICE(0x093a, 0x2600), .driver_info = SENSOR_PAC7311},
1061 {USB_DEVICE(0x093a, 0x2601), .driver_info = SENSOR_PAC7311}, 1062 {USB_DEVICE(0x093a, 0x2601), .driver_info = SENSOR_PAC7311},
1062 {USB_DEVICE(0x093a, 0x2603), .driver_info = SENSOR_PAC7311}, 1063 {USB_DEVICE(0x093a, 0x2603), .driver_info = SENSOR_PAC7311},
@@ -1068,6 +1069,7 @@ static __devinitdata struct usb_device_id device_table[] = {
1068 {USB_DEVICE(0x093a, 0x2622), .driver_info = SENSOR_PAC7302}, 1069 {USB_DEVICE(0x093a, 0x2622), .driver_info = SENSOR_PAC7302},
1069 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302}, 1070 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302},
1070 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302}, 1071 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302},
1072 {USB_DEVICE(0x093a, 0x2629), .driver_info = SENSOR_PAC7302},
1071 {USB_DEVICE(0x093a, 0x262a), .driver_info = SENSOR_PAC7302}, 1073 {USB_DEVICE(0x093a, 0x262a), .driver_info = SENSOR_PAC7302},
1072 {USB_DEVICE(0x093a, 0x262c), .driver_info = SENSOR_PAC7302}, 1074 {USB_DEVICE(0x093a, 0x262c), .driver_info = SENSOR_PAC7302},
1073 {} 1075 {}
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index fcfbbd329b4c..cdad3db33367 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -94,6 +94,16 @@ struct sd {
94#endif 94#endif
95}; 95};
96 96
97struct i2c_reg_u8 {
98 u8 reg;
99 u8 val;
100};
101
102struct i2c_reg_u16 {
103 u8 reg;
104 u16 val;
105};
106
97static int sd_setbrightness(struct gspca_dev *gspca_dev, s32 val); 107static int sd_setbrightness(struct gspca_dev *gspca_dev, s32 val);
98static int sd_getbrightness(struct gspca_dev *gspca_dev, s32 *val); 108static int sd_getbrightness(struct gspca_dev *gspca_dev, s32 *val);
99static int sd_setcontrast(struct gspca_dev *gspca_dev, s32 val); 109static int sd_setcontrast(struct gspca_dev *gspca_dev, s32 val);
@@ -403,7 +413,7 @@ static const struct v4l2_pix_format sxga_mode[] = {
403 .priv = 3 | MODE_RAW | MODE_SXGA}, 413 .priv = 3 | MODE_RAW | MODE_SXGA},
404}; 414};
405 415
406static const int hsv_red_x[] = { 416static const s16 hsv_red_x[] = {
407 41, 44, 46, 48, 50, 52, 54, 56, 417 41, 44, 46, 48, 50, 52, 54, 56,
408 58, 60, 62, 64, 66, 68, 70, 72, 418 58, 60, 62, 64, 66, 68, 70, 72,
409 74, 76, 78, 80, 81, 83, 85, 87, 419 74, 76, 78, 80, 81, 83, 85, 87,
@@ -451,7 +461,7 @@ static const int hsv_red_x[] = {
451 24, 26, 28, 30, 33, 35, 37, 39, 41 461 24, 26, 28, 30, 33, 35, 37, 39, 41
452}; 462};
453 463
454static const int hsv_red_y[] = { 464static const s16 hsv_red_y[] = {
455 82, 80, 78, 76, 74, 73, 71, 69, 465 82, 80, 78, 76, 74, 73, 71, 69,
456 67, 65, 63, 61, 58, 56, 54, 52, 466 67, 65, 63, 61, 58, 56, 54, 52,
457 50, 48, 46, 44, 41, 39, 37, 35, 467 50, 48, 46, 44, 41, 39, 37, 35,
@@ -499,7 +509,7 @@ static const int hsv_red_y[] = {
499 96, 94, 92, 91, 89, 87, 85, 84, 82 509 96, 94, 92, 91, 89, 87, 85, 84, 82
500}; 510};
501 511
502static const int hsv_green_x[] = { 512static const s16 hsv_green_x[] = {
503 -124, -124, -125, -125, -125, -125, -125, -125, 513 -124, -124, -125, -125, -125, -125, -125, -125,
504 -125, -126, -126, -125, -125, -125, -125, -125, 514 -125, -126, -126, -125, -125, -125, -125, -125,
505 -125, -124, -124, -124, -123, -123, -122, -122, 515 -125, -124, -124, -124, -123, -123, -122, -122,
@@ -547,7 +557,7 @@ static const int hsv_green_x[] = {
547 -120, -120, -121, -122, -122, -123, -123, -124, -124 557 -120, -120, -121, -122, -122, -123, -123, -124, -124
548}; 558};
549 559
550static const int hsv_green_y[] = { 560static const s16 hsv_green_y[] = {
551 -100, -99, -98, -97, -95, -94, -93, -91, 561 -100, -99, -98, -97, -95, -94, -93, -91,
552 -90, -89, -87, -86, -84, -83, -81, -80, 562 -90, -89, -87, -86, -84, -83, -81, -80,
553 -78, -76, -75, -73, -71, -70, -68, -66, 563 -78, -76, -75, -73, -71, -70, -68, -66,
@@ -595,7 +605,7 @@ static const int hsv_green_y[] = {
595 -109, -108, -107, -106, -105, -104, -103, -102, -100 605 -109, -108, -107, -106, -105, -104, -103, -102, -100
596}; 606};
597 607
598static const int hsv_blue_x[] = { 608static const s16 hsv_blue_x[] = {
599 112, 113, 114, 114, 115, 116, 117, 117, 609 112, 113, 114, 114, 115, 116, 117, 117,
600 118, 118, 119, 119, 120, 120, 120, 121, 610 118, 118, 119, 119, 120, 120, 120, 121,
601 121, 121, 122, 122, 122, 122, 122, 122, 611 121, 121, 122, 122, 122, 122, 122, 122,
@@ -643,7 +653,7 @@ static const int hsv_blue_x[] = {
643 104, 105, 106, 107, 108, 109, 110, 111, 112 653 104, 105, 106, 107, 108, 109, 110, 111, 112
644}; 654};
645 655
646static const int hsv_blue_y[] = { 656static const s16 hsv_blue_y[] = {
647 -11, -13, -15, -17, -19, -21, -23, -25, 657 -11, -13, -15, -17, -19, -21, -23, -25,
648 -27, -29, -31, -33, -35, -37, -39, -41, 658 -27, -29, -31, -33, -35, -37, -39, -41,
649 -43, -45, -46, -48, -50, -52, -54, -55, 659 -43, -45, -46, -48, -50, -52, -54, -55,
@@ -792,21 +802,21 @@ static u8 hv7131r_gain[] = {
792 0x78 /* 8x */ 802 0x78 /* 8x */
793}; 803};
794 804
795static u8 soi968_init[][2] = { 805static struct i2c_reg_u8 soi968_init[] = {
796 {0x12, 0x80}, {0x0c, 0x00}, {0x0f, 0x1f}, 806 {0x12, 0x80}, {0x0c, 0x00}, {0x0f, 0x1f},
797 {0x11, 0x80}, {0x38, 0x52}, {0x1e, 0x00}, 807 {0x11, 0x80}, {0x38, 0x52}, {0x1e, 0x00},
798 {0x33, 0x08}, {0x35, 0x8c}, {0x36, 0x0c}, 808 {0x33, 0x08}, {0x35, 0x8c}, {0x36, 0x0c},
799 {0x37, 0x04}, {0x45, 0x04}, {0x47, 0xff}, 809 {0x37, 0x04}, {0x45, 0x04}, {0x47, 0xff},
800 {0x3e, 0x00}, {0x3f, 0x00}, {0x3b, 0x20}, 810 {0x3e, 0x00}, {0x3f, 0x00}, {0x3b, 0x20},
801 {0x3a, 0x96}, {0x3d, 0x0a}, {0x14, 0x8e}, 811 {0x3a, 0x96}, {0x3d, 0x0a}, {0x14, 0x8e},
802 {0x13, 0x8a}, {0x12, 0x40}, {0x17, 0x13}, 812 {0x13, 0x8b}, {0x12, 0x40}, {0x17, 0x13},
803 {0x18, 0x63}, {0x19, 0x01}, {0x1a, 0x79}, 813 {0x18, 0x63}, {0x19, 0x01}, {0x1a, 0x79},
804 {0x32, 0x24}, {0x03, 0x00}, {0x11, 0x40}, 814 {0x32, 0x24}, {0x03, 0x00}, {0x11, 0x40},
805 {0x2a, 0x10}, {0x2b, 0xe0}, {0x10, 0x32}, 815 {0x2a, 0x10}, {0x2b, 0xe0}, {0x10, 0x32},
806 {0x00, 0x00}, {0x01, 0x80}, {0x02, 0x80}, 816 {0x00, 0x00}, {0x01, 0x80}, {0x02, 0x80},
807}; 817};
808 818
809static u8 ov7660_init[][2] = { 819static struct i2c_reg_u8 ov7660_init[] = {
810 {0x0e, 0x80}, {0x0d, 0x08}, {0x0f, 0xc3}, 820 {0x0e, 0x80}, {0x0d, 0x08}, {0x0f, 0xc3},
811 {0x04, 0xc3}, {0x10, 0x40}, {0x11, 0x40}, 821 {0x04, 0xc3}, {0x10, 0x40}, {0x11, 0x40},
812 {0x12, 0x05}, {0x13, 0xba}, {0x14, 0x2a}, 822 {0x12, 0x05}, {0x13, 0xba}, {0x14, 0x2a},
@@ -815,7 +825,7 @@ static u8 ov7660_init[][2] = {
815 {0x2e, 0x0b}, {0x01, 0x78}, {0x02, 0x50}, 825 {0x2e, 0x0b}, {0x01, 0x78}, {0x02, 0x50},
816}; 826};
817 827
818static u8 ov7670_init[][2] = { 828static struct i2c_reg_u8 ov7670_init[] = {
819 {0x12, 0x80}, {0x11, 0x80}, {0x3a, 0x04}, {0x12, 0x01}, 829 {0x12, 0x80}, {0x11, 0x80}, {0x3a, 0x04}, {0x12, 0x01},
820 {0x32, 0xb6}, {0x03, 0x0a}, {0x0c, 0x00}, {0x3e, 0x00}, 830 {0x32, 0xb6}, {0x03, 0x0a}, {0x0c, 0x00}, {0x3e, 0x00},
821 {0x70, 0x3a}, {0x71, 0x35}, {0x72, 0x11}, {0x73, 0xf0}, 831 {0x70, 0x3a}, {0x71, 0x35}, {0x72, 0x11}, {0x73, 0xf0},
@@ -872,7 +882,7 @@ static u8 ov7670_init[][2] = {
872 {0x93, 0x00}, 882 {0x93, 0x00},
873}; 883};
874 884
875static u8 ov9650_init[][2] = { 885static struct i2c_reg_u8 ov9650_init[] = {
876 {0x12, 0x80}, {0x00, 0x00}, {0x01, 0x78}, 886 {0x12, 0x80}, {0x00, 0x00}, {0x01, 0x78},
877 {0x02, 0x78}, {0x03, 0x36}, {0x04, 0x03}, 887 {0x02, 0x78}, {0x03, 0x36}, {0x04, 0x03},
878 {0x05, 0x00}, {0x06, 0x00}, {0x08, 0x00}, 888 {0x05, 0x00}, {0x06, 0x00}, {0x08, 0x00},
@@ -902,7 +912,7 @@ static u8 ov9650_init[][2] = {
902 {0xaa, 0x92}, {0xab, 0x0a}, 912 {0xaa, 0x92}, {0xab, 0x0a},
903}; 913};
904 914
905static u8 ov9655_init[][2] = { 915static struct i2c_reg_u8 ov9655_init[] = {
906 {0x12, 0x80}, {0x12, 0x01}, {0x0d, 0x00}, {0x0e, 0x61}, 916 {0x12, 0x80}, {0x12, 0x01}, {0x0d, 0x00}, {0x0e, 0x61},
907 {0x11, 0x80}, {0x13, 0xba}, {0x14, 0x2e}, {0x16, 0x24}, 917 {0x11, 0x80}, {0x13, 0xba}, {0x14, 0x2e}, {0x16, 0x24},
908 {0x1e, 0x04}, {0x1e, 0x04}, {0x1e, 0x04}, {0x27, 0x08}, 918 {0x1e, 0x04}, {0x1e, 0x04}, {0x1e, 0x04}, {0x27, 0x08},
@@ -939,7 +949,7 @@ static u8 ov9655_init[][2] = {
939 {0x00, 0x03}, {0x00, 0x0a}, {0x00, 0x10}, {0x00, 0x13}, 949 {0x00, 0x03}, {0x00, 0x0a}, {0x00, 0x10}, {0x00, 0x13},
940}; 950};
941 951
942static u16 mt9v112_init[][2] = { 952static struct i2c_reg_u16 mt9v112_init[] = {
943 {0xf0, 0x0000}, {0x0d, 0x0021}, {0x0d, 0x0020}, 953 {0xf0, 0x0000}, {0x0d, 0x0021}, {0x0d, 0x0020},
944 {0x34, 0xc019}, {0x0a, 0x0011}, {0x0b, 0x000b}, 954 {0x34, 0xc019}, {0x0a, 0x0011}, {0x0b, 0x000b},
945 {0x20, 0x0703}, {0x35, 0x2022}, {0xf0, 0x0001}, 955 {0x20, 0x0703}, {0x35, 0x2022}, {0xf0, 0x0001},
@@ -958,7 +968,7 @@ static u16 mt9v112_init[][2] = {
958 {0x2c, 0x00ae}, {0x2d, 0x00ae}, {0x2e, 0x00ae}, 968 {0x2c, 0x00ae}, {0x2d, 0x00ae}, {0x2e, 0x00ae},
959}; 969};
960 970
961static u16 mt9v111_init[][2] = { 971static struct i2c_reg_u16 mt9v111_init[] = {
962 {0x01, 0x0004}, {0x0d, 0x0001}, {0x0d, 0x0000}, 972 {0x01, 0x0004}, {0x0d, 0x0001}, {0x0d, 0x0000},
963 {0x01, 0x0001}, {0x02, 0x0016}, {0x03, 0x01e1}, 973 {0x01, 0x0001}, {0x02, 0x0016}, {0x03, 0x01e1},
964 {0x04, 0x0281}, {0x05, 0x0004}, {0x07, 0x3002}, 974 {0x04, 0x0281}, {0x05, 0x0004}, {0x07, 0x3002},
@@ -985,7 +995,7 @@ static u16 mt9v111_init[][2] = {
985 {0x0e, 0x0008}, {0x06, 0x002d}, {0x05, 0x0004}, 995 {0x0e, 0x0008}, {0x06, 0x002d}, {0x05, 0x0004},
986}; 996};
987 997
988static u16 mt9v011_init[][2] = { 998static struct i2c_reg_u16 mt9v011_init[] = {
989 {0x07, 0x0002}, {0x0d, 0x0001}, {0x0d, 0x0000}, 999 {0x07, 0x0002}, {0x0d, 0x0001}, {0x0d, 0x0000},
990 {0x01, 0x0008}, {0x02, 0x0016}, {0x03, 0x01e1}, 1000 {0x01, 0x0008}, {0x02, 0x0016}, {0x03, 0x01e1},
991 {0x04, 0x0281}, {0x05, 0x0083}, {0x06, 0x0006}, 1001 {0x04, 0x0281}, {0x05, 0x0083}, {0x06, 0x0006},
@@ -1012,7 +1022,7 @@ static u16 mt9v011_init[][2] = {
1012 {0x06, 0x0029}, {0x05, 0x0009}, 1022 {0x06, 0x0029}, {0x05, 0x0009},
1013}; 1023};
1014 1024
1015static u16 mt9m001_init[][2] = { 1025static struct i2c_reg_u16 mt9m001_init[] = {
1016 {0x0d, 0x0001}, {0x0d, 0x0000}, {0x01, 0x000e}, 1026 {0x0d, 0x0001}, {0x0d, 0x0000}, {0x01, 0x000e},
1017 {0x02, 0x0014}, {0x03, 0x03c1}, {0x04, 0x0501}, 1027 {0x02, 0x0014}, {0x03, 0x03c1}, {0x04, 0x0501},
1018 {0x05, 0x0083}, {0x06, 0x0006}, {0x0d, 0x0002}, 1028 {0x05, 0x0083}, {0x06, 0x0006}, {0x0d, 0x0002},
@@ -1025,14 +1035,14 @@ static u16 mt9m001_init[][2] = {
1025 {0x2e, 0x0029}, {0x07, 0x0002}, 1035 {0x2e, 0x0029}, {0x07, 0x0002},
1026}; 1036};
1027 1037
1028static u16 mt9m111_init[][2] = { 1038static struct i2c_reg_u16 mt9m111_init[] = {
1029 {0xf0, 0x0000}, {0x0d, 0x0008}, {0x0d, 0x0009}, 1039 {0xf0, 0x0000}, {0x0d, 0x0021}, {0x0d, 0x0008},
1030 {0x0d, 0x0008}, {0xf0, 0x0001}, {0x3a, 0x4300}, 1040 {0xf0, 0x0001}, {0x3a, 0x4300}, {0x9b, 0x4300},
1031 {0x9b, 0x4300}, {0xa1, 0x0280}, {0xa4, 0x0200}, 1041 {0x06, 0x708e}, {0xf0, 0x0002}, {0x2e, 0x0a1e},
1032 {0x06, 0x308e}, {0xf0, 0x0000}, 1042 {0xf0, 0x0000},
1033}; 1043};
1034 1044
1035static u8 hv7131r_init[][2] = { 1045static struct i2c_reg_u8 hv7131r_init[] = {
1036 {0x02, 0x08}, {0x02, 0x00}, {0x01, 0x08}, 1046 {0x02, 0x08}, {0x02, 0x00}, {0x01, 0x08},
1037 {0x02, 0x00}, {0x20, 0x00}, {0x21, 0xd0}, 1047 {0x02, 0x00}, {0x20, 0x00}, {0x21, 0xd0},
1038 {0x22, 0x00}, {0x23, 0x09}, {0x01, 0x08}, 1048 {0x22, 0x00}, {0x23, 0x09}, {0x01, 0x08},
@@ -1043,7 +1053,7 @@ static u8 hv7131r_init[][2] = {
1043 {0x23, 0x09}, {0x01, 0x08}, 1053 {0x23, 0x09}, {0x01, 0x08},
1044}; 1054};
1045 1055
1046int reg_r(struct gspca_dev *gspca_dev, u16 reg, u16 length) 1056static int reg_r(struct gspca_dev *gspca_dev, u16 reg, u16 length)
1047{ 1057{
1048 struct usb_device *dev = gspca_dev->dev; 1058 struct usb_device *dev = gspca_dev->dev;
1049 int result; 1059 int result;
@@ -1062,7 +1072,8 @@ int reg_r(struct gspca_dev *gspca_dev, u16 reg, u16 length)
1062 return 0; 1072 return 0;
1063} 1073}
1064 1074
1065int reg_w(struct gspca_dev *gspca_dev, u16 reg, const u8 *buffer, int length) 1075static int reg_w(struct gspca_dev *gspca_dev, u16 reg,
1076 const u8 *buffer, int length)
1066{ 1077{
1067 struct usb_device *dev = gspca_dev->dev; 1078 struct usb_device *dev = gspca_dev->dev;
1068 int result; 1079 int result;
@@ -1082,13 +1093,13 @@ int reg_w(struct gspca_dev *gspca_dev, u16 reg, const u8 *buffer, int length)
1082 return 0; 1093 return 0;
1083} 1094}
1084 1095
1085int reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value) 1096static int reg_w1(struct gspca_dev *gspca_dev, u16 reg, const u8 value)
1086{ 1097{
1087 u8 data[1] = {value}; 1098 u8 data[1] = {value};
1088 return reg_w(gspca_dev, reg, data, 1); 1099 return reg_w(gspca_dev, reg, data, 1);
1089} 1100}
1090 1101
1091int i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer) 1102static int i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
1092{ 1103{
1093 int i; 1104 int i;
1094 reg_w(gspca_dev, 0x10c0, buffer, 8); 1105 reg_w(gspca_dev, 0x10c0, buffer, 8);
@@ -1096,15 +1107,15 @@ int i2c_w(struct gspca_dev *gspca_dev, const u8 *buffer)
1096 reg_r(gspca_dev, 0x10c0, 1); 1107 reg_r(gspca_dev, 0x10c0, 1);
1097 if (gspca_dev->usb_buf[0] & 0x04) { 1108 if (gspca_dev->usb_buf[0] & 0x04) {
1098 if (gspca_dev->usb_buf[0] & 0x08) 1109 if (gspca_dev->usb_buf[0] & 0x08)
1099 return -1; 1110 return -EIO;
1100 return 0; 1111 return 0;
1101 } 1112 }
1102 msleep(1); 1113 msleep(1);
1103 } 1114 }
1104 return -1; 1115 return -EIO;
1105} 1116}
1106 1117
1107int i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) 1118static int i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1108{ 1119{
1109 struct sd *sd = (struct sd *) gspca_dev; 1120 struct sd *sd = (struct sd *) gspca_dev;
1110 1121
@@ -1126,7 +1137,7 @@ int i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val)
1126 return i2c_w(gspca_dev, row); 1137 return i2c_w(gspca_dev, row);
1127} 1138}
1128 1139
1129int i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val) 1140static int i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val)
1130{ 1141{
1131 struct sd *sd = (struct sd *) gspca_dev; 1142 struct sd *sd = (struct sd *) gspca_dev;
1132 u8 row[8]; 1143 u8 row[8];
@@ -1152,7 +1163,7 @@ int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
1152 struct sd *sd = (struct sd *) gspca_dev; 1163 struct sd *sd = (struct sd *) gspca_dev;
1153 u8 row[8]; 1164 u8 row[8];
1154 1165
1155 row[0] = 0x81 | 0x10; 1166 row[0] = 0x81 | (1 << 4);
1156 row[1] = sd->i2c_addr; 1167 row[1] = sd->i2c_addr;
1157 row[2] = reg; 1168 row[2] = reg;
1158 row[3] = 0; 1169 row[3] = 0;
@@ -1160,14 +1171,15 @@ int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
1160 row[5] = 0; 1171 row[5] = 0;
1161 row[6] = 0; 1172 row[6] = 0;
1162 row[7] = 0x10; 1173 row[7] = 0x10;
1163 reg_w(gspca_dev, 0x10c0, row, 8); 1174 if (i2c_w(gspca_dev, row) < 0)
1164 msleep(1); 1175 return -EIO;
1165 row[0] = 0x81 | (2 << 4) | 0x02; 1176 row[0] = 0x81 | (1 << 4) | 0x02;
1166 row[2] = 0; 1177 row[2] = 0;
1167 reg_w(gspca_dev, 0x10c0, row, 8); 1178 if (i2c_w(gspca_dev, row) < 0)
1168 msleep(1); 1179 return -EIO;
1169 reg_r(gspca_dev, 0x10c2, 5); 1180 if (reg_r(gspca_dev, 0x10c2, 5) < 0)
1170 *val = gspca_dev->usb_buf[3]; 1181 return -EIO;
1182 *val = gspca_dev->usb_buf[4];
1171 return 0; 1183 return 0;
1172} 1184}
1173 1185
@@ -1176,7 +1188,7 @@ int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val)
1176 struct sd *sd = (struct sd *) gspca_dev; 1188 struct sd *sd = (struct sd *) gspca_dev;
1177 u8 row[8]; 1189 u8 row[8];
1178 1190
1179 row[0] = 0x81 | 0x10; 1191 row[0] = 0x81 | (1 << 4);
1180 row[1] = sd->i2c_addr; 1192 row[1] = sd->i2c_addr;
1181 row[2] = reg; 1193 row[2] = reg;
1182 row[3] = 0; 1194 row[3] = 0;
@@ -1184,14 +1196,15 @@ int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val)
1184 row[5] = 0; 1196 row[5] = 0;
1185 row[6] = 0; 1197 row[6] = 0;
1186 row[7] = 0x10; 1198 row[7] = 0x10;
1187 reg_w(gspca_dev, 0x10c0, row, 8); 1199 if (i2c_w(gspca_dev, row) < 0)
1188 msleep(1); 1200 return -EIO;
1189 row[0] = 0x81 | (3 << 4) | 0x02; 1201 row[0] = 0x81 | (2 << 4) | 0x02;
1190 row[2] = 0; 1202 row[2] = 0;
1191 reg_w(gspca_dev, 0x10c0, row, 8); 1203 if (i2c_w(gspca_dev, row) < 0)
1192 msleep(1); 1204 return -EIO;
1193 reg_r(gspca_dev, 0x10c2, 5); 1205 if (reg_r(gspca_dev, 0x10c2, 5) < 0)
1194 *val = (gspca_dev->usb_buf[2] << 8) | gspca_dev->usb_buf[3]; 1206 return -EIO;
1207 *val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4];
1195 return 0; 1208 return 0;
1196} 1209}
1197 1210
@@ -1201,8 +1214,8 @@ static int ov9650_init_sensor(struct gspca_dev *gspca_dev)
1201 struct sd *sd = (struct sd *) gspca_dev; 1214 struct sd *sd = (struct sd *) gspca_dev;
1202 1215
1203 for (i = 0; i < ARRAY_SIZE(ov9650_init); i++) { 1216 for (i = 0; i < ARRAY_SIZE(ov9650_init); i++) {
1204 if (i2c_w1(gspca_dev, ov9650_init[i][0], 1217 if (i2c_w1(gspca_dev, ov9650_init[i].reg,
1205 ov9650_init[i][1]) < 0) { 1218 ov9650_init[i].val) < 0) {
1206 err("OV9650 sensor initialization failed"); 1219 err("OV9650 sensor initialization failed");
1207 return -ENODEV; 1220 return -ENODEV;
1208 } 1221 }
@@ -1218,8 +1231,8 @@ static int ov9655_init_sensor(struct gspca_dev *gspca_dev)
1218 struct sd *sd = (struct sd *) gspca_dev; 1231 struct sd *sd = (struct sd *) gspca_dev;
1219 1232
1220 for (i = 0; i < ARRAY_SIZE(ov9655_init); i++) { 1233 for (i = 0; i < ARRAY_SIZE(ov9655_init); i++) {
1221 if (i2c_w1(gspca_dev, ov9655_init[i][0], 1234 if (i2c_w1(gspca_dev, ov9655_init[i].reg,
1222 ov9655_init[i][1]) < 0) { 1235 ov9655_init[i].val) < 0) {
1223 err("OV9655 sensor initialization failed"); 1236 err("OV9655 sensor initialization failed");
1224 return -ENODEV; 1237 return -ENODEV;
1225 } 1238 }
@@ -1237,14 +1250,14 @@ static int soi968_init_sensor(struct gspca_dev *gspca_dev)
1237 struct sd *sd = (struct sd *) gspca_dev; 1250 struct sd *sd = (struct sd *) gspca_dev;
1238 1251
1239 for (i = 0; i < ARRAY_SIZE(soi968_init); i++) { 1252 for (i = 0; i < ARRAY_SIZE(soi968_init); i++) {
1240 if (i2c_w1(gspca_dev, soi968_init[i][0], 1253 if (i2c_w1(gspca_dev, soi968_init[i].reg,
1241 soi968_init[i][1]) < 0) { 1254 soi968_init[i].val) < 0) {
1242 err("SOI968 sensor initialization failed"); 1255 err("SOI968 sensor initialization failed");
1243 return -ENODEV; 1256 return -ENODEV;
1244 } 1257 }
1245 } 1258 }
1246 /* disable hflip and vflip */ 1259 /* disable hflip and vflip */
1247 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX); 1260 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX) | (1 << EXPOSURE_IDX);
1248 sd->hstart = 60; 1261 sd->hstart = 60;
1249 sd->vstart = 11; 1262 sd->vstart = 11;
1250 return 0; 1263 return 0;
@@ -1256,8 +1269,8 @@ static int ov7660_init_sensor(struct gspca_dev *gspca_dev)
1256 struct sd *sd = (struct sd *) gspca_dev; 1269 struct sd *sd = (struct sd *) gspca_dev;
1257 1270
1258 for (i = 0; i < ARRAY_SIZE(ov7660_init); i++) { 1271 for (i = 0; i < ARRAY_SIZE(ov7660_init); i++) {
1259 if (i2c_w1(gspca_dev, ov7660_init[i][0], 1272 if (i2c_w1(gspca_dev, ov7660_init[i].reg,
1260 ov7660_init[i][1]) < 0) { 1273 ov7660_init[i].val) < 0) {
1261 err("OV7660 sensor initialization failed"); 1274 err("OV7660 sensor initialization failed");
1262 return -ENODEV; 1275 return -ENODEV;
1263 } 1276 }
@@ -1275,8 +1288,8 @@ static int ov7670_init_sensor(struct gspca_dev *gspca_dev)
1275 struct sd *sd = (struct sd *) gspca_dev; 1288 struct sd *sd = (struct sd *) gspca_dev;
1276 1289
1277 for (i = 0; i < ARRAY_SIZE(ov7670_init); i++) { 1290 for (i = 0; i < ARRAY_SIZE(ov7670_init); i++) {
1278 if (i2c_w1(gspca_dev, ov7670_init[i][0], 1291 if (i2c_w1(gspca_dev, ov7670_init[i].reg,
1279 ov7670_init[i][1]) < 0) { 1292 ov7670_init[i].val) < 0) {
1280 err("OV7670 sensor initialization failed"); 1293 err("OV7670 sensor initialization failed");
1281 return -ENODEV; 1294 return -ENODEV;
1282 } 1295 }
@@ -1299,8 +1312,8 @@ static int mt9v_init_sensor(struct gspca_dev *gspca_dev)
1299 ret = i2c_r2(gspca_dev, 0xff, &value); 1312 ret = i2c_r2(gspca_dev, 0xff, &value);
1300 if ((ret == 0) && (value == 0x8243)) { 1313 if ((ret == 0) && (value == 0x8243)) {
1301 for (i = 0; i < ARRAY_SIZE(mt9v011_init); i++) { 1314 for (i = 0; i < ARRAY_SIZE(mt9v011_init); i++) {
1302 if (i2c_w2(gspca_dev, mt9v011_init[i][0], 1315 if (i2c_w2(gspca_dev, mt9v011_init[i].reg,
1303 mt9v011_init[i][1]) < 0) { 1316 mt9v011_init[i].val) < 0) {
1304 err("MT9V011 sensor initialization failed"); 1317 err("MT9V011 sensor initialization failed");
1305 return -ENODEV; 1318 return -ENODEV;
1306 } 1319 }
@@ -1317,8 +1330,8 @@ static int mt9v_init_sensor(struct gspca_dev *gspca_dev)
1317 ret = i2c_r2(gspca_dev, 0xff, &value); 1330 ret = i2c_r2(gspca_dev, 0xff, &value);
1318 if ((ret == 0) && (value == 0x823a)) { 1331 if ((ret == 0) && (value == 0x823a)) {
1319 for (i = 0; i < ARRAY_SIZE(mt9v111_init); i++) { 1332 for (i = 0; i < ARRAY_SIZE(mt9v111_init); i++) {
1320 if (i2c_w2(gspca_dev, mt9v111_init[i][0], 1333 if (i2c_w2(gspca_dev, mt9v111_init[i].reg,
1321 mt9v111_init[i][1]) < 0) { 1334 mt9v111_init[i].val) < 0) {
1322 err("MT9V111 sensor initialization failed"); 1335 err("MT9V111 sensor initialization failed");
1323 return -ENODEV; 1336 return -ENODEV;
1324 } 1337 }
@@ -1339,8 +1352,8 @@ static int mt9v_init_sensor(struct gspca_dev *gspca_dev)
1339 ret = i2c_r2(gspca_dev, 0x00, &value); 1352 ret = i2c_r2(gspca_dev, 0x00, &value);
1340 if ((ret == 0) && (value == 0x1229)) { 1353 if ((ret == 0) && (value == 0x1229)) {
1341 for (i = 0; i < ARRAY_SIZE(mt9v112_init); i++) { 1354 for (i = 0; i < ARRAY_SIZE(mt9v112_init); i++) {
1342 if (i2c_w2(gspca_dev, mt9v112_init[i][0], 1355 if (i2c_w2(gspca_dev, mt9v112_init[i].reg,
1343 mt9v112_init[i][1]) < 0) { 1356 mt9v112_init[i].val) < 0) {
1344 err("MT9V112 sensor initialization failed"); 1357 err("MT9V112 sensor initialization failed");
1345 return -ENODEV; 1358 return -ENODEV;
1346 } 1359 }
@@ -1360,12 +1373,13 @@ static int mt9m111_init_sensor(struct gspca_dev *gspca_dev)
1360 struct sd *sd = (struct sd *) gspca_dev; 1373 struct sd *sd = (struct sd *) gspca_dev;
1361 int i; 1374 int i;
1362 for (i = 0; i < ARRAY_SIZE(mt9m111_init); i++) { 1375 for (i = 0; i < ARRAY_SIZE(mt9m111_init); i++) {
1363 if (i2c_w2(gspca_dev, mt9m111_init[i][0], 1376 if (i2c_w2(gspca_dev, mt9m111_init[i].reg,
1364 mt9m111_init[i][1]) < 0) { 1377 mt9m111_init[i].val) < 0) {
1365 err("MT9M111 sensor initialization failed"); 1378 err("MT9M111 sensor initialization failed");
1366 return -ENODEV; 1379 return -ENODEV;
1367 } 1380 }
1368 } 1381 }
1382 gspca_dev->ctrl_dis = (1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX) | (1 << GAIN_IDX);
1369 sd->hstart = 0; 1383 sd->hstart = 0;
1370 sd->vstart = 2; 1384 sd->vstart = 2;
1371 return 0; 1385 return 0;
@@ -1376,8 +1390,8 @@ static int mt9m001_init_sensor(struct gspca_dev *gspca_dev)
1376 struct sd *sd = (struct sd *) gspca_dev; 1390 struct sd *sd = (struct sd *) gspca_dev;
1377 int i; 1391 int i;
1378 for (i = 0; i < ARRAY_SIZE(mt9m001_init); i++) { 1392 for (i = 0; i < ARRAY_SIZE(mt9m001_init); i++) {
1379 if (i2c_w2(gspca_dev, mt9m001_init[i][0], 1393 if (i2c_w2(gspca_dev, mt9m001_init[i].reg,
1380 mt9m001_init[i][1]) < 0) { 1394 mt9m001_init[i].val) < 0) {
1381 err("MT9M001 sensor initialization failed"); 1395 err("MT9M001 sensor initialization failed");
1382 return -ENODEV; 1396 return -ENODEV;
1383 } 1397 }
@@ -1395,8 +1409,8 @@ static int hv7131r_init_sensor(struct gspca_dev *gspca_dev)
1395 struct sd *sd = (struct sd *) gspca_dev; 1409 struct sd *sd = (struct sd *) gspca_dev;
1396 1410
1397 for (i = 0; i < ARRAY_SIZE(hv7131r_init); i++) { 1411 for (i = 0; i < ARRAY_SIZE(hv7131r_init); i++) {
1398 if (i2c_w1(gspca_dev, hv7131r_init[i][0], 1412 if (i2c_w1(gspca_dev, hv7131r_init[i].reg,
1399 hv7131r_init[i][1]) < 0) { 1413 hv7131r_init[i].val) < 0) {
1400 err("HV7131R Sensor initialization failed"); 1414 err("HV7131R Sensor initialization failed");
1401 return -ENODEV; 1415 return -ENODEV;
1402 } 1416 }
@@ -1620,7 +1634,6 @@ static int set_exposure(struct gspca_dev *gspca_dev)
1620 switch (sd->sensor) { 1634 switch (sd->sensor) {
1621 case SENSOR_OV7660: 1635 case SENSOR_OV7660:
1622 case SENSOR_OV7670: 1636 case SENSOR_OV7670:
1623 case SENSOR_SOI968:
1624 case SENSOR_OV9655: 1637 case SENSOR_OV9655:
1625 case SENSOR_OV9650: 1638 case SENSOR_OV9650:
1626 exp[0] |= (3 << 4); 1639 exp[0] |= (3 << 4);
@@ -1629,7 +1642,6 @@ static int set_exposure(struct gspca_dev *gspca_dev)
1629 exp[4] = sd->exposure >> 8; 1642 exp[4] = sd->exposure >> 8;
1630 break; 1643 break;
1631 case SENSOR_MT9M001: 1644 case SENSOR_MT9M001:
1632 case SENSOR_MT9M111:
1633 case SENSOR_MT9V112: 1645 case SENSOR_MT9V112:
1634 case SENSOR_MT9V111: 1646 case SENSOR_MT9V111:
1635 case SENSOR_MT9V011: 1647 case SENSOR_MT9V011:
@@ -1645,6 +1657,8 @@ static int set_exposure(struct gspca_dev *gspca_dev)
1645 exp[4] = ((sd->exposure * 0xffffff) / 0xffff) >> 8; 1657 exp[4] = ((sd->exposure * 0xffffff) / 0xffff) >> 8;
1646 exp[5] = ((sd->exposure * 0xffffff) / 0xffff) & 0xff; 1658 exp[5] = ((sd->exposure * 0xffffff) / 0xffff) & 0xff;
1647 break; 1659 break;
1660 default:
1661 return 0;
1648 } 1662 }
1649 i2c_w(gspca_dev, exp); 1663 i2c_w(gspca_dev, exp);
1650 return 0; 1664 return 0;
@@ -1671,7 +1685,6 @@ static int set_gain(struct gspca_dev *gspca_dev)
1671 gain[4] = micron1_gain[sd->gain] & 0xff; 1685 gain[4] = micron1_gain[sd->gain] & 0xff;
1672 break; 1686 break;
1673 case SENSOR_MT9V112: 1687 case SENSOR_MT9V112:
1674 case SENSOR_MT9M111:
1675 gain[0] |= (3 << 4); 1688 gain[0] |= (3 << 4);
1676 gain[2] = 0x2f; 1689 gain[2] = 0x2f;
1677 gain[3] = micron1_gain[sd->gain] >> 8; 1690 gain[3] = micron1_gain[sd->gain] >> 8;
@@ -1688,6 +1701,8 @@ static int set_gain(struct gspca_dev *gspca_dev)
1688 gain[2] = 0x30; 1701 gain[2] = 0x30;
1689 gain[3] = hv7131r_gain[sd->gain]; 1702 gain[3] = hv7131r_gain[sd->gain];
1690 break; 1703 break;
1704 default:
1705 return 0;
1691 } 1706 }
1692 i2c_w(gspca_dev, gain); 1707 i2c_w(gspca_dev, gain);
1693 return 0; 1708 return 0;
@@ -1990,7 +2005,9 @@ static int sd_config(struct gspca_dev *gspca_dev,
1990 sd->i2c_addr = id->driver_info & 0xff; 2005 sd->i2c_addr = id->driver_info & 0xff;
1991 2006
1992 switch (sd->sensor) { 2007 switch (sd->sensor) {
2008 case SENSOR_MT9M111:
1993 case SENSOR_OV9650: 2009 case SENSOR_OV9650:
2010 case SENSOR_SOI968:
1994 cam->cam_mode = sxga_mode; 2011 cam->cam_mode = sxga_mode;
1995 cam->nmodes = ARRAY_SIZE(sxga_mode); 2012 cam->nmodes = ARRAY_SIZE(sxga_mode);
1996 break; 2013 break;
@@ -2106,6 +2123,25 @@ static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode)
2106 struct sd *sd = (struct sd *) gspca_dev; 2123 struct sd *sd = (struct sd *) gspca_dev;
2107 u8 value; 2124 u8 value;
2108 switch (sd->sensor) { 2125 switch (sd->sensor) {
2126 case SENSOR_SOI968:
2127 if (mode & MODE_SXGA) {
2128 i2c_w1(gspca_dev, 0x17, 0x1d);
2129 i2c_w1(gspca_dev, 0x18, 0xbd);
2130 i2c_w1(gspca_dev, 0x19, 0x01);
2131 i2c_w1(gspca_dev, 0x1a, 0x81);
2132 i2c_w1(gspca_dev, 0x12, 0x00);
2133 sd->hstart = 140;
2134 sd->vstart = 19;
2135 } else {
2136 i2c_w1(gspca_dev, 0x17, 0x13);
2137 i2c_w1(gspca_dev, 0x18, 0x63);
2138 i2c_w1(gspca_dev, 0x19, 0x01);
2139 i2c_w1(gspca_dev, 0x1a, 0x79);
2140 i2c_w1(gspca_dev, 0x12, 0x40);
2141 sd->hstart = 60;
2142 sd->vstart = 11;
2143 }
2144 break;
2109 case SENSOR_OV9650: 2145 case SENSOR_OV9650:
2110 if (mode & MODE_SXGA) { 2146 if (mode & MODE_SXGA) {
2111 i2c_w1(gspca_dev, 0x17, 0x1b); 2147 i2c_w1(gspca_dev, 0x17, 0x1b);
@@ -2123,6 +2159,17 @@ static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode)
2123 i2c_w1(gspca_dev, 0x12, (value & 0x7) | 0x40); 2159 i2c_w1(gspca_dev, 0x12, (value & 0x7) | 0x40);
2124 } 2160 }
2125 break; 2161 break;
2162 case SENSOR_MT9M111:
2163 if (mode & MODE_SXGA) {
2164 i2c_w2(gspca_dev, 0xf0, 0x0002);
2165 i2c_w2(gspca_dev, 0xc8, 0x970b);
2166 i2c_w2(gspca_dev, 0xf0, 0x0000);
2167 } else {
2168 i2c_w2(gspca_dev, 0xf0, 0x0002);
2169 i2c_w2(gspca_dev, 0xc8, 0x8000);
2170 i2c_w2(gspca_dev, 0xf0, 0x0000);
2171 }
2172 break;
2126 } 2173 }
2127} 2174}
2128 2175
@@ -2211,15 +2258,10 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2211 kfree(sd->jpeg_hdr); 2258 kfree(sd->jpeg_hdr);
2212} 2259}
2213 2260
2214static void do_autoexposure(struct gspca_dev *gspca_dev) 2261static void do_autoexposure(struct gspca_dev *gspca_dev, u16 avg_lum)
2215{ 2262{
2216 struct sd *sd = (struct sd *) gspca_dev; 2263 struct sd *sd = (struct sd *) gspca_dev;
2217 int avg_lum, new_exp; 2264 s16 new_exp;
2218
2219 if (!sd->auto_exposure)
2220 return;
2221
2222 avg_lum = atomic_read(&sd->avg_lum);
2223 2265
2224 /* 2266 /*
2225 * some hardcoded values are present 2267 * some hardcoded values are present
@@ -2266,6 +2308,39 @@ static void do_autoexposure(struct gspca_dev *gspca_dev)
2266 } 2308 }
2267} 2309}
2268 2310
2311static void do_autogain(struct gspca_dev *gspca_dev, u16 avg_lum)
2312{
2313 struct sd *sd = (struct sd *) gspca_dev;
2314
2315 if (avg_lum < MIN_AVG_LUM) {
2316 if (sd->gain + 1 <= 28) {
2317 sd->gain++;
2318 set_gain(gspca_dev);
2319 }
2320 }
2321 if (avg_lum > MAX_AVG_LUM) {
2322 if (sd->gain - 1 >= 0) {
2323 sd->gain--;
2324 set_gain(gspca_dev);
2325 }
2326 }
2327}
2328
2329static void sd_dqcallback(struct gspca_dev *gspca_dev)
2330{
2331 struct sd *sd = (struct sd *) gspca_dev;
2332 int avg_lum;
2333
2334 if (!sd->auto_exposure)
2335 return;
2336
2337 avg_lum = atomic_read(&sd->avg_lum);
2338 if (sd->sensor == SENSOR_SOI968)
2339 do_autogain(gspca_dev, avg_lum);
2340 else
2341 do_autoexposure(gspca_dev, avg_lum);
2342}
2343
2269static void sd_pkt_scan(struct gspca_dev *gspca_dev, 2344static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2270 struct gspca_frame *frame, /* target */ 2345 struct gspca_frame *frame, /* target */
2271 u8 *data, /* isoc packet */ 2346 u8 *data, /* isoc packet */
@@ -2333,7 +2408,7 @@ static const struct sd_desc sd_desc = {
2333 .stopN = sd_stopN, 2408 .stopN = sd_stopN,
2334 .stop0 = sd_stop0, 2409 .stop0 = sd_stop0,
2335 .pkt_scan = sd_pkt_scan, 2410 .pkt_scan = sd_pkt_scan,
2336 .dq_callback = do_autoexposure, 2411 .dq_callback = sd_dqcallback,
2337#ifdef CONFIG_VIDEO_ADV_DEBUG 2412#ifdef CONFIG_VIDEO_ADV_DEBUG
2338 .set_register = sd_dbg_s_register, 2413 .set_register = sd_dbg_s_register,
2339 .get_register = sd_dbg_g_register, 2414 .get_register = sd_dbg_g_register,
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index d6332ab80669..33f4d0a1f6fd 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -727,7 +727,7 @@ static const u8 ov7660_sensor_init[][8] = {
727 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, 727 {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10},
728 /* Outformat = rawRGB */ 728 /* Outformat = rawRGB */
729 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */ 729 {0xa1, 0x21, 0x13, 0xb8, 0x00, 0x00, 0x00, 0x10}, /* init COM8 */
730 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x74, 0x00, 0x10}, 730 {0xd1, 0x21, 0x00, 0x01, 0x74, 0x92, 0x00, 0x10},
731 /* GAIN BLUE RED VREF */ 731 /* GAIN BLUE RED VREF */
732 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10}, 732 {0xd1, 0x21, 0x04, 0x00, 0x7d, 0x62, 0x00, 0x10},
733 /* COM 1 BAVE GEAVE AECHH */ 733 /* COM 1 BAVE GEAVE AECHH */
@@ -783,7 +783,7 @@ static const u8 ov7660_sensor_init[][8] = {
783 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */ 783 {0xc1, 0x21, 0x88, 0xaf, 0xc7, 0xdf, 0x00, 0x10}, /* gamma curve */
784 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */ 784 {0xc1, 0x21, 0x8b, 0x99, 0x99, 0xcf, 0x00, 0x10}, /* reserved */
785 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */ 785 {0xb1, 0x21, 0x92, 0x00, 0x00, 0x00, 0x00, 0x10}, /* DM_LNL/H */
786 {0xb1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10}, 786 {0xa1, 0x21, 0xa1, 0x00, 0x00, 0x00, 0x00, 0x10},
787/****** (some exchanges in the win trace) ******/ 787/****** (some exchanges in the win trace) ******/
788 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */ 788 {0xa1, 0x21, 0x1e, 0x01, 0x00, 0x00, 0x00, 0x10}, /* MVFP */
789 /* bits[3..0]reserved */ 789 /* bits[3..0]reserved */
@@ -1145,17 +1145,12 @@ static int configure_gpio(struct gspca_dev *gspca_dev,
1145 reg_w1(gspca_dev, 0x01, 0x42); 1145 reg_w1(gspca_dev, 0x01, 0x42);
1146 break; 1146 break;
1147 case SENSOR_OV7660: 1147 case SENSOR_OV7660:
1148 reg_w1(gspca_dev, 0x01, 0x61);
1149 reg_w1(gspca_dev, 0x17, 0x20);
1150 reg_w1(gspca_dev, 0x01, 0x60);
1151 reg_w1(gspca_dev, 0x01, 0x40);
1152 break;
1153 case SENSOR_SP80708: 1148 case SENSOR_SP80708:
1154 reg_w1(gspca_dev, 0x01, 0x63); 1149 reg_w1(gspca_dev, 0x01, 0x63);
1155 reg_w1(gspca_dev, 0x17, 0x20); 1150 reg_w1(gspca_dev, 0x17, 0x20);
1156 reg_w1(gspca_dev, 0x01, 0x62); 1151 reg_w1(gspca_dev, 0x01, 0x62);
1157 reg_w1(gspca_dev, 0x01, 0x42); 1152 reg_w1(gspca_dev, 0x01, 0x42);
1158 mdelay(100); 1153 msleep(100);
1159 reg_w1(gspca_dev, 0x02, 0x62); 1154 reg_w1(gspca_dev, 0x02, 0x62);
1160 break; 1155 break;
1161/* case SENSOR_HV7131R: */ 1156/* case SENSOR_HV7131R: */
@@ -1624,6 +1619,8 @@ static void setvflip(struct sd *sd)
1624 1619
1625static void setinfrared(struct sd *sd) 1620static void setinfrared(struct sd *sd)
1626{ 1621{
1622 if (sd->gspca_dev.ctrl_dis & (1 << INFRARED_IDX))
1623 return;
1627/*fixme: different sequence for StarCam Clip and StarCam 370i */ 1624/*fixme: different sequence for StarCam Clip and StarCam 370i */
1628/* Clip */ 1625/* Clip */
1629 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */ 1626 i2c_w1(&sd->gspca_dev, 0x02, /* gpio */
@@ -1637,16 +1634,19 @@ static void setfreq(struct gspca_dev *gspca_dev)
1637 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX)) 1634 if (gspca_dev->ctrl_dis & (1 << FREQ_IDX))
1638 return; 1635 return;
1639 if (sd->sensor == SENSOR_OV7660) { 1636 if (sd->sensor == SENSOR_OV7660) {
1637 u8 com8;
1638
1639 com8 = 0xdf; /* auto gain/wb/expo */
1640 switch (sd->freq) { 1640 switch (sd->freq) {
1641 case 0: /* Banding filter disabled */ 1641 case 0: /* Banding filter disabled */
1642 i2c_w1(gspca_dev, 0x13, 0xdf); 1642 i2c_w1(gspca_dev, 0x13, com8 | 0x20);
1643 break; 1643 break;
1644 case 1: /* 50 hz */ 1644 case 1: /* 50 hz */
1645 i2c_w1(gspca_dev, 0x13, 0xff); 1645 i2c_w1(gspca_dev, 0x13, com8);
1646 i2c_w1(gspca_dev, 0x3b, 0x0a); 1646 i2c_w1(gspca_dev, 0x3b, 0x0a);
1647 break; 1647 break;
1648 case 2: /* 60 hz */ 1648 case 2: /* 60 hz */
1649 i2c_w1(gspca_dev, 0x13, 0xff); 1649 i2c_w1(gspca_dev, 0x13, com8);
1650 i2c_w1(gspca_dev, 0x3b, 0x02); 1650 i2c_w1(gspca_dev, 0x3b, 0x02);
1651 break; 1651 break;
1652 } 1652 }
@@ -1796,12 +1796,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
1796 reg_w1(gspca_dev, 0x99, 0x60); 1796 reg_w1(gspca_dev, 0x99, 0x60);
1797 break; 1797 break;
1798 case SENSOR_OV7660: 1798 case SENSOR_OV7660:
1799 reg_w1(gspca_dev, 0x9a, 0x05);
1800 if (sd->bridge == BRIDGE_SN9C105)
1801 reg_w1(gspca_dev, 0x99, 0xff);
1802 else
1803 reg_w1(gspca_dev, 0x99, 0x5b);
1804 break;
1805 case SENSOR_SP80708: 1799 case SENSOR_SP80708:
1806 reg_w1(gspca_dev, 0x9a, 0x05); 1800 reg_w1(gspca_dev, 0x9a, 0x05);
1807 reg_w1(gspca_dev, 0x99, 0x59); 1801 reg_w1(gspca_dev, 0x99, 0x59);
@@ -2325,18 +2319,19 @@ static const __devinitdata struct usb_device_id device_table[] = {
2325 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)}, 2319 {USB_DEVICE(0x0c45, 0x607c), BSI(SN9C102P, HV7131R, 0x11)},
2326/* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */ 2320/* {USB_DEVICE(0x0c45, 0x607e), BSI(SN9C102P, OV7630, 0x??)}, */
2327 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)}, 2321 {USB_DEVICE(0x0c45, 0x60c0), BSI(SN9C105, MI0360, 0x5d)},
2328/* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6801, 0x??)}, */ 2322/* {USB_DEVICE(0x0c45, 0x60c8), BSI(SN9C105, OM6802, 0x??)}, */
2329/* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */ 2323/* {USB_DEVICE(0x0c45, 0x60cc), BSI(SN9C105, HV7131GP, 0x??)}, */
2330 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)}, 2324 {USB_DEVICE(0x0c45, 0x60ec), BSI(SN9C105, MO4000, 0x21)},
2331/* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */ 2325/* {USB_DEVICE(0x0c45, 0x60ef), BSI(SN9C105, ICM105C, 0x??)}, */
2332/* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */ 2326/* {USB_DEVICE(0x0c45, 0x60fa), BSI(SN9C105, OV7648, 0x??)}, */
2333 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)}, 2327 {USB_DEVICE(0x0c45, 0x60fb), BSI(SN9C105, OV7660, 0x21)},
2334 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
2335#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2328#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2329 {USB_DEVICE(0x0c45, 0x60fc), BSI(SN9C105, HV7131R, 0x11)},
2336 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)}, 2330 {USB_DEVICE(0x0c45, 0x60fe), BSI(SN9C105, OV7630, 0x21)},
2337#endif 2331#endif
2338 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/ 2332 {USB_DEVICE(0x0c45, 0x6100), BSI(SN9C120, MI0360, 0x5d)}, /*sn9c128*/
2339/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6801, 0x??)}, */ 2333/* {USB_DEVICE(0x0c45, 0x6102), BSI(SN9C120, PO2030N, ??)}, */
2334/* {USB_DEVICE(0x0c45, 0x6108), BSI(SN9C120, OM6802, 0x21)}, */
2340 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/ 2335 {USB_DEVICE(0x0c45, 0x610a), BSI(SN9C120, OV7648, 0x21)}, /*sn9c128*/
2341 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/ 2336 {USB_DEVICE(0x0c45, 0x610b), BSI(SN9C120, OV7660, 0x21)}, /*sn9c128*/
2342 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/ 2337 {USB_DEVICE(0x0c45, 0x610c), BSI(SN9C120, HV7131R, 0x11)}, /*sn9c128*/
@@ -2352,6 +2347,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
2352#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2347#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2353 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)}, 2348 {USB_DEVICE(0x0c45, 0x6130), BSI(SN9C120, MI0360, 0x5d)},
2354#endif 2349#endif
2350/* {USB_DEVICE(0x0c45, 0x6132), BSI(SN9C120, OV7670, 0x21)}, */
2355 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)}, 2351 {USB_DEVICE(0x0c45, 0x6138), BSI(SN9C120, MO4000, 0x21)},
2356 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)}, 2352 {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)},
2357#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 2353#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
@@ -2359,7 +2355,9 @@ static const __devinitdata struct usb_device_id device_table[] = {
2359#endif 2355#endif
2360 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, 2356 {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)},
2361 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)}, 2357 {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x21)},
2362 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, 2358/* {USB_DEVICE(0x0c45, 0x6142), BSI(SN9C120, PO2030N, ??)}, *sn9c120b*/
2359 {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, /*sn9c120b*/
2360 {USB_DEVICE(0x0c45, 0x6148), BSI(SN9C120, OM6802, 0x21)}, /*sn9c120b*/
2363 {} 2361 {}
2364}; 2362};
2365MODULE_DEVICE_TABLE(usb, device_table); 2363MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index d48b27c648ca..b74a34218da0 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -1923,7 +1923,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
1923 1923
1924 cam = &gspca_dev->cam; 1924 cam = &gspca_dev->cam;
1925 cam->cam_mode = vga_mode; 1925 cam->cam_mode = vga_mode;
1926 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 1926 cam->nmodes = ARRAY_SIZE(vga_mode);
1927 sd->subtype = id->driver_info; 1927 sd->subtype = id->driver_info;
1928 sd->brightness = sd_ctrls[MY_BRIGHTNESS].qctrl.default_value; 1928 sd->brightness = sd_ctrls[MY_BRIGHTNESS].qctrl.default_value;
1929 sd->contrast = sd_ctrls[MY_CONTRAST].qctrl.default_value; 1929 sd->contrast = sd_ctrls[MY_CONTRAST].qctrl.default_value;
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
index 3a0c893f942d..a199298a6419 100644
--- a/drivers/media/video/gspca/spca506.c
+++ b/drivers/media/video/gspca/spca506.c
@@ -286,7 +286,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
286 286
287 cam = &gspca_dev->cam; 287 cam = &gspca_dev->cam;
288 cam->cam_mode = vga_mode; 288 cam->cam_mode = vga_mode;
289 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 289 cam->nmodes = ARRAY_SIZE(vga_mode);
290 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; 290 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
291 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; 291 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
292 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; 292 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index 2ed2669bac3e..9696c4caf5c9 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -1304,19 +1304,70 @@ static int reg_read(struct gspca_dev *gspca_dev,
1304 return gspca_dev->usb_buf[0]; 1304 return gspca_dev->usb_buf[0];
1305} 1305}
1306 1306
1307/* send 1 or 2 bytes to the sensor via the Synchronous Serial Interface */
1308static int ssi_w(struct gspca_dev *gspca_dev,
1309 u16 reg, u16 val)
1310{
1311 struct usb_device *dev = gspca_dev->dev;
1312 int ret, retry;
1313
1314 ret = reg_write(dev, 0x8802, reg >> 8);
1315 if (ret < 0)
1316 goto out;
1317 ret = reg_write(dev, 0x8801, reg & 0x00ff);
1318 if (ret < 0)
1319 goto out;
1320 if ((reg & 0xff00) == 0x1000) { /* if 2 bytes */
1321 ret = reg_write(dev, 0x8805, val & 0x00ff);
1322 if (ret < 0)
1323 goto out;
1324 val >>= 8;
1325 }
1326 ret = reg_write(dev, 0x8800, val);
1327 if (ret < 0)
1328 goto out;
1329
1330 /* poll until not busy */
1331 retry = 10;
1332 for (;;) {
1333 ret = reg_read(gspca_dev, 0x8803);
1334 if (ret < 0)
1335 break;
1336 if (gspca_dev->usb_buf[0] == 0)
1337 break;
1338 if (--retry <= 0) {
1339 PDEBUG(D_ERR, "ssi_w busy %02x",
1340 gspca_dev->usb_buf[0]);
1341 ret = -1;
1342 break;
1343 }
1344 msleep(8);
1345 }
1346
1347out:
1348 return ret;
1349}
1350
1307static int write_vector(struct gspca_dev *gspca_dev, 1351static int write_vector(struct gspca_dev *gspca_dev,
1308 const u16 (*data)[2]) 1352 const u16 (*data)[2])
1309{ 1353{
1310 struct usb_device *dev = gspca_dev->dev; 1354 struct usb_device *dev = gspca_dev->dev;
1311 int ret; 1355 int ret = 0;
1312 1356
1313 while ((*data)[1] != 0) { 1357 while ((*data)[1] != 0) {
1314 ret = reg_write(dev, (*data)[1], (*data)[0]); 1358 if ((*data)[1] & 0x8000) {
1359 if ((*data)[1] == 0xdd00) /* delay */
1360 msleep((*data)[0]);
1361 else
1362 ret = reg_write(dev, (*data)[1], (*data)[0]);
1363 } else {
1364 ret = ssi_w(gspca_dev, (*data)[1], (*data)[0]);
1365 }
1315 if (ret < 0) 1366 if (ret < 0)
1316 return ret; 1367 break;
1317 data++; 1368 data++;
1318 } 1369 }
1319 return 0; 1370 return ret;
1320} 1371}
1321 1372
1322/* this function is called at probe time */ 1373/* this function is called at probe time */
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c
index 0da8e0de0456..7af511b5e9c2 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.c
@@ -130,8 +130,8 @@ int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len)
130 STV06XX_URB_MSG_TIMEOUT); 130 STV06XX_URB_MSG_TIMEOUT);
131 if (err < 0) 131 if (err < 0)
132 return err; 132 return err;
133 } 133 }
134 return stv06xx_write_sensor_finish(sd); 134 return stv06xx_write_sensor_finish(sd);
135} 135}
136 136
137int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len) 137int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len)
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index 5127bbf9dd26..aa8f995ce04e 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -32,26 +32,27 @@ MODULE_LICENSE("GPL");
32struct sd { 32struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */ 33 struct gspca_dev gspca_dev; /* !! must be the first item */
34 34
35 unsigned char brightness; 35 s8 brightness;
36 unsigned char contrast; 36 u8 contrast;
37 unsigned char colors; 37 u8 colors;
38 unsigned char autogain; 38 u8 autogain;
39 u8 quality; 39 u8 quality;
40#define QUALITY_MIN 70 40#define QUALITY_MIN 70
41#define QUALITY_MAX 95 41#define QUALITY_MAX 95
42#define QUALITY_DEF 85 42#define QUALITY_DEF 85
43 43
44 char bridge; 44 u8 bridge;
45#define BRIDGE_SPCA504 0 45#define BRIDGE_SPCA504 0
46#define BRIDGE_SPCA504B 1 46#define BRIDGE_SPCA504B 1
47#define BRIDGE_SPCA504C 2 47#define BRIDGE_SPCA504C 2
48#define BRIDGE_SPCA533 3 48#define BRIDGE_SPCA533 3
49#define BRIDGE_SPCA536 4 49#define BRIDGE_SPCA536 4
50 char subtype; 50 u8 subtype;
51#define AiptekMiniPenCam13 1 51#define AiptekMiniPenCam13 1
52#define LogitechClickSmart420 2 52#define LogitechClickSmart420 2
53#define LogitechClickSmart820 3 53#define LogitechClickSmart820 3
54#define MegapixV4 4 54#define MegapixV4 4
55#define MegaImageVI 5
55 56
56 u8 *jpeg_hdr; 57 u8 *jpeg_hdr;
57}; 58};
@@ -67,21 +68,20 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
67static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 68static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
68 69
69static struct ctrl sd_ctrls[] = { 70static struct ctrl sd_ctrls[] = {
70#define SD_BRIGHTNESS 0
71 { 71 {
72 { 72 {
73 .id = V4L2_CID_BRIGHTNESS, 73 .id = V4L2_CID_BRIGHTNESS,
74 .type = V4L2_CTRL_TYPE_INTEGER, 74 .type = V4L2_CTRL_TYPE_INTEGER,
75 .name = "Brightness", 75 .name = "Brightness",
76 .minimum = 0, 76 .minimum = -128,
77 .maximum = 0xff, 77 .maximum = 127,
78 .step = 1, 78 .step = 1,
79 .default_value = 0, 79#define BRIGHTNESS_DEF 0
80 .default_value = BRIGHTNESS_DEF,
80 }, 81 },
81 .set = sd_setbrightness, 82 .set = sd_setbrightness,
82 .get = sd_getbrightness, 83 .get = sd_getbrightness,
83 }, 84 },
84#define SD_CONTRAST 1
85 { 85 {
86 { 86 {
87 .id = V4L2_CID_CONTRAST, 87 .id = V4L2_CID_CONTRAST,
@@ -90,12 +90,12 @@ static struct ctrl sd_ctrls[] = {
90 .minimum = 0, 90 .minimum = 0,
91 .maximum = 0xff, 91 .maximum = 0xff,
92 .step = 1, 92 .step = 1,
93 .default_value = 0x20, 93#define CONTRAST_DEF 0x20
94 .default_value = CONTRAST_DEF,
94 }, 95 },
95 .set = sd_setcontrast, 96 .set = sd_setcontrast,
96 .get = sd_getcontrast, 97 .get = sd_getcontrast,
97 }, 98 },
98#define SD_COLOR 2
99 { 99 {
100 { 100 {
101 .id = V4L2_CID_SATURATION, 101 .id = V4L2_CID_SATURATION,
@@ -104,12 +104,12 @@ static struct ctrl sd_ctrls[] = {
104 .minimum = 0, 104 .minimum = 0,
105 .maximum = 0xff, 105 .maximum = 0xff,
106 .step = 1, 106 .step = 1,
107 .default_value = 0x1a, 107#define COLOR_DEF 0x1a
108 .default_value = COLOR_DEF,
108 }, 109 },
109 .set = sd_setcolors, 110 .set = sd_setcolors,
110 .get = sd_getcolors, 111 .get = sd_getcolors,
111 }, 112 },
112#define SD_AUTOGAIN 3
113 { 113 {
114 { 114 {
115 .id = V4L2_CID_AUTOGAIN, 115 .id = V4L2_CID_AUTOGAIN,
@@ -118,7 +118,8 @@ static struct ctrl sd_ctrls[] = {
118 .minimum = 0, 118 .minimum = 0,
119 .maximum = 1, 119 .maximum = 1,
120 .step = 1, 120 .step = 1,
121 .default_value = 1, 121#define AUTOGAIN_DEF 1
122 .default_value = AUTOGAIN_DEF,
122 }, 123 },
123 .set = sd_setautogain, 124 .set = sd_setautogain,
124 .get = sd_getautogain, 125 .get = sd_getautogain,
@@ -180,14 +181,20 @@ static const struct v4l2_pix_format vga_mode2[] = {
180#define SPCA504_PCCAM600_OFFSET_MODE 5 181#define SPCA504_PCCAM600_OFFSET_MODE 5
181#define SPCA504_PCCAM600_OFFSET_DATA 14 182#define SPCA504_PCCAM600_OFFSET_DATA 14
182 /* Frame packet header offsets for the spca533 */ 183 /* Frame packet header offsets for the spca533 */
183#define SPCA533_OFFSET_DATA 16 184#define SPCA533_OFFSET_DATA 16
184#define SPCA533_OFFSET_FRAMSEQ 15 185#define SPCA533_OFFSET_FRAMSEQ 15
185/* Frame packet header offsets for the spca536 */ 186/* Frame packet header offsets for the spca536 */
186#define SPCA536_OFFSET_DATA 4 187#define SPCA536_OFFSET_DATA 4
187#define SPCA536_OFFSET_FRAMSEQ 1 188#define SPCA536_OFFSET_FRAMSEQ 1
189
190struct cmd {
191 u8 req;
192 u16 val;
193 u16 idx;
194};
188 195
189/* Initialisation data for the Creative PC-CAM 600 */ 196/* Initialisation data for the Creative PC-CAM 600 */
190static const __u16 spca504_pccam600_init_data[][3] = { 197static const struct cmd spca504_pccam600_init_data[] = {
191/* {0xa0, 0x0000, 0x0503}, * capture mode */ 198/* {0xa0, 0x0000, 0x0503}, * capture mode */
192 {0x00, 0x0000, 0x2000}, 199 {0x00, 0x0000, 0x2000},
193 {0x00, 0x0013, 0x2301}, 200 {0x00, 0x0013, 0x2301},
@@ -211,22 +218,20 @@ static const __u16 spca504_pccam600_init_data[][3] = {
211 {0x00, 0x0003, 0x2000}, 218 {0x00, 0x0003, 0x2000},
212 {0x00, 0x0013, 0x2301}, 219 {0x00, 0x0013, 0x2301},
213 {0x00, 0x0003, 0x2000}, 220 {0x00, 0x0003, 0x2000},
214 {}
215}; 221};
216 222
217/* Creative PC-CAM 600 specific open data, sent before using the 223/* Creative PC-CAM 600 specific open data, sent before using the
218 * generic initialisation data from spca504_open_data. 224 * generic initialisation data from spca504_open_data.
219 */ 225 */
220static const __u16 spca504_pccam600_open_data[][3] = { 226static const struct cmd spca504_pccam600_open_data[] = {
221 {0x00, 0x0001, 0x2501}, 227 {0x00, 0x0001, 0x2501},
222 {0x20, 0x0500, 0x0001}, /* snapshot mode */ 228 {0x20, 0x0500, 0x0001}, /* snapshot mode */
223 {0x00, 0x0003, 0x2880}, 229 {0x00, 0x0003, 0x2880},
224 {0x00, 0x0001, 0x2881}, 230 {0x00, 0x0001, 0x2881},
225 {}
226}; 231};
227 232
228/* Initialisation data for the logitech clicksmart 420 */ 233/* Initialisation data for the logitech clicksmart 420 */
229static const __u16 spca504A_clicksmart420_init_data[][3] = { 234static const struct cmd spca504A_clicksmart420_init_data[] = {
230/* {0xa0, 0x0000, 0x0503}, * capture mode */ 235/* {0xa0, 0x0000, 0x0503}, * capture mode */
231 {0x00, 0x0000, 0x2000}, 236 {0x00, 0x0000, 0x2000},
232 {0x00, 0x0013, 0x2301}, 237 {0x00, 0x0013, 0x2301},
@@ -243,7 +248,7 @@ static const __u16 spca504A_clicksmart420_init_data[][3] = {
243 {0xb0, 0x0001, 0x0000}, 248 {0xb0, 0x0001, 0x0000},
244 249
245 250
246 {0x0a1, 0x0080, 0x0001}, 251 {0xa1, 0x0080, 0x0001},
247 {0x30, 0x0049, 0x0000}, 252 {0x30, 0x0049, 0x0000},
248 {0x30, 0x0060, 0x0005}, 253 {0x30, 0x0060, 0x0005},
249 {0x0c, 0x0004, 0x0000}, 254 {0x0c, 0x0004, 0x0000},
@@ -253,11 +258,10 @@ static const __u16 spca504A_clicksmart420_init_data[][3] = {
253 {0x00, 0x0003, 0x2000}, 258 {0x00, 0x0003, 0x2000},
254 {0x00, 0x0000, 0x2000}, 259 {0x00, 0x0000, 0x2000},
255 260
256 {}
257}; 261};
258 262
259/* clicksmart 420 open data ? */ 263/* clicksmart 420 open data ? */
260static const __u16 spca504A_clicksmart420_open_data[][3] = { 264static const struct cmd spca504A_clicksmart420_open_data[] = {
261 {0x00, 0x0001, 0x2501}, 265 {0x00, 0x0001, 0x2501},
262 {0x20, 0x0502, 0x0000}, 266 {0x20, 0x0502, 0x0000},
263 {0x06, 0x0000, 0x0000}, 267 {0x06, 0x0000, 0x0000},
@@ -401,10 +405,9 @@ static const __u16 spca504A_clicksmart420_open_data[][3] = {
401 {0x00, 0x0028, 0x287f}, 405 {0x00, 0x0028, 0x287f},
402 406
403 {0xa0, 0x0000, 0x0503}, 407 {0xa0, 0x0000, 0x0503},
404 {}
405}; 408};
406 409
407static const __u8 qtable_creative_pccam[2][64] = { 410static const u8 qtable_creative_pccam[2][64] = {
408 { /* Q-table Y-components */ 411 { /* Q-table Y-components */
409 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, 412 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
410 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, 413 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -429,7 +432,7 @@ static const __u8 qtable_creative_pccam[2][64] = {
429 * except for one byte. Possibly a typo? 432 * except for one byte. Possibly a typo?
430 * NWG: 18/05/2003. 433 * NWG: 18/05/2003.
431 */ 434 */
432static const __u8 qtable_spca504_default[2][64] = { 435static const u8 qtable_spca504_default[2][64] = {
433 { /* Q-table Y-components */ 436 { /* Q-table Y-components */
434 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, 437 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
435 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, 438 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -453,9 +456,9 @@ static const __u8 qtable_spca504_default[2][64] = {
453 456
454/* read <len> bytes to gspca_dev->usb_buf */ 457/* read <len> bytes to gspca_dev->usb_buf */
455static void reg_r(struct gspca_dev *gspca_dev, 458static void reg_r(struct gspca_dev *gspca_dev,
456 __u16 req, 459 u8 req,
457 __u16 index, 460 u16 index,
458 __u16 len) 461 u16 len)
459{ 462{
460#ifdef GSPCA_DEBUG 463#ifdef GSPCA_DEBUG
461 if (len > USB_BUF_SZ) { 464 if (len > USB_BUF_SZ) {
@@ -473,31 +476,26 @@ static void reg_r(struct gspca_dev *gspca_dev,
473 500); 476 500);
474} 477}
475 478
476/* write <len> bytes from gspca_dev->usb_buf */ 479/* write one byte */
477static void reg_w(struct gspca_dev *gspca_dev, 480static void reg_w_1(struct gspca_dev *gspca_dev,
478 __u16 req, 481 u8 req,
479 __u16 value, 482 u16 value,
480 __u16 index, 483 u16 index,
481 __u16 len) 484 u16 byte)
482{ 485{
483#ifdef GSPCA_DEBUG 486 gspca_dev->usb_buf[0] = byte;
484 if (len > USB_BUF_SZ) {
485 err("reg_w: buffer overflow");
486 return;
487 }
488#endif
489 usb_control_msg(gspca_dev->dev, 487 usb_control_msg(gspca_dev->dev,
490 usb_sndctrlpipe(gspca_dev->dev, 0), 488 usb_sndctrlpipe(gspca_dev->dev, 0),
491 req, 489 req,
492 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 490 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
493 value, index, 491 value, index,
494 len ? gspca_dev->usb_buf : NULL, len, 492 gspca_dev->usb_buf, 1,
495 500); 493 500);
496} 494}
497 495
498/* write req / index / value */ 496/* write req / index / value */
499static int reg_w_riv(struct usb_device *dev, 497static int reg_w_riv(struct usb_device *dev,
500 __u16 req, __u16 index, __u16 value) 498 u8 req, u16 index, u16 value)
501{ 499{
502 int ret; 500 int ret;
503 501
@@ -515,7 +513,7 @@ static int reg_w_riv(struct usb_device *dev,
515 513
516/* read 1 byte */ 514/* read 1 byte */
517static int reg_r_1(struct gspca_dev *gspca_dev, 515static int reg_r_1(struct gspca_dev *gspca_dev,
518 __u16 value) /* wValue */ 516 u16 value) /* wValue */
519{ 517{
520 int ret; 518 int ret;
521 519
@@ -536,9 +534,9 @@ static int reg_r_1(struct gspca_dev *gspca_dev,
536 534
537/* read 1 or 2 bytes - returns < 0 if error */ 535/* read 1 or 2 bytes - returns < 0 if error */
538static int reg_r_12(struct gspca_dev *gspca_dev, 536static int reg_r_12(struct gspca_dev *gspca_dev,
539 __u16 req, /* bRequest */ 537 u8 req, /* bRequest */
540 __u16 index, /* wIndex */ 538 u16 index, /* wIndex */
541 __u16 length) /* wLength (1 or 2 only) */ 539 u16 length) /* wLength (1 or 2 only) */
542{ 540{
543 int ret; 541 int ret;
544 542
@@ -559,43 +557,40 @@ static int reg_r_12(struct gspca_dev *gspca_dev,
559} 557}
560 558
561static int write_vector(struct gspca_dev *gspca_dev, 559static int write_vector(struct gspca_dev *gspca_dev,
562 const __u16 data[][3]) 560 const struct cmd *data, int ncmds)
563{ 561{
564 struct usb_device *dev = gspca_dev->dev; 562 struct usb_device *dev = gspca_dev->dev;
565 int ret, i = 0; 563 int ret;
566 564
567 while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { 565 while (--ncmds >= 0) {
568 ret = reg_w_riv(dev, data[i][0], data[i][2], data[i][1]); 566 ret = reg_w_riv(dev, data->req, data->idx, data->val);
569 if (ret < 0) { 567 if (ret < 0) {
570 PDEBUG(D_ERR, 568 PDEBUG(D_ERR,
571 "Register write failed for 0x%x,0x%x,0x%x", 569 "Register write failed for 0x%02x, 0x%04x, 0x%04x",
572 data[i][0], data[i][1], data[i][2]); 570 data->req, data->val, data->idx);
573 return ret; 571 return ret;
574 } 572 }
575 i++; 573 data++;
576 } 574 }
577 return 0; 575 return 0;
578} 576}
579 577
580static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, 578static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
581 unsigned int request, 579 const u8 qtable[2][64])
582 unsigned int ybase,
583 unsigned int cbase,
584 const __u8 qtable[2][64])
585{ 580{
586 struct usb_device *dev = gspca_dev->dev; 581 struct usb_device *dev = gspca_dev->dev;
587 int i, err; 582 int i, err;
588 583
589 /* loop over y components */ 584 /* loop over y components */
590 for (i = 0; i < 64; i++) { 585 for (i = 0; i < 64; i++) {
591 err = reg_w_riv(dev, request, ybase + i, qtable[0][i]); 586 err = reg_w_riv(dev, 0x00, 0x2800 + i, qtable[0][i]);
592 if (err < 0) 587 if (err < 0)
593 return err; 588 return err;
594 } 589 }
595 590
596 /* loop over c components */ 591 /* loop over c components */
597 for (i = 0; i < 64; i++) { 592 for (i = 0; i < 64; i++) {
598 err = reg_w_riv(dev, request, cbase + i, qtable[1][i]); 593 err = reg_w_riv(dev, 0x00, 0x2840 + i, qtable[1][i]);
599 if (err < 0) 594 if (err < 0)
600 return err; 595 return err;
601 } 596 }
@@ -603,34 +598,34 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
603} 598}
604 599
605static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, 600static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
606 __u16 req, __u16 idx, __u16 val) 601 u8 req, u16 idx, u16 val)
607{ 602{
608 struct usb_device *dev = gspca_dev->dev; 603 struct usb_device *dev = gspca_dev->dev;
609 __u8 notdone; 604 int notdone;
610 605
611 reg_w_riv(dev, req, idx, val); 606 reg_w_riv(dev, req, idx, val);
612 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 607 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
613 reg_w_riv(dev, req, idx, val); 608 reg_w_riv(dev, req, idx, val);
614 609
615 PDEBUG(D_FRAM, "before wait 0x%x", notdone); 610 PDEBUG(D_FRAM, "before wait 0x%04x", notdone);
616 611
617 msleep(200); 612 msleep(200);
618 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 613 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
619 PDEBUG(D_FRAM, "after wait 0x%x", notdone); 614 PDEBUG(D_FRAM, "after wait 0x%04x", notdone);
620} 615}
621 616
622static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, 617static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
623 __u16 req, 618 u8 req,
624 __u16 idx, __u16 val, __u8 stat, __u8 count) 619 u16 idx, u16 val, u8 stat, u8 count)
625{ 620{
626 struct usb_device *dev = gspca_dev->dev; 621 struct usb_device *dev = gspca_dev->dev;
627 __u8 status; 622 int status;
628 __u8 endcode; 623 u8 endcode;
629 624
630 reg_w_riv(dev, req, idx, val); 625 reg_w_riv(dev, req, idx, val);
631 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 626 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
632 endcode = stat; 627 endcode = stat;
633 PDEBUG(D_FRAM, "Status 0x%x Need 0x%x", status, stat); 628 PDEBUG(D_FRAM, "Status 0x%x Need 0x%04x", status, stat);
634 if (!count) 629 if (!count)
635 return; 630 return;
636 count = 200; 631 count = 200;
@@ -640,7 +635,7 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
640/* reg_w_riv(dev, req, idx, val); */ 635/* reg_w_riv(dev, req, idx, val); */
641 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 636 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
642 if (status == endcode) { 637 if (status == endcode) {
643 PDEBUG(D_FRAM, "status 0x%x after wait 0x%x", 638 PDEBUG(D_FRAM, "status 0x%04x after wait %d",
644 status, 200 - count); 639 status, 200 - count);
645 break; 640 break;
646 } 641 }
@@ -667,8 +662,7 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
667 while (--count > 0) { 662 while (--count > 0) {
668 reg_r(gspca_dev, 0x21, 1, 1); 663 reg_r(gspca_dev, 0x21, 1, 1);
669 if (gspca_dev->usb_buf[0] != 0) { 664 if (gspca_dev->usb_buf[0] != 0) {
670 gspca_dev->usb_buf[0] = 0; 665 reg_w_1(gspca_dev, 0x21, 0, 1, 0);
671 reg_w(gspca_dev, 0x21, 0, 1, 1);
672 reg_r(gspca_dev, 0x21, 1, 1); 666 reg_r(gspca_dev, 0x21, 1, 1);
673 spca504B_PollingDataReady(gspca_dev); 667 spca504B_PollingDataReady(gspca_dev);
674 break; 668 break;
@@ -679,7 +673,7 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
679 673
680static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) 674static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
681{ 675{
682 __u8 *data; 676 u8 *data;
683 677
684 data = gspca_dev->usb_buf; 678 data = gspca_dev->usb_buf;
685 reg_r(gspca_dev, 0x20, 0, 5); 679 reg_r(gspca_dev, 0x20, 0, 5);
@@ -693,41 +687,34 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
693{ 687{
694 struct sd *sd = (struct sd *) gspca_dev; 688 struct sd *sd = (struct sd *) gspca_dev;
695 struct usb_device *dev = gspca_dev->dev; 689 struct usb_device *dev = gspca_dev->dev;
696 __u8 Size; 690 u8 Size;
697 __u8 Type;
698 int rc; 691 int rc;
699 692
700 Size = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 693 Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
701 Type = 0;
702 switch (sd->bridge) { 694 switch (sd->bridge) {
703 case BRIDGE_SPCA533: 695 case BRIDGE_SPCA533:
704 reg_w(gspca_dev, 0x31, 0, 0, 0); 696 reg_w_riv(dev, 0x31, 0, 0);
705 spca504B_WaitCmdStatus(gspca_dev); 697 spca504B_WaitCmdStatus(gspca_dev);
706 rc = spca504B_PollingDataReady(gspca_dev); 698 rc = spca504B_PollingDataReady(gspca_dev);
707 spca50x_GetFirmware(gspca_dev); 699 spca50x_GetFirmware(gspca_dev);
708 gspca_dev->usb_buf[0] = 2; /* type */ 700 reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
709 reg_w(gspca_dev, 0x24, 0, 8, 1);
710 reg_r(gspca_dev, 0x24, 8, 1); 701 reg_r(gspca_dev, 0x24, 8, 1);
711 702
712 gspca_dev->usb_buf[0] = Size; 703 reg_w_1(gspca_dev, 0x25, 0, 4, Size);
713 reg_w(gspca_dev, 0x25, 0, 4, 1);
714 reg_r(gspca_dev, 0x25, 4, 1); /* size */ 704 reg_r(gspca_dev, 0x25, 4, 1); /* size */
715 rc = spca504B_PollingDataReady(gspca_dev); 705 rc = spca504B_PollingDataReady(gspca_dev);
716 706
717 /* Init the cam width height with some values get on init ? */ 707 /* Init the cam width height with some values get on init ? */
718 reg_w(gspca_dev, 0x31, 0, 4, 0); 708 reg_w_riv(dev, 0x31, 0, 0x04);
719 spca504B_WaitCmdStatus(gspca_dev); 709 spca504B_WaitCmdStatus(gspca_dev);
720 rc = spca504B_PollingDataReady(gspca_dev); 710 rc = spca504B_PollingDataReady(gspca_dev);
721 break; 711 break;
722 default: 712 default:
723/* case BRIDGE_SPCA504B: */ 713/* case BRIDGE_SPCA504B: */
724/* case BRIDGE_SPCA536: */ 714/* case BRIDGE_SPCA536: */
725 gspca_dev->usb_buf[0] = Size; 715 reg_w_1(gspca_dev, 0x25, 0, 4, Size);
726 reg_w(gspca_dev, 0x25, 0, 4, 1);
727 reg_r(gspca_dev, 0x25, 4, 1); /* size */ 716 reg_r(gspca_dev, 0x25, 4, 1); /* size */
728 Type = 6; 717 reg_w_1(gspca_dev, 0x27, 0, 0, 6);
729 gspca_dev->usb_buf[0] = Type;
730 reg_w(gspca_dev, 0x27, 0, 0, 1);
731 reg_r(gspca_dev, 0x27, 0, 1); /* type */ 718 reg_r(gspca_dev, 0x27, 0, 1); /* type */
732 rc = spca504B_PollingDataReady(gspca_dev); 719 rc = spca504B_PollingDataReady(gspca_dev);
733 break; 720 break;
@@ -767,17 +754,51 @@ static void spca504_wait_status(struct gspca_dev *gspca_dev)
767 754
768static void spca504B_setQtable(struct gspca_dev *gspca_dev) 755static void spca504B_setQtable(struct gspca_dev *gspca_dev)
769{ 756{
770 gspca_dev->usb_buf[0] = 3; 757 reg_w_1(gspca_dev, 0x26, 0, 0, 3);
771 reg_w(gspca_dev, 0x26, 0, 0, 1);
772 reg_r(gspca_dev, 0x26, 0, 1); 758 reg_r(gspca_dev, 0x26, 0, 1);
773 spca504B_PollingDataReady(gspca_dev); 759 spca504B_PollingDataReady(gspca_dev);
774} 760}
775 761
776static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev) 762static void setbrightness(struct gspca_dev *gspca_dev)
763{
764 struct sd *sd = (struct sd *) gspca_dev;
765 struct usb_device *dev = gspca_dev->dev;
766 u16 reg;
767
768 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7;
769 reg_w_riv(dev, 0x00, reg, sd->brightness);
770}
771
772static void setcontrast(struct gspca_dev *gspca_dev)
773{
774 struct sd *sd = (struct sd *) gspca_dev;
775 struct usb_device *dev = gspca_dev->dev;
776 u16 reg;
777
778 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8;
779 reg_w_riv(dev, 0x00, reg, sd->contrast);
780}
781
782static void setcolors(struct gspca_dev *gspca_dev)
783{
784 struct sd *sd = (struct sd *) gspca_dev;
785 struct usb_device *dev = gspca_dev->dev;
786 u16 reg;
787
788 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae;
789 reg_w_riv(dev, 0x00, reg, sd->colors);
790}
791
792static void init_ctl_reg(struct gspca_dev *gspca_dev)
777{ 793{
778 struct sd *sd = (struct sd *) gspca_dev; 794 struct sd *sd = (struct sd *) gspca_dev;
795 struct usb_device *dev = gspca_dev->dev;
779 int pollreg = 1; 796 int pollreg = 1;
780 797
798 setbrightness(gspca_dev);
799 setcontrast(gspca_dev);
800 setcolors(gspca_dev);
801
781 switch (sd->bridge) { 802 switch (sd->bridge) {
782 case BRIDGE_SPCA504: 803 case BRIDGE_SPCA504:
783 case BRIDGE_SPCA504C: 804 case BRIDGE_SPCA504C:
@@ -786,20 +807,14 @@ static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev)
786 default: 807 default:
787/* case BRIDGE_SPCA533: */ 808/* case BRIDGE_SPCA533: */
788/* case BRIDGE_SPCA504B: */ 809/* case BRIDGE_SPCA504B: */
789 reg_w(gspca_dev, 0, 0, 0x21a7, 0); /* brightness */ 810 reg_w_riv(dev, 0, 0x00, 0x21ad); /* hue */
790 reg_w(gspca_dev, 0, 0x20, 0x21a8, 0); /* contrast */ 811 reg_w_riv(dev, 0, 0x01, 0x21ac); /* sat/hue */
791 reg_w(gspca_dev, 0, 0, 0x21ad, 0); /* hue */ 812 reg_w_riv(dev, 0, 0x00, 0x21a3); /* gamma */
792 reg_w(gspca_dev, 0, 1, 0x21ac, 0); /* sat/hue */
793 reg_w(gspca_dev, 0, 0x20, 0x21ae, 0); /* saturation */
794 reg_w(gspca_dev, 0, 0, 0x21a3, 0); /* gamma */
795 break; 813 break;
796 case BRIDGE_SPCA536: 814 case BRIDGE_SPCA536:
797 reg_w(gspca_dev, 0, 0, 0x20f0, 0); 815 reg_w_riv(dev, 0, 0x40, 0x20f5);
798 reg_w(gspca_dev, 0, 0x21, 0x20f1, 0); 816 reg_w_riv(dev, 0, 0x01, 0x20f4);
799 reg_w(gspca_dev, 0, 0x40, 0x20f5, 0); 817 reg_w_riv(dev, 0, 0x00, 0x2089);
800 reg_w(gspca_dev, 0, 1, 0x20f4, 0);
801 reg_w(gspca_dev, 0, 0x40, 0x20f6, 0);
802 reg_w(gspca_dev, 0, 0, 0x2089, 0);
803 break; 818 break;
804 } 819 }
805 if (pollreg) 820 if (pollreg)
@@ -840,20 +855,24 @@ static int sd_config(struct gspca_dev *gspca_dev,
840/* case BRIDGE_SPCA504: */ 855/* case BRIDGE_SPCA504: */
841/* case BRIDGE_SPCA536: */ 856/* case BRIDGE_SPCA536: */
842 cam->cam_mode = vga_mode; 857 cam->cam_mode = vga_mode;
843 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 858 cam->nmodes =ARRAY_SIZE(vga_mode);
844 break; 859 break;
845 case BRIDGE_SPCA533: 860 case BRIDGE_SPCA533:
846 cam->cam_mode = custom_mode; 861 cam->cam_mode = custom_mode;
847 cam->nmodes = sizeof custom_mode / sizeof custom_mode[0]; 862 if (sd->subtype == MegaImageVI) /* 320x240 only */
863 cam->nmodes = ARRAY_SIZE(custom_mode) - 1;
864 else
865 cam->nmodes = ARRAY_SIZE(custom_mode);
848 break; 866 break;
849 case BRIDGE_SPCA504C: 867 case BRIDGE_SPCA504C:
850 cam->cam_mode = vga_mode2; 868 cam->cam_mode = vga_mode2;
851 cam->nmodes = sizeof vga_mode2 / sizeof vga_mode2[0]; 869 cam->nmodes = ARRAY_SIZE(vga_mode2);
852 break; 870 break;
853 } 871 }
854 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; 872 sd->brightness = BRIGHTNESS_DEF;
855 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; 873 sd->contrast = CONTRAST_DEF;
856 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; 874 sd->colors = COLOR_DEF;
875 sd->autogain = AUTOGAIN_DEF;
857 sd->quality = QUALITY_DEF; 876 sd->quality = QUALITY_DEF;
858 return 0; 877 return 0;
859} 878}
@@ -863,32 +882,29 @@ static int sd_init(struct gspca_dev *gspca_dev)
863{ 882{
864 struct sd *sd = (struct sd *) gspca_dev; 883 struct sd *sd = (struct sd *) gspca_dev;
865 struct usb_device *dev = gspca_dev->dev; 884 struct usb_device *dev = gspca_dev->dev;
866 int rc; 885 int i, err_code;
867 __u8 i; 886 u8 info[6];
868 __u8 info[6];
869 int err_code;
870 887
871 switch (sd->bridge) { 888 switch (sd->bridge) {
872 case BRIDGE_SPCA504B: 889 case BRIDGE_SPCA504B:
873 reg_w(gspca_dev, 0x1d, 0, 0, 0); 890 reg_w_riv(dev, 0x1d, 0x00, 0);
874 reg_w(gspca_dev, 0, 1, 0x2306, 0); 891 reg_w_riv(dev, 0, 0x01, 0x2306);
875 reg_w(gspca_dev, 0, 0, 0x0d04, 0); 892 reg_w_riv(dev, 0, 0x00, 0x0d04);
876 reg_w(gspca_dev, 0, 0, 0x2000, 0); 893 reg_w_riv(dev, 0, 0x00, 0x2000);
877 reg_w(gspca_dev, 0, 0x13, 0x2301, 0); 894 reg_w_riv(dev, 0, 0x13, 0x2301);
878 reg_w(gspca_dev, 0, 0, 0x2306, 0); 895 reg_w_riv(dev, 0, 0x00, 0x2306);
879 /* fall thru */ 896 /* fall thru */
880 case BRIDGE_SPCA533: 897 case BRIDGE_SPCA533:
881 rc = spca504B_PollingDataReady(gspca_dev); 898 spca504B_PollingDataReady(gspca_dev);
882 spca50x_GetFirmware(gspca_dev); 899 spca50x_GetFirmware(gspca_dev);
883 break; 900 break;
884 case BRIDGE_SPCA536: 901 case BRIDGE_SPCA536:
885 spca50x_GetFirmware(gspca_dev); 902 spca50x_GetFirmware(gspca_dev);
886 reg_r(gspca_dev, 0x00, 0x5002, 1); 903 reg_r(gspca_dev, 0x00, 0x5002, 1);
887 gspca_dev->usb_buf[0] = 0; 904 reg_w_1(gspca_dev, 0x24, 0, 0, 0);
888 reg_w(gspca_dev, 0x24, 0, 0, 1);
889 reg_r(gspca_dev, 0x24, 0, 1); 905 reg_r(gspca_dev, 0x24, 0, 1);
890 rc = spca504B_PollingDataReady(gspca_dev); 906 spca504B_PollingDataReady(gspca_dev);
891 reg_w(gspca_dev, 0x34, 0, 0, 0); 907 reg_w_riv(dev, 0x34, 0, 0);
892 spca504B_WaitCmdStatus(gspca_dev); 908 spca504B_WaitCmdStatus(gspca_dev);
893 break; 909 break;
894 case BRIDGE_SPCA504C: /* pccam600 */ 910 case BRIDGE_SPCA504C: /* pccam600 */
@@ -898,12 +914,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
898 spca504_wait_status(gspca_dev); 914 spca504_wait_status(gspca_dev);
899 if (sd->subtype == LogitechClickSmart420) 915 if (sd->subtype == LogitechClickSmart420)
900 write_vector(gspca_dev, 916 write_vector(gspca_dev,
901 spca504A_clicksmart420_open_data); 917 spca504A_clicksmart420_open_data,
918 ARRAY_SIZE(spca504A_clicksmart420_open_data));
902 else 919 else
903 write_vector(gspca_dev, spca504_pccam600_open_data); 920 write_vector(gspca_dev, spca504_pccam600_open_data,
921 ARRAY_SIZE(spca504_pccam600_open_data));
904 err_code = spca50x_setup_qtable(gspca_dev, 922 err_code = spca50x_setup_qtable(gspca_dev,
905 0x00, 0x2800, 923 qtable_creative_pccam);
906 0x2840, qtable_creative_pccam);
907 if (err_code < 0) { 924 if (err_code < 0) {
908 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed"); 925 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
909 return err_code; 926 return err_code;
@@ -941,8 +958,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
941 6, 0, 0x86, 1); */ 958 6, 0, 0x86, 1); */
942/* spca504A_acknowledged_command (gspca_dev, 0x24, 959/* spca504A_acknowledged_command (gspca_dev, 0x24,
943 0, 0, 0x9D, 1); */ 960 0, 0, 0x9D, 1); */
944 reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */ 961 reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */
945 reg_w_riv(dev, 0x0, 0x2310, 0x05); 962 reg_w_riv(dev, 0x00, 0x2310, 0x05);
946 spca504A_acknowledged_command(gspca_dev, 0x01, 963 spca504A_acknowledged_command(gspca_dev, 0x01,
947 0x0f, 0, 0xff, 0); 964 0x0f, 0, 0xff, 0);
948 } 965 }
@@ -950,8 +967,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
950 reg_w_riv(dev, 0, 0x2000, 0); 967 reg_w_riv(dev, 0, 0x2000, 0);
951 reg_w_riv(dev, 0, 0x2883, 1); 968 reg_w_riv(dev, 0, 0x2883, 1);
952 err_code = spca50x_setup_qtable(gspca_dev, 969 err_code = spca50x_setup_qtable(gspca_dev,
953 0x00, 0x2800,
954 0x2840,
955 qtable_spca504_default); 970 qtable_spca504_default);
956 if (err_code < 0) { 971 if (err_code < 0) {
957 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 972 PDEBUG(D_ERR, "spca50x_setup_qtable failed");
@@ -966,10 +981,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
966{ 981{
967 struct sd *sd = (struct sd *) gspca_dev; 982 struct sd *sd = (struct sd *) gspca_dev;
968 struct usb_device *dev = gspca_dev->dev; 983 struct usb_device *dev = gspca_dev->dev;
969 int rc;
970 int enable; 984 int enable;
971 __u8 i; 985 int i;
972 __u8 info[6]; 986 u8 info[6];
973 987
974 /* create the JPEG header */ 988 /* create the JPEG header */
975 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL); 989 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
@@ -987,16 +1001,20 @@ static int sd_start(struct gspca_dev *gspca_dev)
987/* case BRIDGE_SPCA504B: */ 1001/* case BRIDGE_SPCA504B: */
988/* case BRIDGE_SPCA533: */ 1002/* case BRIDGE_SPCA533: */
989/* case BRIDGE_SPCA536: */ 1003/* case BRIDGE_SPCA536: */
990 if (sd->subtype == MegapixV4 || 1004 switch (sd->subtype) {
991 sd->subtype == LogitechClickSmart820) { 1005 case MegapixV4:
992 reg_w(gspca_dev, 0xf0, 0, 0, 0); 1006 case LogitechClickSmart820:
1007 case MegaImageVI:
1008 reg_w_riv(dev, 0xf0, 0, 0);
993 spca504B_WaitCmdStatus(gspca_dev); 1009 spca504B_WaitCmdStatus(gspca_dev);
994 reg_r(gspca_dev, 0xf0, 4, 0); 1010 reg_r(gspca_dev, 0xf0, 4, 0);
995 spca504B_WaitCmdStatus(gspca_dev); 1011 spca504B_WaitCmdStatus(gspca_dev);
996 } else { 1012 break;
997 reg_w(gspca_dev, 0x31, 0, 4, 0); 1013 default:
1014 reg_w_riv(dev, 0x31, 0, 0x04);
998 spca504B_WaitCmdStatus(gspca_dev); 1015 spca504B_WaitCmdStatus(gspca_dev);
999 rc = spca504B_PollingDataReady(gspca_dev); 1016 spca504B_PollingDataReady(gspca_dev);
1017 break;
1000 } 1018 }
1001 break; 1019 break;
1002 case BRIDGE_SPCA504: 1020 case BRIDGE_SPCA504:
@@ -1030,15 +1048,17 @@ static int sd_start(struct gspca_dev *gspca_dev)
1030 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 1048 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1031 } 1049 }
1032 spca504B_SetSizeType(gspca_dev); 1050 spca504B_SetSizeType(gspca_dev);
1033 reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */ 1051 reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */
1034 reg_w_riv(dev, 0x0, 0x2310, 0x05); 1052 reg_w_riv(dev, 0x00, 0x2310, 0x05);
1035 break; 1053 break;
1036 case BRIDGE_SPCA504C: 1054 case BRIDGE_SPCA504C:
1037 if (sd->subtype == LogitechClickSmart420) { 1055 if (sd->subtype == LogitechClickSmart420) {
1038 write_vector(gspca_dev, 1056 write_vector(gspca_dev,
1039 spca504A_clicksmart420_init_data); 1057 spca504A_clicksmart420_init_data,
1058 ARRAY_SIZE(spca504A_clicksmart420_init_data));
1040 } else { 1059 } else {
1041 write_vector(gspca_dev, spca504_pccam600_init_data); 1060 write_vector(gspca_dev, spca504_pccam600_init_data,
1061 ARRAY_SIZE(spca504_pccam600_init_data));
1042 } 1062 }
1043 enable = (sd->autogain ? 0x04 : 0x01); 1063 enable = (sd->autogain ? 0x04 : 0x01);
1044 reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */ 1064 reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */
@@ -1050,7 +1070,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
1050 spca504B_SetSizeType(gspca_dev); 1070 spca504B_SetSizeType(gspca_dev);
1051 break; 1071 break;
1052 } 1072 }
1053 sp5xx_initContBrigHueRegisters(gspca_dev); 1073 init_ctl_reg(gspca_dev);
1054 return 0; 1074 return 0;
1055} 1075}
1056 1076
@@ -1064,7 +1084,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1064/* case BRIDGE_SPCA533: */ 1084/* case BRIDGE_SPCA533: */
1065/* case BRIDGE_SPCA536: */ 1085/* case BRIDGE_SPCA536: */
1066/* case BRIDGE_SPCA504B: */ 1086/* case BRIDGE_SPCA504B: */
1067 reg_w(gspca_dev, 0x31, 0, 0, 0); 1087 reg_w_riv(dev, 0x31, 0, 0);
1068 spca504B_WaitCmdStatus(gspca_dev); 1088 spca504B_WaitCmdStatus(gspca_dev);
1069 spca504B_PollingDataReady(gspca_dev); 1089 spca504B_PollingDataReady(gspca_dev);
1070 break; 1090 break;
@@ -1082,7 +1102,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1082 0x0f, 0x00, 0xff, 1); 1102 0x0f, 0x00, 0xff, 1);
1083 } else { 1103 } else {
1084 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 1104 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1085 reg_w_riv(dev, 0x01, 0x000f, 0x00); 1105 reg_w_riv(dev, 0x01, 0x000f, 0x0000);
1086 } 1106 }
1087 break; 1107 break;
1088 } 1108 }
@@ -1097,12 +1117,12 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
1097 1117
1098static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1118static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1099 struct gspca_frame *frame, /* target */ 1119 struct gspca_frame *frame, /* target */
1100 __u8 *data, /* isoc packet */ 1120 u8 *data, /* isoc packet */
1101 int len) /* iso packet length */ 1121 int len) /* iso packet length */
1102{ 1122{
1103 struct sd *sd = (struct sd *) gspca_dev; 1123 struct sd *sd = (struct sd *) gspca_dev;
1104 int i, sof = 0; 1124 int i, sof = 0;
1105 static unsigned char ffd9[] = {0xff, 0xd9}; 1125 static u8 ffd9[] = {0xff, 0xd9};
1106 1126
1107/* frames are jpeg 4.1.1 without 0xff escape */ 1127/* frames are jpeg 4.1.1 without 0xff escape */
1108 switch (sd->bridge) { 1128 switch (sd->bridge) {
@@ -1190,63 +1210,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1190 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 1210 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1191} 1211}
1192 1212
1193static void setbrightness(struct gspca_dev *gspca_dev)
1194{
1195 struct sd *sd = (struct sd *) gspca_dev;
1196 struct usb_device *dev = gspca_dev->dev;
1197
1198 switch (sd->bridge) {
1199 default:
1200/* case BRIDGE_SPCA533: */
1201/* case BRIDGE_SPCA504B: */
1202/* case BRIDGE_SPCA504: */
1203/* case BRIDGE_SPCA504C: */
1204 reg_w_riv(dev, 0x0, 0x21a7, sd->brightness);
1205 break;
1206 case BRIDGE_SPCA536:
1207 reg_w_riv(dev, 0x0, 0x20f0, sd->brightness);
1208 break;
1209 }
1210}
1211
1212static void setcontrast(struct gspca_dev *gspca_dev)
1213{
1214 struct sd *sd = (struct sd *) gspca_dev;
1215 struct usb_device *dev = gspca_dev->dev;
1216
1217 switch (sd->bridge) {
1218 default:
1219/* case BRIDGE_SPCA533: */
1220/* case BRIDGE_SPCA504B: */
1221/* case BRIDGE_SPCA504: */
1222/* case BRIDGE_SPCA504C: */
1223 reg_w_riv(dev, 0x0, 0x21a8, sd->contrast);
1224 break;
1225 case BRIDGE_SPCA536:
1226 reg_w_riv(dev, 0x0, 0x20f1, sd->contrast);
1227 break;
1228 }
1229}
1230
1231static void setcolors(struct gspca_dev *gspca_dev)
1232{
1233 struct sd *sd = (struct sd *) gspca_dev;
1234 struct usb_device *dev = gspca_dev->dev;
1235
1236 switch (sd->bridge) {
1237 default:
1238/* case BRIDGE_SPCA533: */
1239/* case BRIDGE_SPCA504B: */
1240/* case BRIDGE_SPCA504: */
1241/* case BRIDGE_SPCA504C: */
1242 reg_w_riv(dev, 0x0, 0x21ae, sd->colors);
1243 break;
1244 case BRIDGE_SPCA536:
1245 reg_w_riv(dev, 0x0, 0x20f6, sd->colors);
1246 break;
1247 }
1248}
1249
1250static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 1213static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1251{ 1214{
1252 struct sd *sd = (struct sd *) gspca_dev; 1215 struct sd *sd = (struct sd *) gspca_dev;
@@ -1384,6 +1347,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
1384 {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)}, 1347 {USB_DEVICE(0x04fc, 0x5360), BS(SPCA536, 0)},
1385 {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)}, 1348 {USB_DEVICE(0x04fc, 0xffff), BS(SPCA504B, 0)},
1386 {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)}, 1349 {USB_DEVICE(0x052b, 0x1513), BS(SPCA533, MegapixV4)},
1350 {USB_DEVICE(0x052b, 0x1803), BS(SPCA533, MegaImageVI)},
1387 {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)}, 1351 {USB_DEVICE(0x0546, 0x3155), BS(SPCA533, 0)},
1388 {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)}, 1352 {USB_DEVICE(0x0546, 0x3191), BS(SPCA504B, 0)},
1389 {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)}, 1353 {USB_DEVICE(0x0546, 0x3273), BS(SPCA504B, 0)},
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 404214b8cd2b..1d321c30d22f 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -264,6 +264,10 @@ static const struct v4l2_pix_format vga_mode_t16[] = {
264 264
265/* sensor specific data */ 265/* sensor specific data */
266struct additional_sensor_data { 266struct additional_sensor_data {
267 const u8 n3[6];
268 const u8 *n4, n4sz;
269 const u8 reg80, reg8e;
270 const u8 nset8[6];
267 const u8 data1[10]; 271 const u8 data1[10];
268 const u8 data2[9]; 272 const u8 data2[9];
269 const u8 data3[9]; 273 const u8 data3[9];
@@ -272,14 +276,55 @@ struct additional_sensor_data {
272 const u8 stream[4]; 276 const u8 stream[4];
273}; 277};
274 278
279static const u8 n4_om6802[] = {
280 0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c,
281 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68,
282 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1,
283 0xa2, 0x60, 0xa5, 0x30, 0xa6, 0x3a, 0xa8, 0xe8,
284 0xae, 0x05, 0xb1, 0x00, 0xbb, 0x04, 0xbc, 0x48,
285 0xbe, 0x36, 0xc6, 0x88, 0xe9, 0x00, 0xc5, 0xc0,
286 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68,
287 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40,
288 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46
289};
290static const u8 n4_other[] = {
291 0x66, 0x00, 0x7f, 0x00, 0x80, 0xac, 0x81, 0x69,
292 0x84, 0x40, 0x85, 0x70, 0x86, 0x20, 0x8a, 0x68,
293 0x8b, 0x58, 0x8c, 0x88, 0x8d, 0xff, 0x8e, 0xb8,
294 0x8f, 0x28, 0xa2, 0x60, 0xa5, 0x40, 0xa8, 0xa8,
295 0xac, 0x84, 0xad, 0x84, 0xae, 0x24, 0xaf, 0x56,
296 0xb0, 0x68, 0xb1, 0x00, 0xb2, 0x88, 0xbb, 0xc5,
297 0xbc, 0x4a, 0xbe, 0x36, 0xc2, 0x88, 0xc5, 0xc0,
298 0xc6, 0xda, 0xe9, 0x26, 0xeb, 0x00
299};
300static const u8 n4_tas5130a[] = {
301 0x80, 0x3c, 0x81, 0x68, 0x83, 0xa0, 0x84, 0x20,
302 0x8a, 0x68, 0x8b, 0x58, 0x8c, 0x88, 0x8e, 0xb4,
303 0x8f, 0x24, 0xa1, 0xb1, 0xa2, 0x30, 0xa5, 0x10,
304 0xa6, 0x4a, 0xae, 0x03, 0xb1, 0x44, 0xb2, 0x08,
305 0xb7, 0x06, 0xb9, 0xe7, 0xbb, 0xc4, 0xbc, 0x4a,
306 0xbe, 0x36, 0xbf, 0xff, 0xc2, 0x88, 0xc5, 0xc8,
307 0xc6, 0xda
308};
309
275static const struct additional_sensor_data sensor_data[] = { 310static const struct additional_sensor_data sensor_data[] = {
276 { /* OM6802 */ 311 { /* 0: OM6802 */
312 .n3 =
313 {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04},
314 .n4 = n4_om6802,
315 .n4sz = sizeof n4_om6802,
316 .reg80 = 0x3c,
317 .reg8e = 0x33,
318 .nset8 = {0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00},
277 .data1 = 319 .data1 =
278 {0xc2, 0x28, 0x0f, 0x22, 0xcd, 0x27, 0x2c, 0x06, 320 {0xc2, 0x28, 0x0f, 0x22, 0xcd, 0x27, 0x2c, 0x06,
279 0xb3, 0xfc}, 321 0xb3, 0xfc},
280 .data2 = 322 .data2 =
281 {0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 323 {0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff,
282 0xff}, 324 0xff},
325 .data3 =
326 {0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff,
327 0xff},
283 .data4 = /*Freq (50/60Hz). Splitted for test purpose */ 328 .data4 = /*Freq (50/60Hz). Splitted for test purpose */
284 {0x66, 0xca, 0xa8, 0xf0}, 329 {0x66, 0xca, 0xa8, 0xf0},
285 .data5 = /* this could be removed later */ 330 .data5 = /* this could be removed later */
@@ -287,13 +332,23 @@ static const struct additional_sensor_data sensor_data[] = {
287 .stream = 332 .stream =
288 {0x0b, 0x04, 0x0a, 0x78}, 333 {0x0b, 0x04, 0x0a, 0x78},
289 }, 334 },
290 { /* OTHER */ 335 { /* 1: OTHER */
336 .n3 =
337 {0x61, 0xc2, 0x65, 0x88, 0x60, 0x00},
338 .n4 = n4_other,
339 .n4sz = sizeof n4_other,
340 .reg80 = 0xac,
341 .reg8e = 0xb8,
342 .nset8 = {0xa8, 0xa8, 0xc6, 0xda, 0xc0, 0x00},
291 .data1 = 343 .data1 =
292 {0xc1, 0x48, 0x04, 0x1b, 0xca, 0x2e, 0x33, 0x3a, 344 {0xc1, 0x48, 0x04, 0x1b, 0xca, 0x2e, 0x33, 0x3a,
293 0xe8, 0xfc}, 345 0xe8, 0xfc},
294 .data2 = 346 .data2 =
295 {0x4e, 0x9c, 0xec, 0x40, 0x80, 0xc0, 0x48, 0x96, 347 {0x4e, 0x9c, 0xec, 0x40, 0x80, 0xc0, 0x48, 0x96,
296 0xd9}, 348 0xd9},
349 .data3 =
350 {0x4e, 0x9c, 0xec, 0x40, 0x80, 0xc0, 0x48, 0x96,
351 0xd9},
297 .data4 = 352 .data4 =
298 {0x66, 0x00, 0xa8, 0xa8}, 353 {0x66, 0x00, 0xa8, 0xa8},
299 .data5 = 354 .data5 =
@@ -301,13 +356,23 @@ static const struct additional_sensor_data sensor_data[] = {
301 .stream = 356 .stream =
302 {0x0b, 0x04, 0x0a, 0x00}, 357 {0x0b, 0x04, 0x0a, 0x00},
303 }, 358 },
304 { /* TAS5130A */ 359 { /* 2: TAS5130A */
360 .n3 =
361 {0x61, 0xc2, 0x65, 0x0d, 0x60, 0x08},
362 .n4 = n4_tas5130a,
363 .n4sz = sizeof n4_tas5130a,
364 .reg80 = 0x3c,
365 .reg8e = 0xb4,
366 .nset8 = {0xa8, 0xf0, 0xc6, 0xda, 0xc0, 0x00},
305 .data1 = 367 .data1 =
306 {0xbb, 0x28, 0x10, 0x10, 0xbb, 0x28, 0x1e, 0x27, 368 {0xbb, 0x28, 0x10, 0x10, 0xbb, 0x28, 0x1e, 0x27,
307 0xc8, 0xfc}, 369 0xc8, 0xfc},
308 .data2 = 370 .data2 =
309 {0x60, 0xa8, 0xe0, 0x60, 0xa8, 0xe0, 0x60, 0xa8, 371 {0x60, 0xa8, 0xe0, 0x60, 0xa8, 0xe0, 0x60, 0xa8,
310 0xe0}, 372 0xe0},
373 .data3 =
374 {0x60, 0xa8, 0xe0, 0x60, 0xa8, 0xe0, 0x60, 0xa8,
375 0xe0},
311 .data4 = /* Freq (50/60Hz). Splitted for test purpose */ 376 .data4 = /* Freq (50/60Hz). Splitted for test purpose */
312 {0x66, 0x00, 0xa8, 0xe8}, 377 {0x66, 0x00, 0xa8, 0xe8},
313 .data5 = 378 .data5 =
@@ -364,7 +429,7 @@ static const u8 gamma_table[GAMMA_MAX][17] = {
364 {0x00, 0x18, 0x2b, 0x44, 0x60, 0x70, 0x80, 0x8e, /* 10 */ 429 {0x00, 0x18, 0x2b, 0x44, 0x60, 0x70, 0x80, 0x8e, /* 10 */
365 0x9c, 0xaa, 0xb7, 0xc4, 0xd0, 0xd8, 0xe2, 0xf0, 430 0x9c, 0xaa, 0xb7, 0xc4, 0xd0, 0xd8, 0xe2, 0xf0,
366 0xff}, 431 0xff},
367 {0x00, 0x1a, 0x34, 0x52, 0x66, 0x7e, 0x8D, 0x9B, /* 11 */ 432 {0x00, 0x1a, 0x34, 0x52, 0x66, 0x7e, 0x8d, 0x9b, /* 11 */
368 0xa8, 0xb4, 0xc0, 0xcb, 0xd6, 0xe1, 0xeb, 0xf5, 433 0xa8, 0xb4, 0xc0, 0xcb, 0xd6, 0xe1, 0xeb, 0xf5,
369 0xff}, 434 0xff},
370 {0x00, 0x3f, 0x5a, 0x6e, 0x7f, 0x8e, 0x9c, 0xa8, /* 12 */ 435 {0x00, 0x3f, 0x5a, 0x6e, 0x7f, 0x8e, 0x9c, 0xa8, /* 12 */
@@ -385,8 +450,6 @@ static const u8 tas5130a_sensor_init[][8] = {
385 {0x62, 0x08, 0x63, 0x70, 0x64, 0x1d, 0x60, 0x09}, 450 {0x62, 0x08, 0x63, 0x70, 0x64, 0x1d, 0x60, 0x09},
386 {0x62, 0x20, 0x63, 0x01, 0x64, 0x02, 0x60, 0x09}, 451 {0x62, 0x20, 0x63, 0x01, 0x64, 0x02, 0x60, 0x09},
387 {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09}, 452 {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
388 {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09},
389 {},
390}; 453};
391 454
392static u8 sensor_reset[] = {0x61, 0x68, 0x62, 0xff, 0x60, 0x07}; 455static u8 sensor_reset[] = {0x61, 0x68, 0x62, 0xff, 0x60, 0x07};
@@ -633,10 +696,10 @@ static int sd_init(struct gspca_dev *gspca_dev)
633 * but wont hurt anyway, and can help someone with similar webcam 696 * but wont hurt anyway, and can help someone with similar webcam
634 * to see the initial parameters.*/ 697 * to see the initial parameters.*/
635 struct sd *sd = (struct sd *) gspca_dev; 698 struct sd *sd = (struct sd *) gspca_dev;
699 const struct additional_sensor_data *sensor;
636 int i; 700 int i;
637 u16 sensor_id; 701 u16 sensor_id;
638 u8 test_byte = 0; 702 u8 test_byte = 0;
639 u16 reg80, reg8e;
640 703
641 static const u8 read_indexs[] = 704 static const u8 read_indexs[] =
642 { 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5, 705 { 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5,
@@ -645,37 +708,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
645 {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; 708 {0x08, 0x03, 0x09, 0x03, 0x12, 0x04};
646 static const u8 n2[] = 709 static const u8 n2[] =
647 {0x08, 0x00}; 710 {0x08, 0x00};
648 static const u8 n3[6] =
649 {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04};
650 static const u8 n3_other[6] =
651 {0x61, 0xc2, 0x65, 0x88, 0x60, 0x00};
652 static const u8 n4[] =
653 {0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c,
654 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68,
655 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1,
656 0xa2, 0x60, 0xa5, 0x30, 0xa6, 0x3a, 0xa8, 0xe8,
657 0xae, 0x05, 0xb1, 0x00, 0xbb, 0x04, 0xbc, 0x48,
658 0xbe, 0x36, 0xc6, 0x88, 0xe9, 0x00, 0xc5, 0xc0,
659 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68,
660 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40,
661 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46};
662 static const u8 n4_other[] =
663 {0x66, 0x00, 0x7f, 0x00, 0x80, 0xac, 0x81, 0x69,
664 0x84, 0x40, 0x85, 0x70, 0x86, 0x20, 0x8a, 0x68,
665 0x8b, 0x58, 0x8c, 0x88, 0x8d, 0xff, 0x8e, 0xb8,
666 0x8f, 0x28, 0xa2, 0x60, 0xa5, 0x40, 0xa8, 0xa8,
667 0xac, 0x84, 0xad, 0x84, 0xae, 0x24, 0xaf, 0x56,
668 0xb0, 0x68, 0xb1, 0x00, 0xb2, 0x88, 0xbb, 0xc5,
669 0xbc, 0x4a, 0xbe, 0x36, 0xc2, 0x88, 0xc5, 0xc0,
670 0xc6, 0xda, 0xe9, 0x26, 0xeb, 0x00};
671 static const u8 nset8[6] =
672 { 0xa8, 0xf0, 0xc6, 0x88, 0xc0, 0x00 };
673 static const u8 nset8_other[6] =
674 { 0xa8, 0xa8, 0xc6, 0xda, 0xc0, 0x00 };
675 static const u8 nset9[4] =
676 { 0x0b, 0x04, 0x0a, 0x78 };
677 static const u8 nset9_other[4] =
678 { 0x0b, 0x04, 0x0a, 0x00 };
679 711
680 sensor_id = (reg_r(gspca_dev, 0x06) << 8) 712 sensor_id = (reg_r(gspca_dev, 0x06) << 8)
681 | reg_r(gspca_dev, 0x07); 713 | reg_r(gspca_dev, 0x07);
@@ -709,8 +741,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
709 } 741 }
710 if (i < 0) { 742 if (i < 0) {
711 err("Bad sensor reset %02x", test_byte); 743 err("Bad sensor reset %02x", test_byte);
712/* return -EIO; */ 744 return -EIO;
713/*fixme: test - continue */
714 } 745 }
715 reg_w_buf(gspca_dev, n2, sizeof n2); 746 reg_w_buf(gspca_dev, n2, sizeof n2);
716 } 747 }
@@ -723,31 +754,17 @@ static int sd_init(struct gspca_dev *gspca_dev)
723 i++; 754 i++;
724 } 755 }
725 756
726 if (sd->sensor != SENSOR_OTHER) { 757 sensor = &sensor_data[sd->sensor];
727 reg_w_buf(gspca_dev, n3, sizeof n3); 758 reg_w_buf(gspca_dev, sensor->n3, sizeof sensor->n3);
728 reg_w_buf(gspca_dev, n4, sizeof n4); 759 reg_w_buf(gspca_dev, sensor->n4, sensor->n4sz);
729 reg_r(gspca_dev, 0x0080);
730 reg_w(gspca_dev, 0x2c80);
731 reg80 = 0x3880;
732 reg8e = 0x338e;
733 } else {
734 reg_w_buf(gspca_dev, n3_other, sizeof n3_other);
735 reg_w_buf(gspca_dev, n4_other, sizeof n4_other);
736 sd->gamma = 5;
737 reg80 = 0xac80;
738 reg8e = 0xb88e;
739 }
740 760
741 reg_w_ixbuf(gspca_dev, 0xd0, sensor_data[sd->sensor].data1, 761 reg_w_ixbuf(gspca_dev, 0xd0, sensor->data1, sizeof sensor->data1);
742 sizeof sensor_data[sd->sensor].data1); 762 reg_w_ixbuf(gspca_dev, 0xc7, sensor->data2, sizeof sensor->data2);
743 reg_w_ixbuf(gspca_dev, 0xc7, sensor_data[sd->sensor].data2, 763 reg_w_ixbuf(gspca_dev, 0xe0, sensor->data3, sizeof sensor->data3);
744 sizeof sensor_data[sd->sensor].data2);
745 reg_w_ixbuf(gspca_dev, 0xe0, sensor_data[sd->sensor].data2,
746 sizeof sensor_data[sd->sensor].data2);
747 764
748 reg_w(gspca_dev, reg80); 765 reg_w(gspca_dev, (sensor->reg80 << 8) + 0x80);
749 reg_w(gspca_dev, reg80); 766 reg_w(gspca_dev, (sensor->reg80 << 8) + 0x80);
750 reg_w(gspca_dev, reg8e); 767 reg_w(gspca_dev, (sensor->reg8e << 8) + 0x8e);
751 768
752 setbrightness(gspca_dev); 769 setbrightness(gspca_dev);
753 setcontrast(gspca_dev); 770 setcontrast(gspca_dev);
@@ -760,25 +777,14 @@ static int sd_init(struct gspca_dev *gspca_dev)
760 reg_w(gspca_dev, 0x2088); 777 reg_w(gspca_dev, 0x2088);
761 reg_w(gspca_dev, 0x2089); 778 reg_w(gspca_dev, 0x2089);
762 779
763 reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, 780 reg_w_buf(gspca_dev, sensor->data4, sizeof sensor->data4);
764 sizeof sensor_data[sd->sensor].data4); 781 reg_w_buf(gspca_dev, sensor->data5, sizeof sensor->data5);
765 reg_w_buf(gspca_dev, sensor_data[sd->sensor].data5, 782 reg_w_buf(gspca_dev, sensor->nset8, sizeof sensor->nset8);
766 sizeof sensor_data[sd->sensor].data5); 783 reg_w_buf(gspca_dev, sensor->stream, sizeof sensor->stream);
767 if (sd->sensor != SENSOR_OTHER) {
768 reg_w_buf(gspca_dev, nset8, sizeof nset8);
769 reg_w_buf(gspca_dev, nset9, sizeof nset9);
770 reg_w(gspca_dev, 0x2880);
771 } else {
772 reg_w_buf(gspca_dev, nset8_other, sizeof nset8_other);
773 reg_w_buf(gspca_dev, nset9_other, sizeof nset9_other);
774 }
775 784
776 reg_w_ixbuf(gspca_dev, 0xd0, sensor_data[sd->sensor].data1, 785 reg_w_ixbuf(gspca_dev, 0xd0, sensor->data1, sizeof sensor->data1);
777 sizeof sensor_data[sd->sensor].data1); 786 reg_w_ixbuf(gspca_dev, 0xc7, sensor->data2, sizeof sensor->data2);
778 reg_w_ixbuf(gspca_dev, 0xc7, sensor_data[sd->sensor].data2, 787 reg_w_ixbuf(gspca_dev, 0xe0, sensor->data3, sizeof sensor->data3);
779 sizeof sensor_data[sd->sensor].data2);
780 reg_w_ixbuf(gspca_dev, 0xe0, sensor_data[sd->sensor].data2,
781 sizeof sensor_data[sd->sensor].data2);
782 788
783 return 0; 789 return 0;
784} 790}
@@ -828,7 +834,6 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
828 * i added some module parameters for test with some users */ 834 * i added some module parameters for test with some users */
829static void poll_sensor(struct gspca_dev *gspca_dev) 835static void poll_sensor(struct gspca_dev *gspca_dev)
830{ 836{
831 struct sd *sd = (struct sd *) gspca_dev;
832 static const u8 poll1[] = 837 static const u8 poll1[] =
833 {0x67, 0x05, 0x68, 0x81, 0x69, 0x80, 0x6a, 0x82, 838 {0x67, 0x05, 0x68, 0x81, 0x69, 0x80, 0x6a, 0x82,
834 0x6b, 0x68, 0x6c, 0x69, 0x72, 0xd9, 0x73, 0x34, 839 0x6b, 0x68, 0x6c, 0x69, 0x72, 0xd9, 0x73, 0x34,
@@ -844,24 +849,23 @@ static void poll_sensor(struct gspca_dev *gspca_dev)
844 0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c, 849 0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c,
845 0xc2, 0x80, 0xc3, 0x10}; 850 0xc2, 0x80, 0xc3, 0x10};
846 851
847 if (sd->sensor == SENSOR_OM6802) { 852 PDEBUG(D_STREAM, "[Sensor requires polling]");
848 PDEBUG(D_STREAM, "[Sensor requires polling]"); 853 reg_w_buf(gspca_dev, poll1, sizeof poll1);
849 reg_w_buf(gspca_dev, poll1, sizeof poll1); 854 reg_w_buf(gspca_dev, poll2, sizeof poll2);
850 reg_w_buf(gspca_dev, poll2, sizeof poll2); 855 reg_w_buf(gspca_dev, poll3, sizeof poll3);
851 reg_w_buf(gspca_dev, poll3, sizeof poll3); 856 reg_w_buf(gspca_dev, poll4, sizeof poll4);
852 reg_w_buf(gspca_dev, poll4, sizeof poll4);
853 }
854} 857}
855 858
856static int sd_start(struct gspca_dev *gspca_dev) 859static int sd_start(struct gspca_dev *gspca_dev)
857{ 860{
858 struct sd *sd = (struct sd *) gspca_dev; 861 struct sd *sd = (struct sd *) gspca_dev;
862 const struct additional_sensor_data *sensor;
859 int i, mode; 863 int i, mode;
860 u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; 864 u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 };
861 static const u8 t3[] = 865 static const u8 t3[] =
862 { 0x07, 0x00, 0x88, 0x02, 0x06, 0x00, 0xe7, 0x01 }; 866 { 0x07, 0x00, 0x88, 0x02, 0x06, 0x00, 0xe7, 0x01 };
863 867
864 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; 868 mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
865 switch (mode) { 869 switch (mode) {
866 case 0: /* 640x480 (0x00) */ 870 case 0: /* 640x480 (0x00) */
867 break; 871 break;
@@ -889,34 +893,33 @@ static int sd_start(struct gspca_dev *gspca_dev)
889 default: 893 default:
890/* case SENSOR_TAS5130A: */ 894/* case SENSOR_TAS5130A: */
891 i = 0; 895 i = 0;
892 while (tas5130a_sensor_init[i][0] != 0) { 896 for (;;) {
893 reg_w_buf(gspca_dev, tas5130a_sensor_init[i], 897 reg_w_buf(gspca_dev, tas5130a_sensor_init[i],
894 sizeof tas5130a_sensor_init[0]); 898 sizeof tas5130a_sensor_init[0]);
899 if (i >= ARRAY_SIZE(tas5130a_sensor_init) - 1)
900 break;
895 i++; 901 i++;
896 } 902 }
897 reg_w(gspca_dev, 0x3c80); 903 reg_w(gspca_dev, 0x3c80);
898 /* just in case and to keep sync with logs (for mine) */ 904 /* just in case and to keep sync with logs (for mine) */
899 reg_w_buf(gspca_dev, tas5130a_sensor_init[3], 905 reg_w_buf(gspca_dev, tas5130a_sensor_init[i],
900 sizeof tas5130a_sensor_init[0]); 906 sizeof tas5130a_sensor_init[0]);
901 reg_w(gspca_dev, 0x3c80); 907 reg_w(gspca_dev, 0x3c80);
902 break; 908 break;
903 } 909 }
904 reg_w_buf(gspca_dev, sensor_data[sd->sensor].data4, 910 sensor = &sensor_data[sd->sensor];
905 sizeof sensor_data[sd->sensor].data4); 911 reg_w_buf(gspca_dev, sensor->data4, sizeof sensor->data4);
906 reg_r(gspca_dev, 0x0012); 912 reg_r(gspca_dev, 0x0012);
907 reg_w_buf(gspca_dev, t2, sizeof t2); 913 reg_w_buf(gspca_dev, t2, sizeof t2);
908 reg_w_ixbuf(gspca_dev, 0xb3, t3, sizeof t3); 914 reg_w_ixbuf(gspca_dev, 0xb3, t3, sizeof t3);
909 reg_w(gspca_dev, 0x0013); 915 reg_w(gspca_dev, 0x0013);
910 msleep(15); 916 msleep(15);
911 reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, 917 reg_w_buf(gspca_dev, sensor->stream, sizeof sensor->stream);
912 sizeof sensor_data[sd->sensor].stream); 918 reg_w_buf(gspca_dev, sensor->stream, sizeof sensor->stream);
913 poll_sensor(gspca_dev); 919
920 if (sd->sensor == SENSOR_OM6802)
921 poll_sensor(gspca_dev);
914 922
915 /* restart on each start, just in case, sometimes regs goes wrong
916 * when using controls from app */
917 setbrightness(gspca_dev);
918 setcontrast(gspca_dev);
919 setcolors(gspca_dev);
920 return 0; 923 return 0;
921} 924}
922 925
@@ -926,10 +929,9 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
926 929
927 reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, 930 reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream,
928 sizeof sensor_data[sd->sensor].stream); 931 sizeof sensor_data[sd->sensor].stream);
929 msleep(20);
930 reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream, 932 reg_w_buf(gspca_dev, sensor_data[sd->sensor].stream,
931 sizeof sensor_data[sd->sensor].stream); 933 sizeof sensor_data[sd->sensor].stream);
932 if (sd->sensor != SENSOR_OTHER) { 934 if (sd->sensor == SENSOR_OM6802) {
933 msleep(20); 935 msleep(20);
934 reg_w(gspca_dev, 0x0309); 936 reg_w(gspca_dev, 0x0309);
935 } 937 }
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c
index 9f243d7e3110..4b44dde9f8b8 100644
--- a/drivers/media/video/gspca/tv8532.c
+++ b/drivers/media/video/gspca/tv8532.c
@@ -426,7 +426,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
426 gspca_frame_add(gspca_dev, packet_type0, 426 gspca_frame_add(gspca_dev, packet_type0,
427 frame, data + 2, gspca_dev->width); 427 frame, data + 2, gspca_dev->width);
428 gspca_frame_add(gspca_dev, packet_type1, 428 gspca_frame_add(gspca_dev, packet_type1,
429 frame, data + gspca_dev->width + 6, gspca_dev->width); 429 frame, data + gspca_dev->width + 5, gspca_dev->width);
430} 430}
431 431
432static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 432static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index 26dd155efcc3..619250e70718 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -32,14 +32,14 @@ MODULE_LICENSE("GPL");
32struct sd { 32struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */ 33 struct gspca_dev gspca_dev; /* !! must be the first item */
34 34
35 __u8 hflip; 35 u8 hflip;
36 __u8 vflip; 36 u8 vflip;
37 __u8 lightfreq; 37 u8 lightfreq;
38 __u8 sharpness; 38 u8 sharpness;
39 39
40 u8 image_offset; 40 u8 image_offset;
41 41
42 char bridge; 42 u8 bridge;
43#define BRIDGE_VC0321 0 43#define BRIDGE_VC0321 0
44#define BRIDGE_VC0323 1 44#define BRIDGE_VC0323 1
45 u8 sensor; 45 u8 sensor;
@@ -52,6 +52,10 @@ struct sd {
52#define SENSOR_OV7670 6 52#define SENSOR_OV7670 6
53#define SENSOR_PO1200 7 53#define SENSOR_PO1200 7
54#define SENSOR_PO3130NC 8 54#define SENSOR_PO3130NC 8
55 u8 flags;
56#define FL_SAMSUNG 0x01 /* SamsungQ1 (2 sensors) */
57#define FL_HFLIP 0x02 /* mirrored by default */
58#define FL_VFLIP 0x04 /* vertical flipped by default */
55}; 59};
56 60
57/* V4L2 controls supported by the driver */ 61/* V4L2 controls supported by the driver */
@@ -65,7 +69,7 @@ static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val);
65static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); 69static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val);
66 70
67static struct ctrl sd_ctrls[] = { 71static struct ctrl sd_ctrls[] = {
68/* next 2 controls work with ov7660 and ov7670 only */ 72/* next 2 controls work with some sensors only */
69#define HFLIP_IDX 0 73#define HFLIP_IDX 0
70 { 74 {
71 { 75 {
@@ -152,9 +156,9 @@ static const struct v4l2_pix_format vc0323_mode[] = {
152 .sizeimage = 640 * 480 * 3 / 8 + 590, 156 .sizeimage = 640 * 480 * 3 / 8 + 590,
153 .colorspace = V4L2_COLORSPACE_JPEG, 157 .colorspace = V4L2_COLORSPACE_JPEG,
154 .priv = 0}, 158 .priv = 0},
155 {1280, 1024, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, /* mi13x0_soc only */ 159 {1280, 960, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, /* mi1310_soc only */
156 .bytesperline = 1280, 160 .bytesperline = 1280,
157 .sizeimage = 1280 * 1024 * 1 / 4 + 590, 161 .sizeimage = 1280 * 960 * 3 / 8 + 590,
158 .colorspace = V4L2_COLORSPACE_JPEG, 162 .colorspace = V4L2_COLORSPACE_JPEG,
159 .priv = 2}, 163 .priv = 2},
160}; 164};
@@ -188,11 +192,11 @@ static const struct v4l2_pix_format svga_mode[] = {
188#define OV7660_MVFP_MIRROR 0x20 192#define OV7660_MVFP_MIRROR 0x20
189#define OV7660_MVFP_VFLIP 0x10 193#define OV7660_MVFP_VFLIP 0x10
190 194
191static const __u8 mi0360_matrix[9] = { 195static const u8 mi0360_matrix[9] = {
192 0x50, 0xf8, 0xf8, 0xf5, 0x50, 0xfb, 0xff, 0xf1, 0x50 196 0x50, 0xf8, 0xf8, 0xf5, 0x50, 0xfb, 0xff, 0xf1, 0x50
193}; 197};
194 198
195static const __u8 mi0360_initVGA_JPG[][4] = { 199static const u8 mi0360_initVGA_JPG[][4] = {
196 {0xb0, 0x03, 0x19, 0xcc}, 200 {0xb0, 0x03, 0x19, 0xcc},
197 {0xb0, 0x04, 0x02, 0xcc}, 201 {0xb0, 0x04, 0x02, 0xcc},
198 {0xb3, 0x00, 0x24, 0xcc}, 202 {0xb3, 0x00, 0x24, 0xcc},
@@ -301,7 +305,7 @@ static const __u8 mi0360_initVGA_JPG[][4] = {
301 {0xb3, 0x5c, 0x01, 0xcc}, 305 {0xb3, 0x5c, 0x01, 0xcc},
302 {} 306 {}
303}; 307};
304static const __u8 mi0360_initQVGA_JPG[][4] = { 308static const u8 mi0360_initQVGA_JPG[][4] = {
305 {0xb0, 0x03, 0x19, 0xcc}, 309 {0xb0, 0x03, 0x19, 0xcc},
306 {0xb0, 0x04, 0x02, 0xcc}, 310 {0xb0, 0x04, 0x02, 0xcc},
307 {0xb3, 0x00, 0x24, 0xcc}, 311 {0xb3, 0x00, 0x24, 0xcc},
@@ -421,211 +425,95 @@ static const __u8 mi0360_initQVGA_JPG[][4] = {
421 {} 425 {}
422}; 426};
423 427
424static const __u8 mi1310_socinitVGA_JPG[][4] = { 428static const u8 mi1310_socinitVGA_JPG[][4] = {
425 {0xb0, 0x03, 0x19, 0xcc}, 429 {0xb0, 0x03, 0x19, 0xcc},
426 {0xb0, 0x04, 0x02, 0xcc}, 430 {0xb0, 0x04, 0x02, 0xcc},
427 {0xb3, 0x00, 0x24, 0xcc}, 431 {0xb3, 0x00, 0x64, 0xcc},
428 {0xb3, 0x00, 0x25, 0xcc}, 432 {0xb3, 0x00, 0x65, 0xcc},
429 {0xb3, 0x05, 0x01, 0xcc}, 433 {0xb3, 0x05, 0x00, 0xcc},
430 {0xb3, 0x06, 0x03, 0xcc}, 434 {0xb3, 0x06, 0x00, 0xcc},
431 {0xb3, 0x5c, 0x01, 0xcc},
432 {0xb3, 0x08, 0x01, 0xcc}, 435 {0xb3, 0x08, 0x01, 0xcc},
433 {0xb3, 0x09, 0x0c, 0xcc}, 436 {0xb3, 0x09, 0x0c, 0xcc},
434 {0xb3, 0x34, 0x02, 0xcc}, 437 {0xb3, 0x34, 0x02, 0xcc},
435 {0xb3, 0x35, 0xdd, 0xcc}, 438 {0xb3, 0x35, 0xdd, 0xcc},
439 {0xb3, 0x02, 0x00, 0xcc},
436 {0xb3, 0x03, 0x0a, 0xcc}, 440 {0xb3, 0x03, 0x0a, 0xcc},
437 {0xb3, 0x04, 0x0d, 0xcc}, 441 {0xb3, 0x04, 0x05, 0xcc},
438 {0xb3, 0x20, 0x00, 0xcc}, 442 {0xb3, 0x20, 0x00, 0xcc},
439 {0xb3, 0x21, 0x00, 0xcc}, 443 {0xb3, 0x21, 0x00, 0xcc},
440 {0xb3, 0x22, 0x01, 0xcc}, 444 {0xb3, 0x22, 0x03, 0xcc},
441 {0xb3, 0x23, 0xe0, 0xcc}, 445 {0xb3, 0x23, 0xc0, 0xcc},
442 {0xb3, 0x14, 0x00, 0xcc}, 446 {0xb3, 0x14, 0x00, 0xcc},
443 {0xb3, 0x15, 0x00, 0xcc}, 447 {0xb3, 0x15, 0x00, 0xcc},
444 {0xb3, 0x16, 0x02, 0xcc}, 448 {0xb3, 0x16, 0x04, 0xcc},
445 {0xb3, 0x17, 0x7f, 0xcc}, 449 {0xb3, 0x17, 0xff, 0xcc},
446 {0xb8, 0x01, 0x7d, 0xcc}, 450 {0xb3, 0x00, 0x65, 0xcc},
447 {0xb8, 0x81, 0x09, 0xcc}, 451 {0xb8, 0x00, 0x00, 0xcc},
448 {0xb8, 0x27, 0x20, 0xcc}, 452 {0xbc, 0x00, 0xd0, 0xcc},
449 {0xb8, 0x26, 0x80, 0xcc}, 453 {0xbc, 0x01, 0x01, 0xcc},
450 {0xb3, 0x00, 0x25, 0xcc}, 454 {0xf0, 0x00, 0x02, 0xbb},
451 {0xb8, 0x00, 0x13, 0xcc}, 455 {0xc8, 0x9f, 0x0b, 0xbb},
452 {0xbc, 0x00, 0x71, 0xcc}, 456 {0x5b, 0x00, 0x01, 0xbb},
453 {0xb8, 0x81, 0x01, 0xcc}, 457 {0x2f, 0xde, 0x20, 0xbb},
454 {0xb8, 0x2c, 0x5a, 0xcc},
455 {0xb8, 0x2d, 0xff, 0xcc},
456 {0xb8, 0x2e, 0xee, 0xcc},
457 {0xb8, 0x2f, 0xfb, 0xcc},
458 {0xb8, 0x30, 0x52, 0xcc},
459 {0xb8, 0x31, 0xf8, 0xcc},
460 {0xb8, 0x32, 0xf1, 0xcc},
461 {0xb8, 0x33, 0xff, 0xcc},
462 {0xb8, 0x34, 0x54, 0xcc},
463 {0xb8, 0x35, 0x00, 0xcc},
464 {0xb8, 0x36, 0x00, 0xcc},
465 {0xb8, 0x37, 0x00, 0xcc},
466 {0xf0, 0x00, 0x00, 0xbb}, 458 {0xf0, 0x00, 0x00, 0xbb},
467 {0x00, 0x01, 0x00, 0xdd}, 459 {0x20, 0x03, 0x02, 0xbb}, /* h/v flip */
468 {0x0d, 0x00, 0x09, 0xbb},
469 {0x0d, 0x00, 0x08, 0xbb},
470 {0xf0, 0x00, 0x01, 0xbb}, 460 {0xf0, 0x00, 0x01, 0xbb},
471 {0x00, 0x01, 0x00, 0xdd}, 461 {0x05, 0x00, 0x07, 0xbb},
472 {0x06, 0x00, 0x14, 0xbb}, 462 {0x34, 0x00, 0x00, 0xbb},
473 {0x3a, 0x10, 0x00, 0xbb}, 463 {0x35, 0xff, 0x00, 0xbb},
474 {0x00, 0x00, 0x10, 0xdd}, 464 {0xdc, 0x07, 0x02, 0xbb},
475 {0x9b, 0x10, 0x00, 0xbb}, 465 {0xdd, 0x3c, 0x18, 0xbb},
476 {0x00, 0x00, 0x10, 0xdd}, 466 {0xde, 0x92, 0x6d, 0xbb},
467 {0xdf, 0xcd, 0xb1, 0xbb},
468 {0xe0, 0xff, 0xe7, 0xbb},
469 {0x06, 0xf0, 0x0d, 0xbb},
470 {0x06, 0x70, 0x0e, 0xbb},
471 {0x4c, 0x00, 0x01, 0xbb},
472 {0x4d, 0x00, 0x01, 0xbb},
473 {0xf0, 0x00, 0x02, 0xbb},
474 {0x2e, 0x0c, 0x55, 0xbb},
475 {0x21, 0xb6, 0x6e, 0xbb},
476 {0x36, 0x30, 0x10, 0xbb},
477 {0x37, 0x00, 0xc1, 0xbb},
477 {0xf0, 0x00, 0x00, 0xbb}, 478 {0xf0, 0x00, 0x00, 0xbb},
478 {0x00, 0x01, 0x00, 0xdd}, 479 {0x07, 0x00, 0x84, 0xbb},
479 {0x2b, 0x00, 0x28, 0xbb}, 480 {0x08, 0x02, 0x4a, 0xbb},
480 {0x2c, 0x00, 0x30, 0xbb}, 481 {0x05, 0x01, 0x10, 0xbb},
481 {0x2d, 0x00, 0x30, 0xbb}, 482 {0x06, 0x00, 0x39, 0xbb},
482 {0x2e, 0x00, 0x28, 0xbb}, 483 {0xf0, 0x00, 0x02, 0xbb},
483 {0x41, 0x00, 0xd7, 0xbb}, 484 {0x58, 0x02, 0x67, 0xbb},
484 {0x09, 0x02, 0x3a, 0xbb}, 485 {0x57, 0x02, 0x00, 0xbb},
485 {0x0c, 0x00, 0x00, 0xbb}, 486 {0x5a, 0x02, 0x67, 0xbb},
486 {0x20, 0x00, 0x00, 0xbb}, 487 {0x59, 0x02, 0x00, 0xbb},
487 {0x05, 0x00, 0x8c, 0xbb}, 488 {0x5c, 0x12, 0x0d, 0xbb},
488 {0x06, 0x00, 0x32, 0xbb}, 489 {0x5d, 0x16, 0x11, 0xbb},
489 {0x07, 0x00, 0xc6, 0xbb}, 490 {0x39, 0x06, 0x18, 0xbb},
490 {0x08, 0x00, 0x19, 0xbb}, 491 {0x3a, 0x06, 0x18, 0xbb},
491 {0x24, 0x80, 0x6f, 0xbb}, 492 {0x3b, 0x06, 0x18, 0xbb},
492 {0xc8, 0x00, 0x0f, 0xbb}, 493 {0x3c, 0x06, 0x18, 0xbb},
493 {0x20, 0x00, 0x0f, 0xbb}, 494 {0x64, 0x7b, 0x5b, 0xbb},
495 {0xf0, 0x00, 0x02, 0xbb},
496 {0x36, 0x30, 0x10, 0xbb},
497 {0x37, 0x00, 0xc0, 0xbb},
498 {0xbc, 0x0e, 0x00, 0xcc},
499 {0xbc, 0x0f, 0x05, 0xcc},
500 {0xbc, 0x10, 0xc0, 0xcc},
501 {0xbc, 0x11, 0x03, 0xcc},
494 {0xb6, 0x00, 0x00, 0xcc}, 502 {0xb6, 0x00, 0x00, 0xcc},
495 {0xb6, 0x03, 0x02, 0xcc}, 503 {0xb6, 0x03, 0x02, 0xcc},
496 {0xb6, 0x02, 0x80, 0xcc}, 504 {0xb6, 0x02, 0x80, 0xcc},
497 {0xb6, 0x05, 0x01, 0xcc}, 505 {0xb6, 0x05, 0x01, 0xcc},
498 {0xb6, 0x04, 0xe0, 0xcc}, 506 {0xb6, 0x04, 0xe0, 0xcc},
499 {0xb6, 0x12, 0x78, 0xcc}, 507 {0xb6, 0x12, 0xf8, 0xcc},
508 {0xb6, 0x13, 0x25, 0xcc},
500 {0xb6, 0x18, 0x02, 0xcc}, 509 {0xb6, 0x18, 0x02, 0xcc},
501 {0xb6, 0x17, 0x58, 0xcc}, 510 {0xb6, 0x17, 0x58, 0xcc},
502 {0xb6, 0x16, 0x00, 0xcc}, 511 {0xb6, 0x16, 0x00, 0xcc},
503 {0xb6, 0x22, 0x12, 0xcc}, 512 {0xb6, 0x22, 0x12, 0xcc},
504 {0xb6, 0x23, 0x0b, 0xcc}, 513 {0xb6, 0x23, 0x0b, 0xcc},
505 {0xb3, 0x02, 0x02, 0xcc},
506 {0xbf, 0xc0, 0x39, 0xcc},
507 {0xbf, 0xc1, 0x04, 0xcc},
508 {0xbf, 0xcc, 0x10, 0xcc},
509 {0xb9, 0x12, 0x00, 0xcc},
510 {0xb9, 0x13, 0x0a, 0xcc},
511 {0xb9, 0x14, 0x0a, 0xcc},
512 {0xb9, 0x15, 0x0a, 0xcc},
513 {0xb9, 0x16, 0x0a, 0xcc},
514 {0xb9, 0x18, 0x00, 0xcc},
515 {0xb9, 0x19, 0x0f, 0xcc},
516 {0xb9, 0x1a, 0x0f, 0xcc},
517 {0xb9, 0x1b, 0x0f, 0xcc},
518 {0xb9, 0x1c, 0x0f, 0xcc},
519 {0xb8, 0x8e, 0x00, 0xcc},
520 {0xb8, 0x8f, 0xff, 0xcc},
521 {0xb3, 0x01, 0x41, 0xcc},
522 {0x03, 0x03, 0xc0, 0xbb},
523 {0x06, 0x00, 0x10, 0xbb},
524 {0xb6, 0x12, 0xf8, 0xcc},
525 {0xb8, 0x0c, 0x20, 0xcc},
526 {0xb8, 0x0d, 0x70, 0xcc},
527 {0xb6, 0x13, 0x13, 0xcc},
528 {0x2f, 0x00, 0xC0, 0xbb},
529 {0xb8, 0xa0, 0x12, 0xcc},
530 {},
531};
532static const __u8 mi1310_socinitQVGA_JPG[][4] = {
533 {0xb0, 0x03, 0x19, 0xcc},
534 {0xb0, 0x04, 0x02, 0xcc},
535 {0xb3, 0x00, 0x24, 0xcc},
536 {0xb3, 0x00, 0x25, 0xcc},
537 {0xb3, 0x05, 0x01, 0xcc},
538 {0xb3, 0x06, 0x03, 0xcc},
539 {0xb3, 0x5c, 0x01, 0xcc},
540 {0xb3, 0x08, 0x01, 0xcc},
541 {0xb3, 0x09, 0x0c, 0xcc},
542 {0xb3, 0x34, 0x02, 0xcc},
543 {0xb3, 0x35, 0xdd, 0xcc},
544 {0xb3, 0x03, 0x0a, 0xcc},
545 {0xb3, 0x04, 0x0d, 0xcc},
546 {0xb3, 0x20, 0x00, 0xcc},
547 {0xb3, 0x21, 0x00, 0xcc},
548 {0xb3, 0x22, 0x01, 0xcc},
549 {0xb3, 0x23, 0xe0, 0xcc},
550 {0xb3, 0x14, 0x00, 0xcc},
551 {0xb3, 0x15, 0x00, 0xcc},
552 {0xb3, 0x16, 0x02, 0xcc},
553 {0xb3, 0x17, 0x7f, 0xcc},
554 {0xb8, 0x01, 0x7d, 0xcc},
555 {0xb8, 0x81, 0x09, 0xcc},
556 {0xb8, 0x27, 0x20, 0xcc},
557 {0xb8, 0x26, 0x80, 0xcc},
558 {0xb3, 0x00, 0x25, 0xcc},
559 {0xb8, 0x00, 0x13, 0xcc},
560 {0xbc, 0x00, 0xd1, 0xcc},
561 {0xb8, 0x81, 0x01, 0xcc},
562 {0xb8, 0x2c, 0x5a, 0xcc},
563 {0xb8, 0x2d, 0xff, 0xcc},
564 {0xb8, 0x2e, 0xee, 0xcc},
565 {0xb8, 0x2f, 0xfb, 0xcc},
566 {0xb8, 0x30, 0x52, 0xcc},
567 {0xb8, 0x31, 0xf8, 0xcc},
568 {0xb8, 0x32, 0xf1, 0xcc},
569 {0xb8, 0x33, 0xff, 0xcc},
570 {0xb8, 0x34, 0x54, 0xcc},
571 {0xb8, 0x35, 0x00, 0xcc},
572 {0xb8, 0x36, 0x00, 0xcc},
573 {0xb8, 0x37, 0x00, 0xcc},
574 {0xf0, 0x00, 0x00, 0xbb},
575 {0x00, 0x01, 0x00, 0xdd},
576 {0x0d, 0x00, 0x09, 0xbb},
577 {0x0d, 0x00, 0x08, 0xbb},
578 {0xf0, 0x00, 0x01, 0xbb},
579 {0x00, 0x01, 0x00, 0xdd},
580 {0x06, 0x00, 0x14, 0xbb},
581 {0x3a, 0x10, 0x00, 0xbb},
582 {0x00, 0x00, 0x10, 0xdd},
583 {0x9b, 0x10, 0x00, 0xbb},
584 {0x00, 0x00, 0x10, 0xdd},
585 {0xf0, 0x00, 0x00, 0xbb},
586 {0x00, 0x01, 0x00, 0xdd},
587 {0x2b, 0x00, 0x28, 0xbb},
588 {0x2c, 0x00, 0x30, 0xbb},
589 {0x2d, 0x00, 0x30, 0xbb},
590 {0x2e, 0x00, 0x28, 0xbb},
591 {0x41, 0x00, 0xd7, 0xbb},
592 {0x09, 0x02, 0x3a, 0xbb},
593 {0x0c, 0x00, 0x00, 0xbb},
594 {0x20, 0x00, 0x00, 0xbb},
595 {0x05, 0x00, 0x8c, 0xbb},
596 {0x06, 0x00, 0x32, 0xbb},
597 {0x07, 0x00, 0xc6, 0xbb},
598 {0x08, 0x00, 0x19, 0xbb},
599 {0x24, 0x80, 0x6f, 0xbb},
600 {0xc8, 0x00, 0x0f, 0xbb},
601 {0x20, 0x00, 0x0f, 0xbb},
602 {0xb6, 0x00, 0x00, 0xcc},
603 {0xb6, 0x03, 0x01, 0xcc},
604 {0xb6, 0x02, 0x40, 0xcc},
605 {0xb6, 0x05, 0x00, 0xcc},
606 {0xb6, 0x04, 0xf0, 0xcc},
607 {0xb6, 0x12, 0x78, 0xcc},
608 {0xb6, 0x18, 0x00, 0xcc},
609 {0xb6, 0x17, 0x96, 0xcc},
610 {0xb6, 0x16, 0x00, 0xcc},
611 {0xb6, 0x22, 0x12, 0xcc},
612 {0xb6, 0x23, 0x0b, 0xcc},
613 {0xb3, 0x02, 0x02, 0xcc},
614 {0xbf, 0xc0, 0x39, 0xcc}, 514 {0xbf, 0xc0, 0x39, 0xcc},
615 {0xbf, 0xc1, 0x04, 0xcc}, 515 {0xbf, 0xc1, 0x04, 0xcc},
616 {0xbf, 0xcc, 0x10, 0xcc}, 516 {0xbf, 0xcc, 0x00, 0xcc},
617 {0xb9, 0x12, 0x00, 0xcc},
618 {0xb9, 0x13, 0x0a, 0xcc},
619 {0xb9, 0x14, 0x0a, 0xcc},
620 {0xb9, 0x15, 0x0a, 0xcc},
621 {0xb9, 0x16, 0x0a, 0xcc},
622 {0xb9, 0x18, 0x00, 0xcc},
623 {0xb9, 0x19, 0x0f, 0xcc},
624 {0xb9, 0x1a, 0x0f, 0xcc},
625 {0xb9, 0x1b, 0x0f, 0xcc},
626 {0xb9, 0x1c, 0x0f, 0xcc},
627 {0xb8, 0x8e, 0x00, 0xcc},
628 {0xb8, 0x8f, 0xff, 0xcc},
629 {0xbc, 0x02, 0x18, 0xcc}, 517 {0xbc, 0x02, 0x18, 0xcc},
630 {0xbc, 0x03, 0x50, 0xcc}, 518 {0xbc, 0x03, 0x50, 0xcc},
631 {0xbc, 0x04, 0x18, 0xcc}, 519 {0xbc, 0x04, 0x18, 0xcc},
@@ -636,133 +524,335 @@ static const __u8 mi1310_socinitQVGA_JPG[][4] = {
636 {0xbc, 0x0a, 0x10, 0xcc}, 524 {0xbc, 0x0a, 0x10, 0xcc},
637 {0xbc, 0x0b, 0x00, 0xcc}, 525 {0xbc, 0x0b, 0x00, 0xcc},
638 {0xbc, 0x0c, 0x00, 0xcc}, 526 {0xbc, 0x0c, 0x00, 0xcc},
527 {0xb3, 0x5c, 0x01, 0xcc},
528 {0xf0, 0x00, 0x01, 0xbb},
529 {0x80, 0x00, 0x03, 0xbb},
530 {0x81, 0xc7, 0x14, 0xbb},
531 {0x82, 0xeb, 0xe8, 0xbb},
532 {0x83, 0xfe, 0xf4, 0xbb},
533 {0x84, 0xcd, 0x10, 0xbb},
534 {0x85, 0xf3, 0xee, 0xbb},
535 {0x86, 0xff, 0xf1, 0xbb},
536 {0x87, 0xcd, 0x10, 0xbb},
537 {0x88, 0xf3, 0xee, 0xbb},
538 {0x89, 0x01, 0xf1, 0xbb},
539 {0x8a, 0xe5, 0x17, 0xbb},
540 {0x8b, 0xe8, 0xe2, 0xbb},
541 {0x8c, 0xf7, 0xed, 0xbb},
542 {0x8d, 0x00, 0xff, 0xbb},
543 {0x8e, 0xec, 0x10, 0xbb},
544 {0x8f, 0xf0, 0xed, 0xbb},
545 {0x90, 0xf9, 0xf2, 0xbb},
546 {0x91, 0x00, 0x00, 0xbb},
547 {0x92, 0xe9, 0x0d, 0xbb},
548 {0x93, 0xf4, 0xf2, 0xbb},
549 {0x94, 0xfb, 0xf5, 0xbb},
550 {0x95, 0x00, 0xff, 0xbb},
551 {0xb6, 0x0f, 0x08, 0xbb},
552 {0xb7, 0x3d, 0x16, 0xbb},
553 {0xb8, 0x0c, 0x04, 0xbb},
554 {0xb9, 0x1c, 0x07, 0xbb},
555 {0xba, 0x0a, 0x03, 0xbb},
556 {0xbb, 0x1b, 0x09, 0xbb},
557 {0xbc, 0x17, 0x0d, 0xbb},
558 {0xbd, 0x23, 0x1d, 0xbb},
559 {0xbe, 0x00, 0x28, 0xbb},
560 {0xbf, 0x11, 0x09, 0xbb},
561 {0xc0, 0x16, 0x15, 0xbb},
562 {0xc1, 0x00, 0x1b, 0xbb},
563 {0xc2, 0x0e, 0x07, 0xbb},
564 {0xc3, 0x14, 0x10, 0xbb},
565 {0xc4, 0x00, 0x17, 0xbb},
566 {0x06, 0x74, 0x8e, 0xbb},
567 {0xf0, 0x00, 0x01, 0xbb},
568 {0x06, 0xf4, 0x8e, 0xbb},
569 {0x00, 0x00, 0x50, 0xdd},
570 {0x06, 0x74, 0x8e, 0xbb},
571 {0xf0, 0x00, 0x02, 0xbb},
572 {0x24, 0x50, 0x20, 0xbb},
573 {0xf0, 0x00, 0x02, 0xbb},
574 {0x34, 0x0c, 0x50, 0xbb},
639 {0xb3, 0x01, 0x41, 0xcc}, 575 {0xb3, 0x01, 0x41, 0xcc},
576 {0xf0, 0x00, 0x00, 0xbb},
577 {0x03, 0x03, 0xc0, 0xbb},
578 {},
579};
580static const u8 mi1310_socinitQVGA_JPG[][4] = {
581 {0xb0, 0x03, 0x19, 0xcc}, {0xb0, 0x04, 0x02, 0xcc},
582 {0xb3, 0x00, 0x64, 0xcc}, {0xb3, 0x00, 0x65, 0xcc},
583 {0xb3, 0x05, 0x00, 0xcc}, {0xb3, 0x06, 0x00, 0xcc},
584 {0xb3, 0x08, 0x01, 0xcc}, {0xb3, 0x09, 0x0c, 0xcc},
585 {0xb3, 0x34, 0x02, 0xcc}, {0xb3, 0x35, 0xdd, 0xcc},
586 {0xb3, 0x02, 0x00, 0xcc}, {0xb3, 0x03, 0x0a, 0xcc},
587 {0xb3, 0x04, 0x05, 0xcc}, {0xb3, 0x20, 0x00, 0xcc},
588 {0xb3, 0x21, 0x00, 0xcc}, {0xb3, 0x22, 0x03, 0xcc},
589 {0xb3, 0x23, 0xc0, 0xcc}, {0xb3, 0x14, 0x00, 0xcc},
590 {0xb3, 0x15, 0x00, 0xcc}, {0xb3, 0x16, 0x04, 0xcc},
591 {0xb3, 0x17, 0xff, 0xcc}, {0xb3, 0x00, 0x65, 0xcc},
592 {0xb8, 0x00, 0x00, 0xcc}, {0xbc, 0x00, 0xf0, 0xcc},
593 {0xbc, 0x01, 0x01, 0xcc}, {0xf0, 0x00, 0x02, 0xbb},
594 {0xc8, 0x9f, 0x0b, 0xbb}, {0x5b, 0x00, 0x01, 0xbb},
595 {0x2f, 0xde, 0x20, 0xbb}, {0xf0, 0x00, 0x00, 0xbb},
596 {0x20, 0x03, 0x02, 0xbb}, /* h/v flip */
597 {0xf0, 0x00, 0x01, 0xbb},
598 {0x05, 0x00, 0x07, 0xbb}, {0x34, 0x00, 0x00, 0xbb},
599 {0x35, 0xff, 0x00, 0xbb}, {0xdc, 0x07, 0x02, 0xbb},
600 {0xdd, 0x3c, 0x18, 0xbb}, {0xde, 0x92, 0x6d, 0xbb},
601 {0xdf, 0xcd, 0xb1, 0xbb}, {0xe0, 0xff, 0xe7, 0xbb},
602 {0x06, 0xf0, 0x0d, 0xbb}, {0x06, 0x70, 0x0e, 0xbb},
603 {0x4c, 0x00, 0x01, 0xbb}, {0x4d, 0x00, 0x01, 0xbb},
604 {0xf0, 0x00, 0x02, 0xbb}, {0x2e, 0x0c, 0x55, 0xbb},
605 {0x21, 0xb6, 0x6e, 0xbb}, {0x36, 0x30, 0x10, 0xbb},
606 {0x37, 0x00, 0xc1, 0xbb}, {0xf0, 0x00, 0x00, 0xbb},
607 {0x07, 0x00, 0x84, 0xbb}, {0x08, 0x02, 0x4a, 0xbb},
608 {0x05, 0x01, 0x10, 0xbb}, {0x06, 0x00, 0x39, 0xbb},
609 {0xf0, 0x00, 0x02, 0xbb}, {0x58, 0x02, 0x67, 0xbb},
610 {0x57, 0x02, 0x00, 0xbb}, {0x5a, 0x02, 0x67, 0xbb},
611 {0x59, 0x02, 0x00, 0xbb}, {0x5c, 0x12, 0x0d, 0xbb},
612 {0x5d, 0x16, 0x11, 0xbb}, {0x39, 0x06, 0x18, 0xbb},
613 {0x3a, 0x06, 0x18, 0xbb}, {0x3b, 0x06, 0x18, 0xbb},
614 {0x3c, 0x06, 0x18, 0xbb}, {0x64, 0x7b, 0x5b, 0xbb},
615 {0xf0, 0x00, 0x02, 0xbb}, {0x36, 0x30, 0x10, 0xbb},
616 {0x37, 0x00, 0xc0, 0xbb}, {0xbc, 0x0e, 0x00, 0xcc},
617 {0xbc, 0x0f, 0x05, 0xcc}, {0xbc, 0x10, 0xc0, 0xcc},
618 {0xbc, 0x11, 0x03, 0xcc}, {0xb6, 0x00, 0x00, 0xcc},
619 {0xb6, 0x03, 0x01, 0xcc}, {0xb6, 0x02, 0x40, 0xcc},
620 {0xb6, 0x05, 0x00, 0xcc}, {0xb6, 0x04, 0xf0, 0xcc},
621 {0xb6, 0x12, 0xf8, 0xcc}, {0xb6, 0x13, 0x25, 0xcc},
622 {0xb6, 0x18, 0x00, 0xcc}, {0xb6, 0x17, 0x96, 0xcc},
623 {0xb6, 0x16, 0x00, 0xcc}, {0xb6, 0x22, 0x12, 0xcc},
624 {0xb6, 0x23, 0x0b, 0xcc}, {0xbf, 0xc0, 0x39, 0xcc},
625 {0xbf, 0xc1, 0x04, 0xcc}, {0xbf, 0xcc, 0x00, 0xcc},
626 {0xb3, 0x5c, 0x01, 0xcc}, {0xf0, 0x00, 0x01, 0xbb},
627 {0x80, 0x00, 0x03, 0xbb}, {0x81, 0xc7, 0x14, 0xbb},
628 {0x82, 0xeb, 0xe8, 0xbb}, {0x83, 0xfe, 0xf4, 0xbb},
629 {0x84, 0xcd, 0x10, 0xbb}, {0x85, 0xf3, 0xee, 0xbb},
630 {0x86, 0xff, 0xf1, 0xbb}, {0x87, 0xcd, 0x10, 0xbb},
631 {0x88, 0xf3, 0xee, 0xbb}, {0x89, 0x01, 0xf1, 0xbb},
632 {0x8a, 0xe5, 0x17, 0xbb}, {0x8b, 0xe8, 0xe2, 0xbb},
633 {0x8c, 0xf7, 0xed, 0xbb}, {0x8d, 0x00, 0xff, 0xbb},
634 {0x8e, 0xec, 0x10, 0xbb}, {0x8f, 0xf0, 0xed, 0xbb},
635 {0x90, 0xf9, 0xf2, 0xbb}, {0x91, 0x00, 0x00, 0xbb},
636 {0x92, 0xe9, 0x0d, 0xbb}, {0x93, 0xf4, 0xf2, 0xbb},
637 {0x94, 0xfb, 0xf5, 0xbb}, {0x95, 0x00, 0xff, 0xbb},
638 {0xb6, 0x0f, 0x08, 0xbb}, {0xb7, 0x3d, 0x16, 0xbb},
639 {0xb8, 0x0c, 0x04, 0xbb}, {0xb9, 0x1c, 0x07, 0xbb},
640 {0xba, 0x0a, 0x03, 0xbb}, {0xbb, 0x1b, 0x09, 0xbb},
641 {0xbc, 0x17, 0x0d, 0xbb}, {0xbd, 0x23, 0x1d, 0xbb},
642 {0xbe, 0x00, 0x28, 0xbb}, {0xbf, 0x11, 0x09, 0xbb},
643 {0xc0, 0x16, 0x15, 0xbb}, {0xc1, 0x00, 0x1b, 0xbb},
644 {0xc2, 0x0e, 0x07, 0xbb}, {0xc3, 0x14, 0x10, 0xbb},
645 {0xc4, 0x00, 0x17, 0xbb}, {0x06, 0x74, 0x8e, 0xbb},
646 {0xf0, 0x00, 0x01, 0xbb}, {0x06, 0xf4, 0x8e, 0xbb},
647 {0x00, 0x00, 0x50, 0xdd}, {0x06, 0x74, 0x8e, 0xbb},
648 {0xf0, 0x00, 0x02, 0xbb}, {0x24, 0x50, 0x20, 0xbb},
649 {0xf0, 0x00, 0x02, 0xbb}, {0x34, 0x0c, 0x50, 0xbb},
650 {0xb3, 0x01, 0x41, 0xcc}, {0xf0, 0x00, 0x00, 0xbb},
640 {0x03, 0x03, 0xc0, 0xbb}, 651 {0x03, 0x03, 0xc0, 0xbb},
641 {0x06, 0x00, 0x10, 0xbb},
642 {0xb6, 0x12, 0xf8, 0xcc},
643 {0xb8, 0x0c, 0x20, 0xcc},
644 {0xb8, 0x0d, 0x70, 0xcc},
645 {0xb6, 0x13, 0x13, 0xcc},
646 {0x2f, 0x00, 0xC0, 0xbb},
647 {0xb8, 0xa0, 0x12, 0xcc},
648 {}, 652 {},
649}; 653};
650static const u8 mi1310_soc_InitSXGA_JPG[][4] = { 654static const u8 mi1310_soc_InitSXGA_JPG[][4] = {
651 {0xb0, 0x03, 0x19, 0xcc}, 655 {0xb0, 0x03, 0x19, 0xcc},
652 {0xb0, 0x04, 0x02, 0xcc}, 656 {0xb0, 0x04, 0x02, 0xcc},
653 {0xb3, 0x00, 0x24, 0xcc}, 657 {0xb3, 0x00, 0x64, 0xcc},
654 {0xb3, 0x00, 0x25, 0xcc}, 658 {0xb3, 0x00, 0x65, 0xcc},
655 {0xb3, 0x05, 0x00, 0xcc}, 659 {0xb3, 0x05, 0x00, 0xcc},
656 {0xb3, 0x06, 0x01, 0xcc}, 660 {0xb3, 0x06, 0x00, 0xcc},
657 {0xb3, 0x5c, 0x01, 0xcc},
658 {0xb3, 0x08, 0x01, 0xcc}, 661 {0xb3, 0x08, 0x01, 0xcc},
659 {0xb3, 0x09, 0x0c, 0xcc}, 662 {0xb3, 0x09, 0x0c, 0xcc},
660 {0xb3, 0x34, 0x02, 0xcc}, 663 {0xb3, 0x34, 0x02, 0xcc},
661 {0xb3, 0x35, 0xdd, 0xcc}, 664 {0xb3, 0x35, 0xdd, 0xcc},
665 {0xb3, 0x02, 0x00, 0xcc},
662 {0xb3, 0x03, 0x0a, 0xcc}, 666 {0xb3, 0x03, 0x0a, 0xcc},
663 {0xb3, 0x04, 0x0d, 0xcc}, 667 {0xb3, 0x04, 0x0d, 0xcc},
664 {0xb3, 0x20, 0x00, 0xcc}, 668 {0xb3, 0x20, 0x00, 0xcc},
665 {0xb3, 0x21, 0x00, 0xcc}, 669 {0xb3, 0x21, 0x00, 0xcc},
666 {0xb3, 0x22, 0x04, 0xcc}, 670 {0xb3, 0x22, 0x03, 0xcc},
667 {0xb3, 0x23, 0x00, 0xcc}, 671 {0xb3, 0x23, 0xc0, 0xcc},
668 {0xb3, 0x14, 0x00, 0xcc}, 672 {0xb3, 0x14, 0x00, 0xcc},
669 {0xb3, 0x15, 0x00, 0xcc}, 673 {0xb3, 0x15, 0x00, 0xcc},
670 {0xb3, 0x16, 0x04, 0xcc}, 674 {0xb3, 0x16, 0x04, 0xcc},
671 {0xb3, 0x17, 0xff, 0xcc}, 675 {0xb3, 0x17, 0xff, 0xcc},
672 {0xb8, 0x01, 0x7d, 0xcc}, 676 {0xb3, 0x00, 0x65, 0xcc},
673 {0xb8, 0x81, 0x09, 0xcc}, 677 {0xb8, 0x00, 0x00, 0xcc},
674 {0xb8, 0x27, 0x20, 0xcc}, 678 {0xbc, 0x00, 0x70, 0xcc},
675 {0xb8, 0x26, 0x80, 0xcc}, 679 {0xbc, 0x01, 0x01, 0xcc},
676 {0xb8, 0x06, 0x00, 0xcc}, 680 {0xf0, 0x00, 0x02, 0xbb},
677 {0xb8, 0x07, 0x05, 0xcc}, 681 {0xc8, 0x9f, 0x0b, 0xbb},
678 {0xb8, 0x08, 0x00, 0xcc}, 682 {0x5b, 0x00, 0x01, 0xbb},
679 {0xb8, 0x09, 0x04, 0xcc},
680 {0xb3, 0x00, 0x25, 0xcc},
681 {0xb8, 0x00, 0x11, 0xcc},
682 {0xbc, 0x00, 0x71, 0xcc},
683 {0xb8, 0x81, 0x01, 0xcc},
684 {0xb8, 0x2c, 0x5a, 0xcc},
685 {0xb8, 0x2d, 0xff, 0xcc},
686 {0xb8, 0x2e, 0xee, 0xcc},
687 {0xb8, 0x2f, 0xfb, 0xcc},
688 {0xb8, 0x30, 0x52, 0xcc},
689 {0xb8, 0x31, 0xf8, 0xcc},
690 {0xb8, 0x32, 0xf1, 0xcc},
691 {0xb8, 0x33, 0xff, 0xcc},
692 {0xb8, 0x34, 0x54, 0xcc},
693 {0xf0, 0x00, 0x00, 0xbb}, 683 {0xf0, 0x00, 0x00, 0xbb},
694 {0x00, 0x01, 0x00, 0xdd}, 684 {0x20, 0x03, 0x02, 0xbb}, /* h/v flip */
695 {0x0d, 0x00, 0x09, 0xbb},
696 {0x0d, 0x00, 0x08, 0xbb},
697 {0xf0, 0x00, 0x01, 0xbb}, 685 {0xf0, 0x00, 0x01, 0xbb},
698 {0x00, 0x01, 0x00, 0xdd}, 686 {0x05, 0x00, 0x07, 0xbb},
699 {0x06, 0x00, 0x14, 0xbb}, 687 {0x34, 0x00, 0x00, 0xbb},
700 {0x3a, 0x10, 0x00, 0xbb}, 688 {0x35, 0xff, 0x00, 0xbb},
701 {0x00, 0x00, 0x10, 0xdd}, 689 {0xdc, 0x07, 0x02, 0xbb},
702 {0x9b, 0x10, 0x00, 0xbb}, 690 {0xdd, 0x3c, 0x18, 0xbb},
703 {0x00, 0x00, 0x10, 0xdd}, 691 {0xde, 0x92, 0x6d, 0xbb},
692 {0xdf, 0xcd, 0xb1, 0xbb},
693 {0xe0, 0xff, 0xe7, 0xbb},
694 {0x06, 0xf0, 0x0d, 0xbb},
695 {0x06, 0x70, 0x0e, 0xbb},
696 {0x4c, 0x00, 0x01, 0xbb},
697 {0x4d, 0x00, 0x01, 0xbb},
698 {0xf0, 0x00, 0x02, 0xbb},
699 {0x2e, 0x0c, 0x60, 0xbb},
700 {0x21, 0xb6, 0x6e, 0xbb},
701 {0x37, 0x01, 0x40, 0xbb},
704 {0xf0, 0x00, 0x00, 0xbb}, 702 {0xf0, 0x00, 0x00, 0xbb},
705 {0x00, 0x01, 0x00, 0xdd}, 703 {0x07, 0x00, 0x84, 0xbb},
706 {0x2b, 0x00, 0x28, 0xbb}, 704 {0x08, 0x02, 0x4a, 0xbb},
707 {0x2c, 0x00, 0x30, 0xbb}, 705 {0x05, 0x01, 0x10, 0xbb},
708 {0x2d, 0x00, 0x30, 0xbb}, 706 {0x06, 0x00, 0x39, 0xbb},
709 {0x2e, 0x00, 0x28, 0xbb}, 707 {0xf0, 0x00, 0x02, 0xbb},
710 {0x41, 0x00, 0xd7, 0xbb}, 708 {0x58, 0x02, 0x67, 0xbb},
711 {0x09, 0x02, 0x3a, 0xbb}, 709 {0x57, 0x02, 0x00, 0xbb},
712 {0x0c, 0x00, 0x00, 0xbb}, 710 {0x5a, 0x02, 0x67, 0xbb},
713 {0x20, 0x00, 0x00, 0xbb}, 711 {0x59, 0x02, 0x00, 0xbb},
714 {0x05, 0x00, 0x8c, 0xbb}, 712 {0x5c, 0x12, 0x0d, 0xbb},
715 {0x06, 0x00, 0x32, 0xbb}, 713 {0x5d, 0x16, 0x11, 0xbb},
716 {0x07, 0x00, 0xc6, 0xbb}, 714 {0x39, 0x06, 0x18, 0xbb},
717 {0x08, 0x00, 0x19, 0xbb}, 715 {0x3a, 0x06, 0x18, 0xbb},
718 {0x24, 0x80, 0x6f, 0xbb}, 716 {0x3b, 0x06, 0x18, 0xbb},
719 {0xc8, 0x00, 0x0f, 0xbb}, 717 {0x3c, 0x06, 0x18, 0xbb},
720 {0x20, 0x00, 0x03, 0xbb}, 718 {0x64, 0x7b, 0x5b, 0xbb},
721 {0xb6, 0x00, 0x00, 0xcc}, 719 {0xb6, 0x00, 0x00, 0xcc},
722 {0xb6, 0x03, 0x05, 0xcc}, 720 {0xb6, 0x03, 0x05, 0xcc},
723 {0xb6, 0x02, 0x00, 0xcc}, 721 {0xb6, 0x02, 0x00, 0xcc},
724 {0xb6, 0x05, 0x04, 0xcc}, 722 {0xb6, 0x05, 0x03, 0xcc},
725 {0xb6, 0x04, 0x00, 0xcc}, 723 {0xb6, 0x04, 0xc0, 0xcc},
726 {0xb6, 0x12, 0xf8, 0xcc}, 724 {0xb6, 0x12, 0xf8, 0xcc},
727 {0xb6, 0x18, 0x0a, 0xcc}, 725 {0xb6, 0x13, 0x29, 0xcc},
728 {0xb6, 0x17, 0x00, 0xcc}, 726 {0xb6, 0x18, 0x09, 0xcc},
727 {0xb6, 0x17, 0x60, 0xcc},
729 {0xb6, 0x16, 0x00, 0xcc}, 728 {0xb6, 0x16, 0x00, 0xcc},
730 {0xb6, 0x22, 0x12, 0xcc}, 729 {0xb6, 0x22, 0x12, 0xcc},
731 {0xb6, 0x23, 0x0b, 0xcc}, 730 {0xb6, 0x23, 0x0b, 0xcc},
732 {0xb3, 0x02, 0x02, 0xcc},
733 {0xbf, 0xc0, 0x39, 0xcc}, 731 {0xbf, 0xc0, 0x39, 0xcc},
734 {0xbf, 0xc1, 0x04, 0xcc}, 732 {0xbf, 0xc1, 0x04, 0xcc},
735 {0xbf, 0xcc, 0x10, 0xcc}, 733 {0xbf, 0xcc, 0x00, 0xcc},
736 {0xb9, 0x12, 0x00, 0xcc},
737 {0xb9, 0x13, 0x14, 0xcc},
738 {0xb9, 0x14, 0x14, 0xcc},
739 {0xb9, 0x15, 0x14, 0xcc},
740 {0xb9, 0x16, 0x14, 0xcc},
741 {0xb9, 0x18, 0x00, 0xcc},
742 {0xb9, 0x19, 0x1e, 0xcc},
743 {0xb9, 0x1a, 0x1e, 0xcc},
744 {0xb9, 0x1b, 0x1e, 0xcc},
745 {0xb9, 0x1c, 0x1e, 0xcc},
746 {0xb3, 0x01, 0x41, 0xcc}, 734 {0xb3, 0x01, 0x41, 0xcc},
747 {0xb8, 0x8e, 0x00, 0xcc}, 735 {0x00, 0x00, 0x80, 0xdd},
748 {0xb8, 0x8f, 0xff, 0xcc}, 736 {0xf0, 0x00, 0x02, 0xbb},
749 {0xb6, 0x12, 0xf8, 0xcc}, 737 {0x00, 0x00, 0x10, 0xdd},
750 {0xb8, 0x0c, 0x20, 0xcc}, 738 {0x22, 0xa0, 0x78, 0xbb},
751 {0xb8, 0x0d, 0x70, 0xcc}, 739 {0x23, 0xa0, 0x78, 0xbb},
752 {0xb6, 0x13, 0x13, 0xcc}, 740 {0x24, 0x7f, 0x00, 0xbb},
753 {0x2f, 0x00, 0xC0, 0xbb}, 741 {0x28, 0xea, 0x02, 0xbb},
754 {0xb8, 0xa0, 0x12, 0xcc}, 742 {0x29, 0x86, 0x7a, 0xbb},
743 {0x5e, 0x52, 0x4c, 0xbb},
744 {0x5f, 0x20, 0x24, 0xbb},
745 {0x60, 0x00, 0x02, 0xbb},
746 {0x02, 0x00, 0xee, 0xbb},
747 {0x03, 0x39, 0x23, 0xbb},
748 {0x04, 0x07, 0x24, 0xbb},
749 {0x09, 0x00, 0xc0, 0xbb},
750 {0x0a, 0x00, 0x79, 0xbb},
751 {0x0b, 0x00, 0x04, 0xbb},
752 {0x0c, 0x00, 0x5c, 0xbb},
753 {0x0d, 0x00, 0xd9, 0xbb},
754 {0x0e, 0x00, 0x53, 0xbb},
755 {0x0f, 0x00, 0x21, 0xbb},
756 {0x10, 0x00, 0xa4, 0xbb},
757 {0x11, 0x00, 0xe5, 0xbb},
758 {0x15, 0x00, 0x00, 0xbb},
759 {0x16, 0x00, 0x00, 0xbb},
760 {0x17, 0x00, 0x00, 0xbb},
761 {0x18, 0x00, 0x00, 0xbb},
762 {0x19, 0x00, 0x00, 0xbb},
763 {0x1a, 0x00, 0x00, 0xbb},
764 {0x1b, 0x00, 0x00, 0xbb},
765 {0x1c, 0x00, 0x00, 0xbb},
766 {0x1d, 0x00, 0x00, 0xbb},
767 {0x1e, 0x00, 0x00, 0xbb},
768 {0xf0, 0x00, 0x01, 0xbb},
769 {0x00, 0x00, 0x20, 0xdd},
770 {0x06, 0xf0, 0x8e, 0xbb},
771 {0x00, 0x00, 0x80, 0xdd},
772 {0x06, 0x70, 0x8e, 0xbb},
773 {0xf0, 0x00, 0x02, 0xbb},
774 {0x00, 0x00, 0x20, 0xdd},
775 {0x5e, 0x6a, 0x53, 0xbb},
776 {0x5f, 0x40, 0x2c, 0xbb},
777 {0xf0, 0x00, 0x01, 0xbb},
778 {0x00, 0x00, 0x20, 0xdd},
779 {0x58, 0x00, 0x00, 0xbb},
780 {0x53, 0x09, 0x03, 0xbb},
781 {0x54, 0x31, 0x18, 0xbb},
782 {0x55, 0x8b, 0x5f, 0xbb},
783 {0x56, 0xc0, 0xa9, 0xbb},
784 {0x57, 0xe0, 0xd2, 0xbb},
785 {0xe1, 0x00, 0x00, 0xbb},
786 {0xdc, 0x09, 0x03, 0xbb},
787 {0xdd, 0x31, 0x18, 0xbb},
788 {0xde, 0x8b, 0x5f, 0xbb},
789 {0xdf, 0xc0, 0xa9, 0xbb},
790 {0xe0, 0xe0, 0xd2, 0xbb},
791 {0xb3, 0x5c, 0x01, 0xcc},
792 {0xf0, 0x00, 0x01, 0xbb},
793 {0x06, 0xf0, 0x8e, 0xbb},
794 {0xf0, 0x00, 0x02, 0xbb},
795 {0x2f, 0xde, 0x20, 0xbb},
796 {0xf0, 0x00, 0x02, 0xbb},
797 {0x24, 0x50, 0x20, 0xbb},
798 {0xbc, 0x0e, 0x00, 0xcc},
799 {0xbc, 0x0f, 0x05, 0xcc},
800 {0xbc, 0x10, 0xc0, 0xcc},
801 {0xf0, 0x00, 0x02, 0xbb},
802 {0x34, 0x0c, 0x50, 0xbb},
803 {0xbc, 0x11, 0x03, 0xcc},
804 {0xf0, 0x00, 0x01, 0xbb},
805 {0x80, 0x00, 0x03, 0xbb},
806 {0x81, 0xc7, 0x14, 0xbb},
807 {0x82, 0xeb, 0xe8, 0xbb},
808 {0x83, 0xfe, 0xf4, 0xbb},
809 {0x84, 0xcd, 0x10, 0xbb},
810 {0x85, 0xf3, 0xee, 0xbb},
811 {0x86, 0xff, 0xf1, 0xbb},
812 {0x87, 0xcd, 0x10, 0xbb},
813 {0x88, 0xf3, 0xee, 0xbb},
814 {0x89, 0x01, 0xf1, 0xbb},
815 {0x8a, 0xe5, 0x17, 0xbb},
816 {0x8b, 0xe8, 0xe2, 0xbb},
817 {0x8c, 0xf7, 0xed, 0xbb},
818 {0x8d, 0x00, 0xff, 0xbb},
819 {0x8e, 0xec, 0x10, 0xbb},
820 {0x8f, 0xf0, 0xed, 0xbb},
821 {0x90, 0xf9, 0xf2, 0xbb},
822 {0x91, 0x00, 0x00, 0xbb},
823 {0x92, 0xe9, 0x0d, 0xbb},
824 {0x93, 0xf4, 0xf2, 0xbb},
825 {0x94, 0xfb, 0xf5, 0xbb},
826 {0x95, 0x00, 0xff, 0xbb},
827 {0xb6, 0x0f, 0x08, 0xbb},
828 {0xb7, 0x3d, 0x16, 0xbb},
829 {0xb8, 0x0c, 0x04, 0xbb},
830 {0xb9, 0x1c, 0x07, 0xbb},
831 {0xba, 0x0a, 0x03, 0xbb},
832 {0xbb, 0x1b, 0x09, 0xbb},
833 {0xbc, 0x17, 0x0d, 0xbb},
834 {0xbd, 0x23, 0x1d, 0xbb},
835 {0xbe, 0x00, 0x28, 0xbb},
836 {0xbf, 0x11, 0x09, 0xbb},
837 {0xc0, 0x16, 0x15, 0xbb},
838 {0xc1, 0x00, 0x1b, 0xbb},
839 {0xc2, 0x0e, 0x07, 0xbb},
840 {0xc3, 0x14, 0x10, 0xbb},
841 {0xc4, 0x00, 0x17, 0xbb},
842 {0x06, 0x74, 0x8e, 0xbb},
843 {0xf0, 0x00, 0x00, 0xbb},
844 {0x03, 0x03, 0xc0, 0xbb},
755 {} 845 {}
756}; 846};
757 847
758static const __u8 mi1320_gamma[17] = { 848static const u8 mi1320_gamma[17] = {
759 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8, 849 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
760 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff 850 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
761}; 851};
762static const __u8 mi1320_matrix[9] = { 852static const u8 mi1320_matrix[9] = {
763 0x54, 0xda, 0x06, 0xf1, 0x50, 0xf4, 0xf7, 0xea, 0x52 853 0x54, 0xda, 0x06, 0xf1, 0x50, 0xf4, 0xf7, 0xea, 0x52
764}; 854};
765static const __u8 mi1320_initVGA_data[][4] = { 855static const u8 mi1320_initVGA_data[][4] = {
766 {0xb3, 0x01, 0x01, 0xcc}, {0x00, 0x00, 0x33, 0xdd}, 856 {0xb3, 0x01, 0x01, 0xcc}, {0x00, 0x00, 0x33, 0xdd},
767 {0xb0, 0x03, 0x19, 0xcc}, {0x00, 0x00, 0x33, 0xdd}, 857 {0xb0, 0x03, 0x19, 0xcc}, {0x00, 0x00, 0x33, 0xdd},
768 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x33, 0xdd}, 858 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x33, 0xdd},
@@ -841,7 +931,7 @@ static const __u8 mi1320_initVGA_data[][4] = {
841 {0xb3, 0x5c, 0x01, 0xcc}, {0xb3, 0x01, 0x41, 0xcc}, 931 {0xb3, 0x5c, 0x01, 0xcc}, {0xb3, 0x01, 0x41, 0xcc},
842 {} 932 {}
843}; 933};
844static const __u8 mi1320_initQVGA_data[][4] = { 934static const u8 mi1320_initQVGA_data[][4] = {
845 {0xb3, 0x01, 0x01, 0xcc}, {0x00, 0x00, 0x33, 0xdd}, 935 {0xb3, 0x01, 0x01, 0xcc}, {0x00, 0x00, 0x33, 0xdd},
846 {0xb0, 0x03, 0x19, 0xcc}, {0x00, 0x00, 0x33, 0xdd}, 936 {0xb0, 0x03, 0x19, 0xcc}, {0x00, 0x00, 0x33, 0xdd},
847 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x33, 0xdd}, 937 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x33, 0xdd},
@@ -948,7 +1038,7 @@ static const u8 mi1320_soc_InitVGA[][4] = {
948 {0x07, 0x00, 0xe0, 0xbb}, 1038 {0x07, 0x00, 0xe0, 0xbb},
949 {0x08, 0x00, 0x0b, 0xbb}, 1039 {0x08, 0x00, 0x0b, 0xbb},
950 {0x21, 0x00, 0x0c, 0xbb}, 1040 {0x21, 0x00, 0x0c, 0xbb},
951 {0x20, 0x01, 0x03, 0xbb}, 1041 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
952 {0xbf, 0xc0, 0x26, 0xcc}, 1042 {0xbf, 0xc0, 0x26, 0xcc},
953 {0xbf, 0xc1, 0x02, 0xcc}, 1043 {0xbf, 0xc1, 0x02, 0xcc},
954 {0xbf, 0xcc, 0x04, 0xcc}, 1044 {0xbf, 0xcc, 0x04, 0xcc},
@@ -958,7 +1048,7 @@ static const u8 mi1320_soc_InitVGA[][4] = {
958 {0x06, 0x00, 0x11, 0xbb}, 1048 {0x06, 0x00, 0x11, 0xbb},
959 {0x07, 0x01, 0x42, 0xbb}, 1049 {0x07, 0x01, 0x42, 0xbb},
960 {0x08, 0x00, 0x11, 0xbb}, 1050 {0x08, 0x00, 0x11, 0xbb},
961 {0x20, 0x01, 0x03, 0xbb}, 1051 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
962 {0x21, 0x80, 0x00, 0xbb}, 1052 {0x21, 0x80, 0x00, 0xbb},
963 {0x22, 0x0d, 0x0f, 0xbb}, 1053 {0x22, 0x0d, 0x0f, 0xbb},
964 {0x24, 0x80, 0x00, 0xbb}, 1054 {0x24, 0x80, 0x00, 0xbb},
@@ -1051,7 +1141,7 @@ static const u8 mi1320_soc_InitQVGA[][4] = {
1051 {0x07, 0x00, 0xe0, 0xbb}, 1141 {0x07, 0x00, 0xe0, 0xbb},
1052 {0x08, 0x00, 0x0b, 0xbb}, 1142 {0x08, 0x00, 0x0b, 0xbb},
1053 {0x21, 0x00, 0x0c, 0xbb}, 1143 {0x21, 0x00, 0x0c, 0xbb},
1054 {0x20, 0x01, 0x03, 0xbb}, 1144 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
1055 {0xbf, 0xc0, 0x26, 0xcc}, 1145 {0xbf, 0xc0, 0x26, 0xcc},
1056 {0xbf, 0xc1, 0x02, 0xcc}, 1146 {0xbf, 0xc1, 0x02, 0xcc},
1057 {0xbf, 0xcc, 0x04, 0xcc}, 1147 {0xbf, 0xcc, 0x04, 0xcc},
@@ -1071,7 +1161,7 @@ static const u8 mi1320_soc_InitQVGA[][4] = {
1071 {0x06, 0x00, 0x11, 0xbb}, 1161 {0x06, 0x00, 0x11, 0xbb},
1072 {0x07, 0x01, 0x42, 0xbb}, 1162 {0x07, 0x01, 0x42, 0xbb},
1073 {0x08, 0x00, 0x11, 0xbb}, 1163 {0x08, 0x00, 0x11, 0xbb},
1074 {0x20, 0x01, 0x03, 0xbb}, 1164 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
1075 {0x21, 0x80, 0x00, 0xbb}, 1165 {0x21, 0x80, 0x00, 0xbb},
1076 {0x22, 0x0d, 0x0f, 0xbb}, 1166 {0x22, 0x0d, 0x0f, 0xbb},
1077 {0x24, 0x80, 0x00, 0xbb}, 1167 {0x24, 0x80, 0x00, 0xbb},
@@ -1161,7 +1251,7 @@ static const u8 mi1320_soc_InitSXGA[][4] = {
1161 {0x00, 0x00, 0x20, 0xdd}, 1251 {0x00, 0x00, 0x20, 0xdd},
1162 {0xf0, 0x00, 0x00, 0xbb}, 1252 {0xf0, 0x00, 0x00, 0xbb},
1163 {0x00, 0x00, 0x30, 0xdd}, 1253 {0x00, 0x00, 0x30, 0xdd},
1164 {0x20, 0x01, 0x03, 0xbb}, 1254 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
1165 {0x00, 0x00, 0x20, 0xdd}, 1255 {0x00, 0x00, 0x20, 0xdd},
1166 {0xbf, 0xc0, 0x26, 0xcc}, 1256 {0xbf, 0xc0, 0x26, 0xcc},
1167 {0xbf, 0xc1, 0x02, 0xcc}, 1257 {0xbf, 0xc1, 0x02, 0xcc},
@@ -1172,7 +1262,7 @@ static const u8 mi1320_soc_InitSXGA[][4] = {
1172 {0x06, 0x00, 0x11, 0xbb}, 1262 {0x06, 0x00, 0x11, 0xbb},
1173 {0x07, 0x01, 0x42, 0xbb}, 1263 {0x07, 0x01, 0x42, 0xbb},
1174 {0x08, 0x00, 0x11, 0xbb}, 1264 {0x08, 0x00, 0x11, 0xbb},
1175 {0x20, 0x01, 0x03, 0xbb}, 1265 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
1176 {0x21, 0x80, 0x00, 0xbb}, 1266 {0x21, 0x80, 0x00, 0xbb},
1177 {0x22, 0x0d, 0x0f, 0xbb}, 1267 {0x22, 0x0d, 0x0f, 0xbb},
1178 {0x24, 0x80, 0x00, 0xbb}, 1268 {0x24, 0x80, 0x00, 0xbb},
@@ -1230,7 +1320,7 @@ static const u8 mi1320_soc_InitSXGA[][4] = {
1230 {0x06, 0x00, 0x11, 0xbb}, 1320 {0x06, 0x00, 0x11, 0xbb},
1231 {0x07, 0x00, 0x85, 0xbb}, 1321 {0x07, 0x00, 0x85, 0xbb},
1232 {0x08, 0x00, 0x27, 0xbb}, 1322 {0x08, 0x00, 0x27, 0xbb},
1233 {0x20, 0x01, 0x03, 0xbb}, 1323 {0x20, 0x01, 0x03, 0xbb}, /* h/v flip */
1234 {0x21, 0x80, 0x00, 0xbb}, 1324 {0x21, 0x80, 0x00, 0xbb},
1235 {0x22, 0x0d, 0x0f, 0xbb}, 1325 {0x22, 0x0d, 0x0f, 0xbb},
1236 {0x24, 0x80, 0x00, 0xbb}, 1326 {0x24, 0x80, 0x00, 0xbb},
@@ -1249,15 +1339,15 @@ static const u8 mi1320_soc_InitSXGA[][4] = {
1249 {0x64, 0x5e, 0x1c, 0xbb}, 1339 {0x64, 0x5e, 0x1c, 0xbb},
1250 {} 1340 {}
1251}; 1341};
1252static const __u8 po3130_gamma[17] = { 1342static const u8 po3130_gamma[17] = {
1253 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8, 1343 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
1254 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff 1344 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
1255}; 1345};
1256static const __u8 po3130_matrix[9] = { 1346static const u8 po3130_matrix[9] = {
1257 0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63 1347 0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63
1258}; 1348};
1259 1349
1260static const __u8 po3130_initVGA_data[][4] = { 1350static const u8 po3130_initVGA_data[][4] = {
1261 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc}, 1351 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc},
1262 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x01, 0xcc}, 1352 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x01, 0xcc},
1263 {0xb3, 0x00, 0x04, 0xcc}, {0xb3, 0x00, 0x24, 0xcc}, 1353 {0xb3, 0x00, 0x04, 0xcc}, {0xb3, 0x00, 0x24, 0xcc},
@@ -1340,7 +1430,7 @@ static const __u8 po3130_initVGA_data[][4] = {
1340 {0xb3, 0x5c, 0x00, 0xcc}, {0xb3, 0x01, 0x41, 0xcc}, 1430 {0xb3, 0x5c, 0x00, 0xcc}, {0xb3, 0x01, 0x41, 0xcc},
1341 {} 1431 {}
1342}; 1432};
1343static const __u8 po3130_rundata[][4] = { 1433static const u8 po3130_rundata[][4] = {
1344 {0x00, 0x47, 0x45, 0xaa}, {0x00, 0x48, 0x9b, 0xaa}, 1434 {0x00, 0x47, 0x45, 0xaa}, {0x00, 0x48, 0x9b, 0xaa},
1345 {0x00, 0x49, 0x3a, 0xaa}, {0x00, 0x4a, 0x01, 0xaa}, 1435 {0x00, 0x49, 0x3a, 0xaa}, {0x00, 0x4a, 0x01, 0xaa},
1346 {0x00, 0x44, 0x40, 0xaa}, 1436 {0x00, 0x44, 0x40, 0xaa},
@@ -1355,7 +1445,7 @@ static const __u8 po3130_rundata[][4] = {
1355 {} 1445 {}
1356}; 1446};
1357 1447
1358static const __u8 po3130_initQVGA_data[][4] = { 1448static const u8 po3130_initQVGA_data[][4] = {
1359 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc}, 1449 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc},
1360 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x09, 0xcc}, 1450 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x09, 0xcc},
1361 {0xb3, 0x00, 0x04, 0xcc}, {0xb3, 0x00, 0x24, 0xcc}, 1451 {0xb3, 0x00, 0x04, 0xcc}, {0xb3, 0x00, 0x24, 0xcc},
@@ -1441,121 +1531,207 @@ static const __u8 po3130_initQVGA_data[][4] = {
1441 {} 1531 {}
1442}; 1532};
1443 1533
1444static const __u8 hv7131r_gamma[17] = { 1534static const u8 hv7131r_gamma[17] = {
1445/* 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8, 1535 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
1446 * 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff */ 1536 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
1447 0x04, 0x1a, 0x36, 0x55, 0x6f, 0x87, 0x9d, 0xb0, 0xc1,
1448 0xcf, 0xda, 0xe4, 0xec, 0xf3, 0xf8, 0xfd, 0xff
1449}; 1537};
1450static const __u8 hv7131r_matrix[9] = { 1538static const u8 hv7131r_matrix[9] = {
1451 0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63 1539 0x5f, 0xec, 0xf5, 0xf1, 0x5a, 0xf5, 0xf1, 0xec, 0x63
1452}; 1540};
1453static const __u8 hv7131r_initVGA_data[][4] = { 1541static const u8 hv7131r_initVGA_data[][4] = {
1454 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc}, 1542 {0xb3, 0x01, 0x01, 0xcc},
1455 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x01, 0xcc}, 1543 {0xb0, 0x03, 0x19, 0xcc},
1544 {0xb0, 0x04, 0x02, 0xcc},
1545 {0x00, 0x00, 0x20, 0xdd},
1456 {0xb3, 0x00, 0x24, 0xcc}, 1546 {0xb3, 0x00, 0x24, 0xcc},
1457 {0xb3, 0x00, 0x25, 0xcc}, {0xb3, 0x08, 0x01, 0xcc}, 1547 {0xb3, 0x00, 0x25, 0xcc},
1458 {0xb3, 0x09, 0x0c, 0xcc}, {0xb3, 0x05, 0x00, 0xcc}, 1548 {0xb3, 0x08, 0x01, 0xcc},
1459 {0xb3, 0x06, 0x01, 0xcc}, 1549 {0xb3, 0x09, 0x0c, 0xcc},
1460 {0xb3, 0x01, 0x45, 0xcc}, {0xb3, 0x03, 0x0b, 0xcc}, 1550 {0xb3, 0x05, 0x01, 0xcc},
1461 {0xb3, 0x04, 0x05, 0xcc}, {0xb3, 0x20, 0x00, 0xcc}, 1551 {0xb3, 0x06, 0x03, 0xcc},
1552 {0xb3, 0x01, 0x45, 0xcc},
1553 {0xb3, 0x03, 0x0b, 0xcc},
1554 {0xb3, 0x04, 0x05, 0xcc},
1555 {0xb3, 0x20, 0x00, 0xcc},
1462 {0xb3, 0x21, 0x00, 0xcc}, 1556 {0xb3, 0x21, 0x00, 0xcc},
1463 {0xb3, 0x22, 0x01, 0xcc}, {0xb3, 0x23, 0xe0, 0xcc}, 1557 {0xb3, 0x22, 0x01, 0xcc},
1464 {0xb3, 0x14, 0x00, 0xcc}, {0xb3, 0x15, 0x00, 0xcc}, 1558 {0xb3, 0x23, 0xe0, 0xcc},
1559 {0xb3, 0x14, 0x00, 0xcc},
1560 {0xb3, 0x15, 0x02, 0xcc},
1465 {0xb3, 0x16, 0x02, 0xcc}, 1561 {0xb3, 0x16, 0x02, 0xcc},
1466 {0xb3, 0x17, 0x7f, 0xcc}, {0xb3, 0x34, 0x01, 0xcc}, 1562 {0xb3, 0x17, 0x7f, 0xcc},
1467 {0xb3, 0x35, 0x91, 0xcc}, {0xb3, 0x00, 0x27, 0xcc}, 1563 {0xb3, 0x34, 0x01, 0xcc},
1564 {0xb3, 0x35, 0x91, 0xcc},
1565 {0xb3, 0x00, 0x27, 0xcc},
1468 {0xbc, 0x00, 0x73, 0xcc}, 1566 {0xbc, 0x00, 0x73, 0xcc},
1469 {0xb8, 0x00, 0x23, 0xcc}, {0x00, 0x01, 0x0c, 0xaa}, 1567 {0xb8, 0x00, 0x23, 0xcc},
1470 {0x00, 0x14, 0x01, 0xaa}, {0x00, 0x15, 0xe6, 0xaa}, 1568 {0xb8, 0x2c, 0x50, 0xcc},
1471 {0x00, 0x16, 0x02, 0xaa}, 1569 {0xb8, 0x2d, 0xf8, 0xcc},
1472 {0x00, 0x17, 0x86, 0xaa}, {0x00, 0x23, 0x00, 0xaa}, 1570 {0xb8, 0x2e, 0xf8, 0xcc},
1473 {0x00, 0x25, 0x09, 0xaa}, {0x00, 0x26, 0x27, 0xaa}, 1571 {0xb8, 0x2f, 0xf8, 0xcc},
1474 {0x00, 0x27, 0xc0, 0xaa},
1475 {0xb8, 0x2c, 0x60, 0xcc}, {0xb8, 0x2d, 0xf8, 0xcc},
1476 {0xb8, 0x2e, 0xf8, 0xcc}, {0xb8, 0x2f, 0xf8, 0xcc},
1477 {0xb8, 0x30, 0x50, 0xcc}, 1572 {0xb8, 0x30, 0x50, 0xcc},
1478 {0xb8, 0x31, 0xf8, 0xcc}, {0xb8, 0x32, 0xf8, 0xcc}, 1573 {0xb8, 0x31, 0xf8, 0xcc},
1479 {0xb8, 0x33, 0xf8, 0xcc}, {0xb8, 0x34, 0x65, 0xcc}, 1574 {0xb8, 0x32, 0xf8, 0xcc},
1575 {0xb8, 0x33, 0xf8, 0xcc},
1576 {0xb8, 0x34, 0x58, 0xcc},
1480 {0xb8, 0x35, 0x00, 0xcc}, 1577 {0xb8, 0x35, 0x00, 0xcc},
1481 {0xb8, 0x36, 0x00, 0xcc}, {0xb8, 0x37, 0x00, 0xcc}, 1578 {0xb8, 0x36, 0x00, 0xcc},
1482 {0xb8, 0x27, 0x20, 0xcc}, {0xb8, 0x01, 0x7d, 0xcc}, 1579 {0xb8, 0x37, 0x00, 0xcc},
1580 {0xb8, 0x27, 0x20, 0xcc},
1581 {0xb8, 0x01, 0x7d, 0xcc},
1483 {0xb8, 0x81, 0x09, 0xcc}, 1582 {0xb8, 0x81, 0x09, 0xcc},
1484 {0xb3, 0x01, 0x41, 0xcc}, {0xb8, 0xfe, 0x00, 0xcc}, 1583 {0xb3, 0x01, 0x41, 0xcc},
1485 {0xb8, 0xff, 0x28, 0xcc}, {0xb9, 0x00, 0x28, 0xcc}, 1584 {0xb8, 0x8e, 0x00, 0xcc},
1486 {0xb9, 0x01, 0x28, 0xcc}, 1585 {0xb8, 0x8f, 0xff, 0xcc},
1487 {0xb9, 0x02, 0x28, 0xcc}, {0xb9, 0x03, 0x00, 0xcc}, 1586 {0x00, 0x01, 0x0c, 0xaa},
1488 {0xb9, 0x04, 0x00, 0xcc}, {0xb9, 0x05, 0x3c, 0xcc}, 1587 {0x00, 0x14, 0x01, 0xaa},
1489 {0xb9, 0x06, 0x3c, 0xcc}, 1588 {0x00, 0x15, 0xe6, 0xaa},
1490 {0xb9, 0x07, 0x3c, 0xcc}, {0xb9, 0x08, 0x3c, 0xcc}, 1589 {0x00, 0x16, 0x02, 0xaa},
1491 {0xb8, 0x8e, 0x00, 0xcc}, {0xb8, 0x8f, 0xff, 0xcc}, 1590 {0x00, 0x17, 0x86, 0xaa},
1591 {0x00, 0x23, 0x00, 0xaa},
1592 {0x00, 0x25, 0x03, 0xaa},
1593 {0x00, 0x26, 0xa9, 0xaa},
1594 {0x00, 0x27, 0x80, 0xaa},
1492 {0x00, 0x30, 0x18, 0xaa}, 1595 {0x00, 0x30, 0x18, 0xaa},
1596 {0xb6, 0x00, 0x00, 0xcc},
1597 {0xb6, 0x03, 0x02, 0xcc},
1598 {0xb6, 0x02, 0x80, 0xcc},
1599 {0xb6, 0x05, 0x01, 0xcc},
1600 {0xb6, 0x04, 0xe0, 0xcc},
1601 {0xb6, 0x12, 0x78, 0xcc},
1602 {0xb6, 0x18, 0x02, 0xcc},
1603 {0xb6, 0x17, 0x58, 0xcc},
1604 {0xb6, 0x16, 0x00, 0xcc},
1605 {0xb6, 0x22, 0x12, 0xcc},
1606 {0xb6, 0x23, 0x0b, 0xcc},
1607 {0xb3, 0x02, 0x02, 0xcc},
1608 {0xbf, 0xc0, 0x39, 0xcc},
1609 {0xbf, 0xc1, 0x04, 0xcc},
1610 {0xbf, 0xcc, 0x10, 0xcc},
1611 {0xb6, 0x12, 0xf8, 0xcc},
1612 {0xb6, 0x13, 0x13, 0xcc},
1613 {0xb9, 0x12, 0x00, 0xcc},
1614 {0xb9, 0x13, 0x0a, 0xcc},
1615 {0xb9, 0x14, 0x0a, 0xcc},
1616 {0xb9, 0x15, 0x0a, 0xcc},
1617 {0xb9, 0x16, 0x0a, 0xcc},
1618 {0xb8, 0x0c, 0x20, 0xcc},
1619 {0xb8, 0x0d, 0x70, 0xcc},
1620 {0xb9, 0x18, 0x00, 0xcc},
1621 {0xb9, 0x19, 0x0f, 0xcc},
1622 {0xb9, 0x1a, 0x0f, 0xcc},
1623 {0xb9, 0x1b, 0x0f, 0xcc},
1624 {0xb9, 0x1c, 0x0f, 0xcc},
1625 {0xb3, 0x5c, 0x01, 0xcc},
1493 {} 1626 {}
1494}; 1627};
1495 1628
1496static const __u8 hv7131r_initQVGA_data[][4] = { 1629static const u8 hv7131r_initQVGA_data[][4] = {
1497 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc}, 1630 {0xb3, 0x01, 0x01, 0xcc},
1498 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x01, 0xcc}, 1631 {0xb0, 0x03, 0x19, 0xcc},
1632 {0xb0, 0x04, 0x02, 0xcc},
1633 {0x00, 0x00, 0x20, 0xdd},
1499 {0xb3, 0x00, 0x24, 0xcc}, 1634 {0xb3, 0x00, 0x24, 0xcc},
1500 {0xb3, 0x00, 0x25, 0xcc}, {0xb3, 0x08, 0x01, 0xcc}, 1635 {0xb3, 0x00, 0x25, 0xcc},
1501 {0xb3, 0x09, 0x0c, 0xcc}, {0xb3, 0x05, 0x00, 0xcc}, 1636 {0xb3, 0x08, 0x01, 0xcc},
1502 {0xb3, 0x06, 0x01, 0xcc}, 1637 {0xb3, 0x09, 0x0c, 0xcc},
1503 {0xb3, 0x03, 0x0b, 0xcc}, {0xb3, 0x04, 0x05, 0xcc}, 1638 {0xb3, 0x05, 0x01, 0xcc},
1504 {0xb3, 0x20, 0x00, 0xcc}, {0xb3, 0x21, 0x00, 0xcc}, 1639 {0xb3, 0x06, 0x03, 0xcc},
1640 {0xb3, 0x01, 0x45, 0xcc},
1641 {0xb3, 0x03, 0x0b, 0xcc},
1642 {0xb3, 0x04, 0x05, 0xcc},
1643 {0xb3, 0x20, 0x00, 0xcc},
1644 {0xb3, 0x21, 0x00, 0xcc},
1505 {0xb3, 0x22, 0x01, 0xcc}, 1645 {0xb3, 0x22, 0x01, 0xcc},
1506 {0xb3, 0x23, 0xe0, 0xcc}, {0xb3, 0x14, 0x00, 0xcc}, 1646 {0xb3, 0x23, 0xe0, 0xcc},
1507 {0xb3, 0x15, 0x00, 0xcc}, {0xb3, 0x16, 0x02, 0xcc}, 1647 {0xb3, 0x14, 0x00, 0xcc},
1648 {0xb3, 0x15, 0x02, 0xcc},
1649 {0xb3, 0x16, 0x02, 0xcc},
1508 {0xb3, 0x17, 0x7f, 0xcc}, 1650 {0xb3, 0x17, 0x7f, 0xcc},
1509 {0xb3, 0x34, 0x01, 0xcc}, {0xb3, 0x35, 0x91, 0xcc}, 1651 {0xb3, 0x34, 0x01, 0xcc},
1510 {0xb3, 0x00, 0x27, 0xcc}, {0xbc, 0x00, 0xd1, 0xcc}, 1652 {0xb3, 0x35, 0x91, 0xcc},
1511 {0xb8, 0x00, 0x21, 0xcc}, 1653 {0xb3, 0x00, 0x27, 0xcc},
1512 {0x00, 0x01, 0x0c, 0xaa}, {0x00, 0x14, 0x01, 0xaa}, 1654 {0xbc, 0x00, 0xd3, 0xcc},
1513 {0x00, 0x15, 0xe6, 0xaa}, {0x00, 0x16, 0x02, 0xaa}, 1655 {0xb8, 0x00, 0x23, 0xcc},
1514 {0x00, 0x17, 0x86, 0xaa}, 1656 {0xb8, 0x2c, 0x50, 0xcc},
1515 {0x00, 0x23, 0x00, 0xaa}, {0x00, 0x25, 0x01, 0xaa}, 1657 {0xb8, 0x2d, 0xf8, 0xcc},
1516 {0x00, 0x26, 0xd4, 0xaa}, {0x00, 0x27, 0xc0, 0xaa}, 1658 {0xb8, 0x2e, 0xf8, 0xcc},
1517 {0xbc, 0x02, 0x08, 0xcc}, 1659 {0xb8, 0x2f, 0xf8, 0xcc},
1518 {0xbc, 0x03, 0x70, 0xcc}, {0xbc, 0x04, 0x08, 0xcc},
1519 {0xbc, 0x05, 0x00, 0xcc}, {0xbc, 0x06, 0x00, 0xcc},
1520 {0xbc, 0x08, 0x3c, 0xcc},
1521 {0xbc, 0x09, 0x40, 0xcc}, {0xbc, 0x0a, 0x04, 0xcc},
1522 {0xbc, 0x0b, 0x00, 0xcc}, {0xbc, 0x0c, 0x00, 0xcc},
1523 {0xb8, 0xfe, 0x02, 0xcc},
1524 {0xb8, 0xff, 0x07, 0xcc}, {0xb9, 0x00, 0x14, 0xcc},
1525 {0xb9, 0x01, 0x14, 0xcc}, {0xb9, 0x02, 0x14, 0xcc},
1526 {0xb9, 0x03, 0x00, 0xcc},
1527 {0xb9, 0x04, 0x02, 0xcc}, {0xb9, 0x05, 0x05, 0xcc},
1528 {0xb9, 0x06, 0x0f, 0xcc}, {0xb9, 0x07, 0x0f, 0xcc},
1529 {0xb9, 0x08, 0x0f, 0xcc},
1530 {0xb8, 0x2c, 0x60, 0xcc}, {0xb8, 0x2d, 0xf8, 0xcc},
1531 {0xb8, 0x2e, 0xf8, 0xcc}, {0xb8, 0x2f, 0xf8, 0xcc},
1532 {0xb8, 0x30, 0x50, 0xcc}, 1660 {0xb8, 0x30, 0x50, 0xcc},
1533 {0xb8, 0x31, 0xf8, 0xcc}, {0xb8, 0x32, 0xf8, 0xcc}, 1661 {0xb8, 0x31, 0xf8, 0xcc},
1662 {0xb8, 0x32, 0xf8, 0xcc},
1534 {0xb8, 0x33, 0xf8, 0xcc}, 1663 {0xb8, 0x33, 0xf8, 0xcc},
1535 {0xb8, 0x34, 0x65, 0xcc}, {0xb8, 0x35, 0x00, 0xcc}, 1664 {0xb8, 0x34, 0x58, 0xcc},
1536 {0xb8, 0x36, 0x00, 0xcc}, {0xb8, 0x37, 0x00, 0xcc}, 1665 {0xb8, 0x35, 0x00, 0xcc},
1666 {0xb8, 0x36, 0x00, 0xcc},
1667 {0xb8, 0x37, 0x00, 0xcc},
1537 {0xb8, 0x27, 0x20, 0xcc}, 1668 {0xb8, 0x27, 0x20, 0xcc},
1538 {0xb8, 0x01, 0x7d, 0xcc}, {0xb8, 0x81, 0x09, 0xcc}, 1669 {0xb8, 0x01, 0x7d, 0xcc},
1539 {0xb3, 0x01, 0x41, 0xcc}, {0xb8, 0xfe, 0x00, 0xcc}, 1670 {0xb8, 0x81, 0x09, 0xcc},
1540 {0xb8, 0xff, 0x28, 0xcc}, 1671 {0xb3, 0x01, 0x41, 0xcc},
1541 {0xb9, 0x00, 0x28, 0xcc}, {0xb9, 0x01, 0x28, 0xcc},
1542 {0xb9, 0x02, 0x28, 0xcc}, {0xb9, 0x03, 0x00, 0xcc},
1543 {0xb9, 0x04, 0x00, 0xcc},
1544 {0xb9, 0x05, 0x3c, 0xcc}, {0xb9, 0x06, 0x3c, 0xcc},
1545 {0xb9, 0x07, 0x3c, 0xcc}, {0xb9, 0x08, 0x3c, 0xcc},
1546 {0xb8, 0x8e, 0x00, 0xcc}, 1672 {0xb8, 0x8e, 0x00, 0xcc},
1547 {0xb8, 0x8f, 0xff, 0xcc}, {0x00, 0x30, 0x18, 0xaa}, 1673 {0xb8, 0x8f, 0xff, 0xcc},
1674 {0x00, 0x01, 0x0c, 0xaa},
1675 {0x00, 0x14, 0x01, 0xaa},
1676 {0x00, 0x15, 0xe6, 0xaa},
1677 {0x00, 0x16, 0x02, 0xaa},
1678 {0x00, 0x17, 0x86, 0xaa},
1679 {0x00, 0x23, 0x00, 0xaa},
1680 {0x00, 0x25, 0x03, 0xaa},
1681 {0x00, 0x26, 0xa9, 0xaa},
1682 {0x00, 0x27, 0x80, 0xaa},
1683 {0x00, 0x30, 0x18, 0xaa},
1684 {0xb6, 0x00, 0x00, 0xcc},
1685 {0xb6, 0x03, 0x01, 0xcc},
1686 {0xb6, 0x02, 0x40, 0xcc},
1687 {0xb6, 0x05, 0x00, 0xcc},
1688 {0xb6, 0x04, 0xf0, 0xcc},
1689 {0xb6, 0x12, 0x78, 0xcc},
1690 {0xb6, 0x18, 0x00, 0xcc},
1691 {0xb6, 0x17, 0x96, 0xcc},
1692 {0xb6, 0x16, 0x00, 0xcc},
1693 {0xb6, 0x22, 0x12, 0xcc},
1694 {0xb6, 0x23, 0x0b, 0xcc},
1695 {0xb3, 0x02, 0x02, 0xcc},
1696 {0xbf, 0xc0, 0x39, 0xcc},
1697 {0xbf, 0xc1, 0x04, 0xcc},
1698 {0xbf, 0xcc, 0x10, 0xcc},
1699 {0xbc, 0x02, 0x18, 0xcc},
1700 {0xbc, 0x03, 0x50, 0xcc},
1701 {0xbc, 0x04, 0x18, 0xcc},
1702 {0xbc, 0x05, 0x00, 0xcc},
1703 {0xbc, 0x06, 0x00, 0xcc},
1704 {0xbc, 0x08, 0x30, 0xcc},
1705 {0xbc, 0x09, 0x40, 0xcc},
1706 {0xbc, 0x0a, 0x10, 0xcc},
1707 {0xbc, 0x0b, 0x00, 0xcc},
1708 {0xbc, 0x0c, 0x00, 0xcc},
1709 {0xb9, 0x12, 0x00, 0xcc},
1710 {0xb9, 0x13, 0x0a, 0xcc},
1711 {0xb9, 0x14, 0x0a, 0xcc},
1712 {0xb9, 0x15, 0x0a, 0xcc},
1713 {0xb9, 0x16, 0x0a, 0xcc},
1714 {0xb9, 0x18, 0x00, 0xcc},
1715 {0xb9, 0x19, 0x0f, 0xcc},
1716 {0xb8, 0x0c, 0x20, 0xcc},
1717 {0xb8, 0x0d, 0x70, 0xcc},
1718 {0xb9, 0x1a, 0x0f, 0xcc},
1719 {0xb9, 0x1b, 0x0f, 0xcc},
1720 {0xb9, 0x1c, 0x0f, 0xcc},
1721 {0xb6, 0x12, 0xf8, 0xcc},
1722 {0xb6, 0x13, 0x13, 0xcc},
1723 {0xb3, 0x5c, 0x01, 0xcc},
1548 {} 1724 {}
1549}; 1725};
1550 1726
1551static const __u8 ov7660_gamma[17] = { 1727static const u8 ov7660_gamma[17] = {
1552 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8, 1728 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
1553 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff 1729 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
1554}; 1730};
1555static const __u8 ov7660_matrix[9] = { 1731static const u8 ov7660_matrix[9] = {
1556 0x5a, 0xf0, 0xf6, 0xf3, 0x57, 0xf6, 0xf3, 0xef, 0x62 1732 0x5a, 0xf0, 0xf6, 0xf3, 0x57, 0xf6, 0xf3, 0xef, 0x62
1557}; 1733};
1558static const __u8 ov7660_initVGA_data[][4] = { 1734static const u8 ov7660_initVGA_data[][4] = {
1559 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc}, 1735 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc},
1560 {0x00, 0x00, 0x50, 0xdd}, 1736 {0x00, 0x00, 0x50, 0xdd},
1561 {0xb0, 0x03, 0x01, 0xcc}, 1737 {0xb0, 0x03, 0x01, 0xcc},
@@ -1613,7 +1789,7 @@ static const __u8 ov7660_initVGA_data[][4] = {
1613 {0x00, 0x29, 0x3c, 0xaa}, {0xb3, 0x01, 0x45, 0xcc}, 1789 {0x00, 0x29, 0x3c, 0xaa}, {0xb3, 0x01, 0x45, 0xcc},
1614 {} 1790 {}
1615}; 1791};
1616static const __u8 ov7660_initQVGA_data[][4] = { 1792static const u8 ov7660_initQVGA_data[][4] = {
1617 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc}, 1793 {0xb0, 0x4d, 0x00, 0xcc}, {0xb3, 0x01, 0x01, 0xcc},
1618 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x01, 0xcc}, 1794 {0x00, 0x00, 0x50, 0xdd}, {0xb0, 0x03, 0x01, 0xcc},
1619 {0xb3, 0x00, 0x21, 0xcc}, {0xb3, 0x00, 0x26, 0xcc}, 1795 {0xb3, 0x00, 0x21, 0xcc}, {0xb3, 0x00, 0x26, 0xcc},
@@ -1682,26 +1858,26 @@ static const __u8 ov7660_initQVGA_data[][4] = {
1682 {} 1858 {}
1683}; 1859};
1684 1860
1685static const __u8 ov7660_50HZ[][4] = { 1861static const u8 ov7660_50HZ[][4] = {
1686 {0x00, 0x3b, 0x08, 0xaa}, 1862 {0x00, 0x3b, 0x08, 0xaa},
1687 {0x00, 0x9d, 0x40, 0xaa}, 1863 {0x00, 0x9d, 0x40, 0xaa},
1688 {0x00, 0x13, 0xa7, 0xaa}, 1864 {0x00, 0x13, 0xa7, 0xaa},
1689 {} 1865 {}
1690}; 1866};
1691 1867
1692static const __u8 ov7660_60HZ[][4] = { 1868static const u8 ov7660_60HZ[][4] = {
1693 {0x00, 0x3b, 0x00, 0xaa}, 1869 {0x00, 0x3b, 0x00, 0xaa},
1694 {0x00, 0x9e, 0x40, 0xaa}, 1870 {0x00, 0x9e, 0x40, 0xaa},
1695 {0x00, 0x13, 0xa7, 0xaa}, 1871 {0x00, 0x13, 0xa7, 0xaa},
1696 {} 1872 {}
1697}; 1873};
1698 1874
1699static const __u8 ov7660_NoFliker[][4] = { 1875static const u8 ov7660_NoFliker[][4] = {
1700 {0x00, 0x13, 0x87, 0xaa}, 1876 {0x00, 0x13, 0x87, 0xaa},
1701 {} 1877 {}
1702}; 1878};
1703 1879
1704static const __u8 ov7670_initVGA_JPG[][4] = { 1880static const u8 ov7670_initVGA_JPG[][4] = {
1705 {0xb3, 0x01, 0x05, 0xcc}, 1881 {0xb3, 0x01, 0x05, 0xcc},
1706 {0x00, 0x00, 0x30, 0xdd}, {0xb0, 0x03, 0x19, 0xcc}, 1882 {0x00, 0x00, 0x30, 0xdd}, {0xb0, 0x03, 0x19, 0xcc},
1707 {0x00, 0x00, 0x10, 0xdd}, 1883 {0x00, 0x00, 0x10, 0xdd},
@@ -1831,7 +2007,7 @@ static const __u8 ov7670_initVGA_JPG[][4] = {
1831 {}, 2007 {},
1832}; 2008};
1833 2009
1834static const __u8 ov7670_initQVGA_JPG[][4] = { 2010static const u8 ov7670_initQVGA_JPG[][4] = {
1835 {0xb3, 0x01, 0x05, 0xcc}, {0x00, 0x00, 0x30, 0xdd}, 2011 {0xb3, 0x01, 0x05, 0xcc}, {0x00, 0x00, 0x30, 0xdd},
1836 {0xb0, 0x03, 0x19, 0xcc}, {0x00, 0x00, 0x10, 0xdd}, 2012 {0xb0, 0x03, 0x19, 0xcc}, {0x00, 0x00, 0x10, 0xdd},
1837 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x10, 0xdd}, 2013 {0xb0, 0x04, 0x02, 0xcc}, {0x00, 0x00, 0x10, 0xdd},
@@ -1966,14 +2142,14 @@ static const __u8 ov7670_initQVGA_JPG[][4] = {
1966}; 2142};
1967 2143
1968/* PO1200 - values from usbvm326.inf and ms-win trace */ 2144/* PO1200 - values from usbvm326.inf and ms-win trace */
1969static const __u8 po1200_gamma[17] = { 2145static const u8 po1200_gamma[17] = {
1970 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8, 2146 0x00, 0x13, 0x38, 0x59, 0x79, 0x92, 0xa7, 0xb9, 0xc8,
1971 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff 2147 0xd4, 0xdf, 0xe7, 0xee, 0xf4, 0xf9, 0xfc, 0xff
1972}; 2148};
1973static const __u8 po1200_matrix[9] = { 2149static const u8 po1200_matrix[9] = {
1974 0x60, 0xf9, 0xe5, 0xe7, 0x50, 0x05, 0xf3, 0xe6, 0x5e 2150 0x60, 0xf9, 0xe5, 0xe7, 0x50, 0x05, 0xf3, 0xe6, 0x5e
1975}; 2151};
1976static const __u8 po1200_initVGA_data[][4] = { 2152static const u8 po1200_initVGA_data[][4] = {
1977 {0xb0, 0x03, 0x19, 0xcc}, /* reset? */ 2153 {0xb0, 0x03, 0x19, 0xcc}, /* reset? */
1978 {0xb0, 0x03, 0x19, 0xcc}, 2154 {0xb0, 0x03, 0x19, 0xcc},
1979/* {0x00, 0x00, 0x33, 0xdd}, */ 2155/* {0x00, 0x00, 0x33, 0xdd}, */
@@ -2276,9 +2452,9 @@ static const struct sensor_info sensor_info_data[] = {
2276 2452
2277/* read 'len' bytes in gspca_dev->usb_buf */ 2453/* read 'len' bytes in gspca_dev->usb_buf */
2278static void reg_r(struct gspca_dev *gspca_dev, 2454static void reg_r(struct gspca_dev *gspca_dev,
2279 __u16 req, 2455 u16 req,
2280 __u16 index, 2456 u16 index,
2281 __u16 len) 2457 u16 len)
2282{ 2458{
2283 usb_control_msg(gspca_dev->dev, 2459 usb_control_msg(gspca_dev->dev,
2284 usb_rcvctrlpipe(gspca_dev->dev, 0), 2460 usb_rcvctrlpipe(gspca_dev->dev, 0),
@@ -2290,9 +2466,9 @@ static void reg_r(struct gspca_dev *gspca_dev,
2290} 2466}
2291 2467
2292static void reg_w(struct usb_device *dev, 2468static void reg_w(struct usb_device *dev,
2293 __u16 req, 2469 u16 req,
2294 __u16 value, 2470 u16 value,
2295 __u16 index) 2471 u16 index)
2296{ 2472{
2297 usb_control_msg(dev, 2473 usb_control_msg(dev,
2298 usb_sndctrlpipe(dev, 0), 2474 usb_sndctrlpipe(dev, 0),
@@ -2342,11 +2518,18 @@ static u16 read_sensor_register(struct gspca_dev *gspca_dev,
2342 2518
2343static int vc032x_probe_sensor(struct gspca_dev *gspca_dev) 2519static int vc032x_probe_sensor(struct gspca_dev *gspca_dev)
2344{ 2520{
2521 struct sd *sd = (struct sd *) gspca_dev;
2345 struct usb_device *dev = gspca_dev->dev; 2522 struct usb_device *dev = gspca_dev->dev;
2346 int i; 2523 int i;
2347 u16 value; 2524 u16 value;
2348 const struct sensor_info *ptsensor_info; 2525 const struct sensor_info *ptsensor_info;
2349 2526
2527/*fixme: should also check the other sensor (back mi1320_soc, front mc501cb)*/
2528 if (sd->flags & FL_SAMSUNG) {
2529 reg_w(dev, 0xa0, 0x01, 0xb301);
2530 reg_w(dev, 0x89, 0xf0ff, 0xffff); /* select the back sensor */
2531 }
2532
2350 reg_r(gspca_dev, 0xa1, 0xbfcf, 1); 2533 reg_r(gspca_dev, 0xa1, 0xbfcf, 1);
2351 PDEBUG(D_PROBE, "check sensor header %02x", gspca_dev->usb_buf[0]); 2534 PDEBUG(D_PROBE, "check sensor header %02x", gspca_dev->usb_buf[0]);
2352 for (i = 0; i < ARRAY_SIZE(sensor_info_data); i++) { 2535 for (i = 0; i < ARRAY_SIZE(sensor_info_data); i++) {
@@ -2406,17 +2589,17 @@ static void i2c_write(struct gspca_dev *gspca_dev,
2406} 2589}
2407 2590
2408static void put_tab_to_reg(struct gspca_dev *gspca_dev, 2591static void put_tab_to_reg(struct gspca_dev *gspca_dev,
2409 const __u8 *tab, __u8 tabsize, __u16 addr) 2592 const u8 *tab, u8 tabsize, u16 addr)
2410{ 2593{
2411 int j; 2594 int j;
2412 __u16 ad = addr; 2595 u16 ad = addr;
2413 2596
2414 for (j = 0; j < tabsize; j++) 2597 for (j = 0; j < tabsize; j++)
2415 reg_w(gspca_dev->dev, 0xa0, tab[j], ad++); 2598 reg_w(gspca_dev->dev, 0xa0, tab[j], ad++);
2416} 2599}
2417 2600
2418static void usb_exchange(struct gspca_dev *gspca_dev, 2601static void usb_exchange(struct gspca_dev *gspca_dev,
2419 const __u8 data[][4]) 2602 const u8 data[][4])
2420{ 2603{
2421 struct usb_device *dev = gspca_dev->dev; 2604 struct usb_device *dev = gspca_dev->dev;
2422 int i = 0; 2605 int i = 0;
@@ -2466,7 +2649,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
2466 }; 2649 };
2467 2650
2468 cam = &gspca_dev->cam; 2651 cam = &gspca_dev->cam;
2469 sd->bridge = id->driver_info; 2652 sd->bridge = id->driver_info >> 8;
2653 sd->flags = id->driver_info & 0xff;
2470 sensor = vc032x_probe_sensor(gspca_dev); 2654 sensor = vc032x_probe_sensor(gspca_dev);
2471 switch (sensor) { 2655 switch (sensor) {
2472 case -1: 2656 case -1:
@@ -2519,8 +2703,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
2519 case SENSOR_MI1320_SOC: 2703 case SENSOR_MI1320_SOC:
2520 cam->cam_mode = bi_mode; 2704 cam->cam_mode = bi_mode;
2521 cam->nmodes = ARRAY_SIZE(bi_mode); 2705 cam->nmodes = ARRAY_SIZE(bi_mode);
2522 cam->input_flags = V4L2_IN_ST_VFLIP |
2523 V4L2_IN_ST_HFLIP;
2524 break; 2706 break;
2525 default: 2707 default:
2526 cam->cam_mode = vc0323_mode; 2708 cam->cam_mode = vc0323_mode;
@@ -2532,14 +2714,14 @@ static int sd_config(struct gspca_dev *gspca_dev,
2532 2714
2533 sd->hflip = HFLIP_DEF; 2715 sd->hflip = HFLIP_DEF;
2534 sd->vflip = VFLIP_DEF; 2716 sd->vflip = VFLIP_DEF;
2535 if (sd->sensor == SENSOR_OV7670) { 2717 if (sd->sensor == SENSOR_OV7670)
2536 sd->hflip = 1; 2718 sd->flags |= FL_HFLIP | FL_VFLIP;
2537 sd->vflip = 1;
2538 }
2539 sd->lightfreq = FREQ_DEF; 2719 sd->lightfreq = FREQ_DEF;
2540 if (sd->sensor != SENSOR_OV7670) 2720 if (sd->sensor != SENSOR_OV7670)
2541 gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX); 2721 gspca_dev->ctrl_dis = (1 << LIGHTFREQ_IDX);
2542 switch (sd->sensor) { 2722 switch (sd->sensor) {
2723 case SENSOR_MI1310_SOC:
2724 case SENSOR_MI1320_SOC:
2543 case SENSOR_OV7660: 2725 case SENSOR_OV7660:
2544 case SENSOR_OV7670: 2726 case SENSOR_OV7670:
2545 case SENSOR_PO1200: 2727 case SENSOR_PO1200:
@@ -2568,39 +2750,50 @@ static int sd_init(struct gspca_dev *gspca_dev)
2568 return 0; 2750 return 0;
2569} 2751}
2570 2752
2571/* for OV7660 and OV7670 only */ 2753/* some sensors only */
2572static void sethvflip(struct gspca_dev *gspca_dev) 2754static void sethvflip(struct gspca_dev *gspca_dev)
2573{ 2755{
2574 struct sd *sd = (struct sd *) gspca_dev; 2756 struct sd *sd = (struct sd *) gspca_dev;
2575 __u8 data; 2757 u8 data[2], hflip, vflip;
2576 2758
2759 hflip = sd->hflip;
2760 if (sd->flags & FL_HFLIP)
2761 hflip = !hflip;
2762 vflip = sd->vflip;
2763 if (sd->flags & FL_VFLIP)
2764 vflip = !vflip;
2577 switch (sd->sensor) { 2765 switch (sd->sensor) {
2578 case SENSOR_OV7660: 2766 case SENSOR_MI1310_SOC:
2579 data = 1; 2767 case SENSOR_MI1320_SOC:
2768 data[0] = data[1] = 0; /* select page 0 */
2769 i2c_write(gspca_dev, 0xf0, data, 2);
2770 data[0] = sd->sensor == SENSOR_MI1310_SOC ? 0x03 : 0x01;
2771 data[1] = 0x02 * hflip
2772 | 0x01 * vflip;
2773 i2c_write(gspca_dev, 0x20, data, 2);
2580 break; 2774 break;
2775 case SENSOR_OV7660:
2581 case SENSOR_OV7670: 2776 case SENSOR_OV7670:
2582 data = 7; 2777 data[0] = sd->sensor == SENSOR_OV7660 ? 0x01 : 0x07;
2778 data[0] |= OV7660_MVFP_MIRROR * hflip
2779 | OV7660_MVFP_VFLIP * vflip;
2780 i2c_write(gspca_dev, OV7660_REG_MVFP, data, 1);
2583 break; 2781 break;
2584 case SENSOR_PO1200: 2782 case SENSOR_PO1200:
2585 data = 0; 2783 data[0] = 0;
2586 i2c_write(gspca_dev, 0x03, &data, 1); 2784 i2c_write(gspca_dev, 0x03, data, 1);
2587 data = 0x80 * sd->hflip 2785 data[0] = 0x80 * hflip
2588 | 0x40 * sd->vflip 2786 | 0x40 * vflip
2589 | 0x06; 2787 | 0x06;
2590 i2c_write(gspca_dev, 0x1e, &data, 1); 2788 i2c_write(gspca_dev, 0x1e, data, 1);
2591 return; 2789 break;
2592 default:
2593 return;
2594 } 2790 }
2595 data |= OV7660_MVFP_MIRROR * sd->hflip
2596 | OV7660_MVFP_VFLIP * sd->vflip;
2597 i2c_write(gspca_dev, OV7660_REG_MVFP, &data, 1);
2598} 2791}
2599 2792
2600static void setlightfreq(struct gspca_dev *gspca_dev) 2793static void setlightfreq(struct gspca_dev *gspca_dev)
2601{ 2794{
2602 struct sd *sd = (struct sd *) gspca_dev; 2795 struct sd *sd = (struct sd *) gspca_dev;
2603 static const __u8 (*ov7660_freq_tb[3])[4] = 2796 static const u8 (*ov7660_freq_tb[3])[4] =
2604 {ov7660_NoFliker, ov7660_50HZ, ov7660_60HZ}; 2797 {ov7660_NoFliker, ov7660_50HZ, ov7660_60HZ};
2605 2798
2606 if (sd->sensor != SENSOR_OV7660) 2799 if (sd->sensor != SENSOR_OV7660)
@@ -2612,7 +2805,7 @@ static void setlightfreq(struct gspca_dev *gspca_dev)
2612static void setsharpness(struct gspca_dev *gspca_dev) 2805static void setsharpness(struct gspca_dev *gspca_dev)
2613{ 2806{
2614 struct sd *sd = (struct sd *) gspca_dev; 2807 struct sd *sd = (struct sd *) gspca_dev;
2615 __u8 data; 2808 u8 data;
2616 2809
2617 if (sd->sensor != SENSOR_PO1200) 2810 if (sd->sensor != SENSOR_PO1200)
2618 return; 2811 return;
@@ -2625,9 +2818,9 @@ static void setsharpness(struct gspca_dev *gspca_dev)
2625static int sd_start(struct gspca_dev *gspca_dev) 2818static int sd_start(struct gspca_dev *gspca_dev)
2626{ 2819{
2627 struct sd *sd = (struct sd *) gspca_dev; 2820 struct sd *sd = (struct sd *) gspca_dev;
2628 const __u8 (*init)[4]; 2821 const u8 (*init)[4];
2629 const __u8 *GammaT = NULL; 2822 const u8 *GammaT = NULL;
2630 const __u8 *MatrixT = NULL; 2823 const u8 *MatrixT = NULL;
2631 int mode; 2824 int mode;
2632 static const u8 (*mi1320_soc_init[])[4] = { 2825 static const u8 (*mi1320_soc_init[])[4] = {
2633 mi1320_soc_InitSXGA, 2826 mi1320_soc_InitSXGA,
@@ -2635,6 +2828,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
2635 mi1320_soc_InitQVGA, 2828 mi1320_soc_InitQVGA,
2636 }; 2829 };
2637 2830
2831/*fixme: back sensor only*/
2832 if (sd->flags & FL_SAMSUNG) {
2833 reg_w(gspca_dev->dev, 0x89, 0xf0ff, 0xffff);
2834 reg_w(gspca_dev->dev, 0xa9, 0x8348, 0x000e);
2835 reg_w(gspca_dev->dev, 0xa9, 0x0000, 0x001a);
2836 }
2837
2638 /* Assume start use the good resolution from gspca_dev->mode */ 2838 /* Assume start use the good resolution from gspca_dev->mode */
2639 if (sd->bridge == BRIDGE_VC0321) { 2839 if (sd->bridge == BRIDGE_VC0321) {
2640 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfec); 2840 reg_w(gspca_dev->dev, 0xa0, 0xff, 0xbfec);
@@ -2737,16 +2937,22 @@ static int sd_start(struct gspca_dev *gspca_dev)
2737 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c); 2937 put_tab_to_reg(gspca_dev, MatrixT, 9, 0xb82c);
2738 2938
2739 /* set the led on 0x0892 0x0896 */ 2939 /* set the led on 0x0892 0x0896 */
2740 if (sd->sensor != SENSOR_PO1200) { 2940 switch (sd->sensor) {
2741 reg_w(gspca_dev->dev, 0x89, 0xffff, 0xfdff); 2941 case SENSOR_PO1200:
2742 msleep(100); 2942 case SENSOR_HV7131R:
2743 sethvflip(gspca_dev);
2744 setlightfreq(gspca_dev);
2745 } else {
2746 setsharpness(gspca_dev);
2747 sethvflip(gspca_dev);
2748 reg_w(gspca_dev->dev, 0x89, 0x0400, 0x1415); 2943 reg_w(gspca_dev->dev, 0x89, 0x0400, 0x1415);
2944 break;
2945 case SENSOR_MI1310_SOC:
2946 reg_w(gspca_dev->dev, 0x89, 0x058c, 0x0000);
2947 break;
2948 default:
2949 reg_w(gspca_dev->dev, 0x89, 0xffff, 0xfdff);
2950 break;
2749 } 2951 }
2952 msleep(100);
2953 setsharpness(gspca_dev);
2954 sethvflip(gspca_dev);
2955 setlightfreq(gspca_dev);
2750 } 2956 }
2751 return 0; 2957 return 0;
2752} 2958}
@@ -2754,8 +2960,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
2754static void sd_stopN(struct gspca_dev *gspca_dev) 2960static void sd_stopN(struct gspca_dev *gspca_dev)
2755{ 2961{
2756 struct usb_device *dev = gspca_dev->dev; 2962 struct usb_device *dev = gspca_dev->dev;
2963 struct sd *sd = (struct sd *) gspca_dev;
2757 2964
2758 reg_w(dev, 0x89, 0xffff, 0xffff); 2965 if (sd->sensor == SENSOR_MI1310_SOC)
2966 reg_w(dev, 0x89, 0x058c, 0x00ff);
2967 else
2968 reg_w(dev, 0x89, 0xffff, 0xffff);
2759 reg_w(dev, 0xa0, 0x01, 0xb301); 2969 reg_w(dev, 0xa0, 0x01, 0xb301);
2760 reg_w(dev, 0xa0, 0x09, 0xb003); 2970 reg_w(dev, 0xa0, 0x09, 0xb003);
2761} 2971}
@@ -2764,15 +2974,20 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2764static void sd_stop0(struct gspca_dev *gspca_dev) 2974static void sd_stop0(struct gspca_dev *gspca_dev)
2765{ 2975{
2766 struct usb_device *dev = gspca_dev->dev; 2976 struct usb_device *dev = gspca_dev->dev;
2977 struct sd *sd = (struct sd *) gspca_dev;
2767 2978
2768 if (!gspca_dev->present) 2979 if (!gspca_dev->present)
2769 return; 2980 return;
2770 reg_w(dev, 0x89, 0xffff, 0xffff); 2981/*fixme: is this useful?*/
2982 if (sd->sensor == SENSOR_MI1310_SOC)
2983 reg_w(dev, 0x89, 0x058c, 0x00ff);
2984 else
2985 reg_w(dev, 0x89, 0xffff, 0xffff);
2771} 2986}
2772 2987
2773static void sd_pkt_scan(struct gspca_dev *gspca_dev, 2988static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2774 struct gspca_frame *frame, /* target */ 2989 struct gspca_frame *frame, /* target */
2775 __u8 *data, /* isoc packet */ 2990 u8 *data, /* isoc packet */
2776 int len) /* iso pkt length */ 2991 int len) /* iso pkt length */
2777{ 2992{
2778 struct sd *sd = (struct sd *) gspca_dev; 2993 struct sd *sd = (struct sd *) gspca_dev;
@@ -2872,21 +3087,12 @@ static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
2872static int sd_querymenu(struct gspca_dev *gspca_dev, 3087static int sd_querymenu(struct gspca_dev *gspca_dev,
2873 struct v4l2_querymenu *menu) 3088 struct v4l2_querymenu *menu)
2874{ 3089{
3090 static const char *freq_nm[3] = {"NoFliker", "50 Hz", "60 Hz"};
3091
2875 switch (menu->id) { 3092 switch (menu->id) {
2876 case V4L2_CID_POWER_LINE_FREQUENCY: 3093 case V4L2_CID_POWER_LINE_FREQUENCY:
2877 switch (menu->index) { 3094 strcpy((char *) menu->name, freq_nm[menu->index]);
2878 case 0: /* V4L2_CID_POWER_LINE_FREQUENCY_DISABLED */ 3095 return 0;
2879 strcpy((char *) menu->name, "NoFliker");
2880 return 0;
2881 case 1: /* V4L2_CID_POWER_LINE_FREQUENCY_50HZ */
2882 strcpy((char *) menu->name, "50 Hz");
2883 return 0;
2884 default:
2885/* case 2: * V4L2_CID_POWER_LINE_FREQUENCY_60HZ */
2886 strcpy((char *) menu->name, "60 Hz");
2887 return 0;
2888 }
2889 break;
2890 } 3096 }
2891 return -EINVAL; 3097 return -EINVAL;
2892} 3098}
@@ -2906,19 +3112,23 @@ static const struct sd_desc sd_desc = {
2906}; 3112};
2907 3113
2908/* -- module initialisation -- */ 3114/* -- module initialisation -- */
3115#define BF(bridge, flags) \
3116 .driver_info = (BRIDGE_ ## bridge << 8) \
3117 | (flags)
2909static const __devinitdata struct usb_device_id device_table[] = { 3118static const __devinitdata struct usb_device_id device_table[] = {
2910 {USB_DEVICE(0x041e, 0x405b), .driver_info = BRIDGE_VC0323}, 3119 {USB_DEVICE(0x041e, 0x405b), BF(VC0323, FL_VFLIP)},
2911 {USB_DEVICE(0x046d, 0x0892), .driver_info = BRIDGE_VC0321}, 3120 {USB_DEVICE(0x046d, 0x0892), BF(VC0321, 0)},
2912 {USB_DEVICE(0x046d, 0x0896), .driver_info = BRIDGE_VC0321}, 3121 {USB_DEVICE(0x046d, 0x0896), BF(VC0321, 0)},
2913 {USB_DEVICE(0x046d, 0x0897), .driver_info = BRIDGE_VC0321}, 3122 {USB_DEVICE(0x046d, 0x0897), BF(VC0321, 0)},
2914 {USB_DEVICE(0x0ac8, 0x0321), .driver_info = BRIDGE_VC0321}, 3123 {USB_DEVICE(0x0ac8, 0x0321), BF(VC0321, 0)},
2915 {USB_DEVICE(0x0ac8, 0x0323), .driver_info = BRIDGE_VC0323}, 3124 {USB_DEVICE(0x0ac8, 0x0323), BF(VC0323, 0)},
2916 {USB_DEVICE(0x0ac8, 0x0328), .driver_info = BRIDGE_VC0321}, 3125 {USB_DEVICE(0x0ac8, 0x0328), BF(VC0321, 0)},
2917 {USB_DEVICE(0x0ac8, 0xc001), .driver_info = BRIDGE_VC0321}, 3126 {USB_DEVICE(0x0ac8, 0xc001), BF(VC0321, 0)},
2918 {USB_DEVICE(0x0ac8, 0xc002), .driver_info = BRIDGE_VC0321}, 3127 {USB_DEVICE(0x0ac8, 0xc002), BF(VC0321, 0)},
2919 {USB_DEVICE(0x15b8, 0x6001), .driver_info = BRIDGE_VC0323}, 3128 {USB_DEVICE(0x0ac8, 0xc301), BF(VC0323, FL_SAMSUNG)},
2920 {USB_DEVICE(0x15b8, 0x6002), .driver_info = BRIDGE_VC0323}, 3129 {USB_DEVICE(0x15b8, 0x6001), BF(VC0323, 0)},
2921 {USB_DEVICE(0x17ef, 0x4802), .driver_info = BRIDGE_VC0323}, 3130 {USB_DEVICE(0x15b8, 0x6002), BF(VC0323, 0)},
3131 {USB_DEVICE(0x17ef, 0x4802), BF(VC0323, 0)},
2922 {} 3132 {}
2923}; 3133};
2924MODULE_DEVICE_TABLE(usb, device_table); 3134MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 3d2756f7874a..cdf3357b4c9f 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -7574,7 +7574,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
7574static const struct sd_desc sd_desc = { 7574static const struct sd_desc sd_desc = {
7575 .name = MODULE_NAME, 7575 .name = MODULE_NAME,
7576 .ctrls = sd_ctrls, 7576 .ctrls = sd_ctrls,
7577 .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0], 7577 .nctrls = ARRAY_SIZE(sd_ctrls),
7578 .config = sd_config, 7578 .config = sd_config,
7579 .init = sd_init, 7579 .init = sd_init,
7580 .start = sd_start, 7580 .start = sd_start,
diff --git a/drivers/media/video/hdpvr/hdpvr-control.c b/drivers/media/video/hdpvr/hdpvr-control.c
index 06791749d1a0..5a6b78b8d25d 100644
--- a/drivers/media/video/hdpvr/hdpvr-control.c
+++ b/drivers/media/video/hdpvr/hdpvr-control.c
@@ -178,24 +178,24 @@ error:
178 178
179int hdpvr_set_options(struct hdpvr_device *dev) 179int hdpvr_set_options(struct hdpvr_device *dev)
180{ 180{
181 hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, dev->options.video_std); 181 hdpvr_config_call(dev, CTRL_VIDEO_STD_TYPE, dev->options.video_std);
182 182
183 hdpvr_config_call(dev, CTRL_VIDEO_INPUT_VALUE, 183 hdpvr_config_call(dev, CTRL_VIDEO_INPUT_VALUE,
184 dev->options.video_input+1); 184 dev->options.video_input+1);
185 185
186 hdpvr_set_audio(dev, dev->options.audio_input+1, 186 hdpvr_set_audio(dev, dev->options.audio_input+1,
187 dev->options.audio_codec); 187 dev->options.audio_codec);
188 188
189 hdpvr_set_bitrate(dev); 189 hdpvr_set_bitrate(dev);
190 hdpvr_config_call(dev, CTRL_BITRATE_MODE_VALUE, 190 hdpvr_config_call(dev, CTRL_BITRATE_MODE_VALUE,
191 dev->options.bitrate_mode); 191 dev->options.bitrate_mode);
192 hdpvr_config_call(dev, CTRL_GOP_MODE_VALUE, dev->options.gop_mode); 192 hdpvr_config_call(dev, CTRL_GOP_MODE_VALUE, dev->options.gop_mode);
193 193
194 hdpvr_config_call(dev, CTRL_BRIGHTNESS, dev->options.brightness); 194 hdpvr_config_call(dev, CTRL_BRIGHTNESS, dev->options.brightness);
195 hdpvr_config_call(dev, CTRL_CONTRAST, dev->options.contrast); 195 hdpvr_config_call(dev, CTRL_CONTRAST, dev->options.contrast);
196 hdpvr_config_call(dev, CTRL_HUE, dev->options.hue); 196 hdpvr_config_call(dev, CTRL_HUE, dev->options.hue);
197 hdpvr_config_call(dev, CTRL_SATURATION, dev->options.saturation); 197 hdpvr_config_call(dev, CTRL_SATURATION, dev->options.saturation);
198 hdpvr_config_call(dev, CTRL_SHARPNESS, dev->options.sharpness); 198 hdpvr_config_call(dev, CTRL_SHARPNESS, dev->options.sharpness);
199 199
200 return 0; 200 return 0;
201} 201}
diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
index 188bd5aea258..1c9bc94c905c 100644
--- a/drivers/media/video/hdpvr/hdpvr-core.c
+++ b/drivers/media/video/hdpvr/hdpvr-core.c
@@ -126,7 +126,7 @@ static int device_authorization(struct hdpvr_device *dev)
126 char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL); 126 char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL);
127 if (!print_buf) { 127 if (!print_buf) {
128 v4l2_err(&dev->v4l2_dev, "Out of memory\n"); 128 v4l2_err(&dev->v4l2_dev, "Out of memory\n");
129 goto error; 129 return retval;
130 } 130 }
131#endif 131#endif
132 132
@@ -140,7 +140,7 @@ static int device_authorization(struct hdpvr_device *dev)
140 if (ret != 46) { 140 if (ret != 46) {
141 v4l2_err(&dev->v4l2_dev, 141 v4l2_err(&dev->v4l2_dev,
142 "unexpected answer of status request, len %d\n", ret); 142 "unexpected answer of status request, len %d\n", ret);
143 goto error; 143 goto unlock;
144 } 144 }
145#ifdef HDPVR_DEBUG 145#ifdef HDPVR_DEBUG
146 else { 146 else {
@@ -163,7 +163,7 @@ static int device_authorization(struct hdpvr_device *dev)
163 v4l2_err(&dev->v4l2_dev, "unknown firmware version 0x%x\n", 163 v4l2_err(&dev->v4l2_dev, "unknown firmware version 0x%x\n",
164 dev->usbc_buf[1]); 164 dev->usbc_buf[1]);
165 ret = -EINVAL; 165 ret = -EINVAL;
166 goto error; 166 goto unlock;
167 } 167 }
168 168
169 response = dev->usbc_buf+38; 169 response = dev->usbc_buf+38;
@@ -188,10 +188,10 @@ static int device_authorization(struct hdpvr_device *dev)
188 10000); 188 10000);
189 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, 189 v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
190 "magic request returned %d\n", ret); 190 "magic request returned %d\n", ret);
191 mutex_unlock(&dev->usbc_mutex);
192 191
193 retval = ret != 8; 192 retval = ret != 8;
194error: 193unlock:
194 mutex_unlock(&dev->usbc_mutex);
195 return retval; 195 return retval;
196} 196}
197 197
@@ -350,6 +350,7 @@ static int hdpvr_probe(struct usb_interface *interface,
350 350
351 mutex_lock(&dev->io_mutex); 351 mutex_lock(&dev->io_mutex);
352 if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) { 352 if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) {
353 mutex_unlock(&dev->io_mutex);
353 v4l2_err(&dev->v4l2_dev, 354 v4l2_err(&dev->v4l2_dev,
354 "allocating transfer buffers failed\n"); 355 "allocating transfer buffers failed\n");
355 goto error; 356 goto error;
@@ -381,7 +382,6 @@ static int hdpvr_probe(struct usb_interface *interface,
381 382
382error: 383error:
383 if (dev) { 384 if (dev) {
384 mutex_unlock(&dev->io_mutex);
385 /* this frees allocated memory */ 385 /* this frees allocated memory */
386 hdpvr_delete(dev); 386 hdpvr_delete(dev);
387 } 387 }
diff --git a/drivers/media/video/hdpvr/hdpvr-i2c.c b/drivers/media/video/hdpvr/hdpvr-i2c.c
index c4b5d1515c10..296330a0e1e5 100644
--- a/drivers/media/video/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/video/hdpvr/hdpvr-i2c.c
@@ -127,7 +127,6 @@ int hdpvr_register_i2c_adapter(struct hdpvr_device *dev)
127 sizeof(i2c_adap->name)); 127 sizeof(i2c_adap->name));
128 i2c_adap->algo = &hdpvr_algo; 128 i2c_adap->algo = &hdpvr_algo;
129 i2c_adap->class = I2C_CLASS_TV_ANALOG; 129 i2c_adap->class = I2C_CLASS_TV_ANALOG;
130 i2c_adap->id = I2C_HW_B_HDPVR;
131 i2c_adap->owner = THIS_MODULE; 130 i2c_adap->owner = THIS_MODULE;
132 i2c_adap->dev.parent = &dev->udev->dev; 131 i2c_adap->dev.parent = &dev->udev->dev;
133 132
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index d678765cbba2..2eb9dc2ebe59 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -375,6 +375,7 @@ static int hdpvr_open(struct file *file)
375 * in resumption */ 375 * in resumption */
376 mutex_lock(&dev->io_mutex); 376 mutex_lock(&dev->io_mutex);
377 dev->open_count++; 377 dev->open_count++;
378 mutex_unlock(&dev->io_mutex);
378 379
379 fh->dev = dev; 380 fh->dev = dev;
380 381
@@ -383,7 +384,6 @@ static int hdpvr_open(struct file *file)
383 384
384 retval = 0; 385 retval = 0;
385err: 386err:
386 mutex_unlock(&dev->io_mutex);
387 return retval; 387 return retval;
388} 388}
389 389
@@ -519,8 +519,10 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
519 519
520 mutex_lock(&dev->io_mutex); 520 mutex_lock(&dev->io_mutex);
521 521
522 if (video_is_unregistered(dev->video_dev)) 522 if (video_is_unregistered(dev->video_dev)) {
523 mutex_unlock(&dev->io_mutex);
523 return -EIO; 524 return -EIO;
525 }
524 526
525 if (dev->status == STATUS_IDLE) { 527 if (dev->status == STATUS_IDLE) {
526 if (hdpvr_start_streaming(dev)) { 528 if (hdpvr_start_streaming(dev)) {
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 86f2fefe1edf..247d3115a9b7 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -122,12 +122,12 @@ static int get_key_haup_common(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
122 return 1; 122 return 1;
123} 123}
124 124
125static inline int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) 125static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
126{ 126{
127 return get_key_haup_common (ir, ir_key, ir_raw, 3, 0); 127 return get_key_haup_common (ir, ir_key, ir_raw, 3, 0);
128} 128}
129 129
130static inline int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) 130static int get_key_haup_xvr(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
131{ 131{
132 return get_key_haup_common (ir, ir_key, ir_raw, 6, 3); 132 return get_key_haup_common (ir, ir_key, ir_raw, 6, 3);
133} 133}
@@ -297,7 +297,7 @@ static void ir_work(struct work_struct *work)
297 297
298static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) 298static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
299{ 299{
300 IR_KEYTAB_TYPE *ir_codes = NULL; 300 struct ir_scancode_table *ir_codes = NULL;
301 const char *name = NULL; 301 const char *name = NULL;
302 int ir_type; 302 int ir_type;
303 struct IR_i2c *ir; 303 struct IR_i2c *ir;
@@ -322,13 +322,13 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
322 name = "Pixelview"; 322 name = "Pixelview";
323 ir->get_key = get_key_pixelview; 323 ir->get_key = get_key_pixelview;
324 ir_type = IR_TYPE_OTHER; 324 ir_type = IR_TYPE_OTHER;
325 ir_codes = ir_codes_empty; 325 ir_codes = &ir_codes_empty_table;
326 break; 326 break;
327 case 0x4b: 327 case 0x4b:
328 name = "PV951"; 328 name = "PV951";
329 ir->get_key = get_key_pv951; 329 ir->get_key = get_key_pv951;
330 ir_type = IR_TYPE_OTHER; 330 ir_type = IR_TYPE_OTHER;
331 ir_codes = ir_codes_pv951; 331 ir_codes = &ir_codes_pv951_table;
332 break; 332 break;
333 case 0x18: 333 case 0x18:
334 case 0x1a: 334 case 0x1a:
@@ -336,36 +336,38 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
336 ir->get_key = get_key_haup; 336 ir->get_key = get_key_haup;
337 ir_type = IR_TYPE_RC5; 337 ir_type = IR_TYPE_RC5;
338 if (hauppauge == 1) { 338 if (hauppauge == 1) {
339 ir_codes = ir_codes_hauppauge_new; 339 ir_codes = &ir_codes_hauppauge_new_table;
340 } else { 340 } else {
341 ir_codes = ir_codes_rc5_tv; 341 ir_codes = &ir_codes_rc5_tv_table;
342 } 342 }
343 break; 343 break;
344 case 0x30: 344 case 0x30:
345 name = "KNC One"; 345 name = "KNC One";
346 ir->get_key = get_key_knc1; 346 ir->get_key = get_key_knc1;
347 ir_type = IR_TYPE_OTHER; 347 ir_type = IR_TYPE_OTHER;
348 ir_codes = ir_codes_empty; 348 ir_codes = &ir_codes_empty_table;
349 break; 349 break;
350 case 0x6b: 350 case 0x6b:
351 name = "FusionHDTV"; 351 name = "FusionHDTV";
352 ir->get_key = get_key_fusionhdtv; 352 ir->get_key = get_key_fusionhdtv;
353 ir_type = IR_TYPE_RC5; 353 ir_type = IR_TYPE_RC5;
354 ir_codes = ir_codes_fusionhdtv_mce; 354 ir_codes = &ir_codes_fusionhdtv_mce_table;
355 break; 355 break;
356 case 0x7a: 356 case 0x7a:
357 case 0x47: 357 case 0x47:
358 case 0x71: 358 case 0x71:
359 case 0x2d: 359 case 0x2d:
360 if (adap->id == I2C_HW_B_CX2388x) { 360 if (adap->id == I2C_HW_B_CX2388x ||
361 adap->id == I2C_HW_B_CX2341X) {
361 /* Handled by cx88-input */ 362 /* Handled by cx88-input */
362 name = "CX2388x remote"; 363 name = adap->id == I2C_HW_B_CX2341X ? "CX2341x remote"
364 : "CX2388x remote";
363 ir_type = IR_TYPE_RC5; 365 ir_type = IR_TYPE_RC5;
364 ir->get_key = get_key_haup_xvr; 366 ir->get_key = get_key_haup_xvr;
365 if (hauppauge == 1) { 367 if (hauppauge == 1) {
366 ir_codes = ir_codes_hauppauge_new; 368 ir_codes = &ir_codes_hauppauge_new_table;
367 } else { 369 } else {
368 ir_codes = ir_codes_rc5_tv; 370 ir_codes = &ir_codes_rc5_tv_table;
369 } 371 }
370 } else { 372 } else {
371 /* Handled by saa7134-input */ 373 /* Handled by saa7134-input */
@@ -377,7 +379,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
377 name = "AVerMedia Cardbus remote"; 379 name = "AVerMedia Cardbus remote";
378 ir->get_key = get_key_avermedia_cardbus; 380 ir->get_key = get_key_avermedia_cardbus;
379 ir_type = IR_TYPE_OTHER; 381 ir_type = IR_TYPE_OTHER;
380 ir_codes = ir_codes_avermedia_cardbus; 382 ir_codes = &ir_codes_avermedia_cardbus_table;
381 break; 383 break;
382 default: 384 default:
383 dprintk(1, DEVNAME ": Unsupported i2c address 0x%02x\n", addr); 385 dprintk(1, DEVNAME ": Unsupported i2c address 0x%02x\n", addr);
@@ -392,7 +394,36 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
392 394
393 ir_codes = init_data->ir_codes; 395 ir_codes = init_data->ir_codes;
394 name = init_data->name; 396 name = init_data->name;
395 ir->get_key = init_data->get_key; 397 if (init_data->type)
398 ir_type = init_data->type;
399
400 switch (init_data->internal_get_key_func) {
401 case IR_KBD_GET_KEY_CUSTOM:
402 /* The bridge driver provided us its own function */
403 ir->get_key = init_data->get_key;
404 break;
405 case IR_KBD_GET_KEY_PIXELVIEW:
406 ir->get_key = get_key_pixelview;
407 break;
408 case IR_KBD_GET_KEY_PV951:
409 ir->get_key = get_key_pv951;
410 break;
411 case IR_KBD_GET_KEY_HAUP:
412 ir->get_key = get_key_haup;
413 break;
414 case IR_KBD_GET_KEY_KNC1:
415 ir->get_key = get_key_knc1;
416 break;
417 case IR_KBD_GET_KEY_FUSIONHDTV:
418 ir->get_key = get_key_fusionhdtv;
419 break;
420 case IR_KBD_GET_KEY_HAUP_XVR:
421 ir->get_key = get_key_haup_xvr;
422 break;
423 case IR_KBD_GET_KEY_AVERMEDIA_CARDBUS:
424 ir->get_key = get_key_avermedia_cardbus;
425 break;
426 }
396 } 427 }
397 428
398 /* Make sure we are all setup before going on */ 429 /* Make sure we are all setup before going on */
@@ -454,7 +485,8 @@ static int ir_remove(struct i2c_client *client)
454static const struct i2c_device_id ir_kbd_id[] = { 485static const struct i2c_device_id ir_kbd_id[] = {
455 /* Generic entry for any IR receiver */ 486 /* Generic entry for any IR receiver */
456 { "ir_video", 0 }, 487 { "ir_video", 0 },
457 /* IR device specific entries could be added here */ 488 /* IR device specific entries should be added here */
489 { "ir_rx_z8f0811_haup", 0 },
458 { } 490 { }
459}; 491};
460 492
diff --git a/drivers/media/video/ivtv/ivtv-cards.c b/drivers/media/video/ivtv/ivtv-cards.c
index 2883c8780760..4873b6ca5801 100644
--- a/drivers/media/video/ivtv/ivtv-cards.c
+++ b/drivers/media/video/ivtv/ivtv-cards.c
@@ -977,26 +977,27 @@ static const struct ivtv_card ivtv_card_avertv_mce116 = {
977 977
978/* ------------------------------------------------------------------------- */ 978/* ------------------------------------------------------------------------- */
979 979
980/* AVerMedia PVR-150 Plus (M113) card */ 980/* AVerMedia PVR-150 Plus / AVerTV M113 cards with a Daewoo/Partsnic Tuner */
981 981
982static const struct ivtv_card_pci_info ivtv_pci_aver_pvr150[] = { 982static const struct ivtv_card_pci_info ivtv_pci_aver_pvr150[] = {
983 { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_AVERMEDIA, 0xc035 }, 983 { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_AVERMEDIA, 0xc034 }, /* NTSC */
984 { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_AVERMEDIA, 0xc035 }, /* NTSC FM */
984 { 0, 0, 0 } 985 { 0, 0, 0 }
985}; 986};
986 987
987static const struct ivtv_card ivtv_card_aver_pvr150 = { 988static const struct ivtv_card ivtv_card_aver_pvr150 = {
988 .type = IVTV_CARD_AVER_PVR150PLUS, 989 .type = IVTV_CARD_AVER_PVR150PLUS,
989 .name = "AVerMedia PVR-150 Plus", 990 .name = "AVerMedia PVR-150 Plus / AVerTV M113 Partsnic (Daewoo) Tuner",
990 .v4l2_capabilities = IVTV_CAP_ENCODER, 991 .v4l2_capabilities = IVTV_CAP_ENCODER,
991 .hw_video = IVTV_HW_CX25840, 992 .hw_video = IVTV_HW_CX25840,
992 .hw_audio = IVTV_HW_CX25840, 993 .hw_audio = IVTV_HW_CX25840,
993 .hw_audio_ctrl = IVTV_HW_CX25840, 994 .hw_audio_ctrl = IVTV_HW_CX25840,
994 .hw_muxer = IVTV_HW_GPIO, 995 .hw_muxer = IVTV_HW_GPIO,
995 .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER, 996 .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER |
997 IVTV_HW_WM8739 | IVTV_HW_GPIO,
996 .video_inputs = { 998 .video_inputs = {
997 { IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 }, 999 { IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 },
998 { IVTV_CARD_INPUT_SVIDEO1, 1, 1000 { IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 },
999 CX25840_SVIDEO_LUMA3 | CX25840_SVIDEO_CHROMA4 },
1000 { IVTV_CARD_INPUT_COMPOSITE1, 1, CX25840_COMPOSITE1 }, 1001 { IVTV_CARD_INPUT_COMPOSITE1, 1, CX25840_COMPOSITE1 },
1001 }, 1002 },
1002 .audio_inputs = { 1003 .audio_inputs = {
@@ -1004,18 +1005,66 @@ static const struct ivtv_card ivtv_card_aver_pvr150 = {
1004 { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 1 }, 1005 { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 1 },
1005 }, 1006 },
1006 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO_SERIAL, 2 }, 1007 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO_SERIAL, 2 },
1007 .gpio_init = { .direction = 0x0800, .initial_value = 0 }, 1008 /* The 74HC4052 Dual 4:1 multiplexer is controlled by 2 GPIO lines */
1008 .gpio_audio_input = { .mask = 0x0800, .tuner = 0, .linein = 0, .radio = 0x0800 }, 1009 .gpio_init = { .direction = 0xc000, .initial_value = 0 },
1010 .gpio_audio_input = { .mask = 0xc000,
1011 .tuner = 0x0000,
1012 .linein = 0x4000,
1013 .radio = 0x8000 },
1009 .tuners = { 1014 .tuners = {
1010 /* This card has a Partsnic PTI-5NF05 tuner */ 1015 /* Subsystem ID's 0xc03[45] have a Partsnic PTI-5NF05 tuner */
1011 { .std = V4L2_STD_MN, .tuner = TUNER_TCL_2002N }, 1016 { .std = V4L2_STD_MN, .tuner = TUNER_PARTSNIC_PTI_5NF05 },
1012 }, 1017 },
1013 .pci_list = ivtv_pci_aver_pvr150, 1018 .pci_list = ivtv_pci_aver_pvr150,
1019 /* Subsystem ID 0xc035 has a TEA5767(?) FM tuner, 0xc034 does not */
1014 .i2c = &ivtv_i2c_radio, 1020 .i2c = &ivtv_i2c_radio,
1015}; 1021};
1016 1022
1017/* ------------------------------------------------------------------------- */ 1023/* ------------------------------------------------------------------------- */
1018 1024
1025/* AVerMedia UltraTV 1500 MCE (newer non-cx88 version, M113 variant) card */
1026
1027static const struct ivtv_card_pci_info ivtv_pci_aver_ultra1500mce[] = {
1028 { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_AVERMEDIA, 0xc019 },
1029 { 0, 0, 0 }
1030};
1031
1032static const struct ivtv_card ivtv_card_aver_ultra1500mce = {
1033 .type = IVTV_CARD_AVER_ULTRA1500MCE,
1034 .name = "AVerMedia UltraTV 1500 MCE / AVerTV M113 Philips Tuner",
1035 .v4l2_capabilities = IVTV_CAP_ENCODER,
1036 .hw_video = IVTV_HW_CX25840,
1037 .hw_audio = IVTV_HW_CX25840,
1038 .hw_audio_ctrl = IVTV_HW_CX25840,
1039 .hw_muxer = IVTV_HW_GPIO,
1040 .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER |
1041 IVTV_HW_WM8739 | IVTV_HW_GPIO,
1042 .video_inputs = {
1043 { IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 },
1044 { IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 },
1045 { IVTV_CARD_INPUT_COMPOSITE1, 1, CX25840_COMPOSITE1 },
1046 },
1047 .audio_inputs = {
1048 { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO5, 0 },
1049 { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 1 },
1050 },
1051 .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO_SERIAL, 2 },
1052 /* The 74HC4052 Dual 4:1 multiplexer is controlled by 2 GPIO lines */
1053 .gpio_init = { .direction = 0xc000, .initial_value = 0 },
1054 .gpio_audio_input = { .mask = 0xc000,
1055 .tuner = 0x0000,
1056 .linein = 0x4000,
1057 .radio = 0x8000 },
1058 .tuners = {
1059 /* The UltraTV 1500 MCE has a Philips FM1236 MK5 TV/FM tuner */
1060 { .std = V4L2_STD_MN, .tuner = TUNER_PHILIPS_FM1236_MK3 },
1061 },
1062 .pci_list = ivtv_pci_aver_ultra1500mce,
1063 .i2c = &ivtv_i2c_std,
1064};
1065
1066/* ------------------------------------------------------------------------- */
1067
1019/* AVerMedia EZMaker PCI Deluxe card */ 1068/* AVerMedia EZMaker PCI Deluxe card */
1020 1069
1021static const struct ivtv_card_pci_info ivtv_pci_aver_ezmaker[] = { 1070static const struct ivtv_card_pci_info ivtv_pci_aver_ezmaker[] = {
@@ -1180,6 +1229,7 @@ static const struct ivtv_card *ivtv_card_list[] = {
1180 &ivtv_card_aver_ezmaker, 1229 &ivtv_card_aver_ezmaker,
1181 &ivtv_card_aver_m104, 1230 &ivtv_card_aver_m104,
1182 &ivtv_card_buffalo, 1231 &ivtv_card_buffalo,
1232 &ivtv_card_aver_ultra1500mce,
1183 1233
1184 /* Variations of standard cards but with the same PCI IDs. 1234 /* Variations of standard cards but with the same PCI IDs.
1185 These cards must come last in this list. */ 1235 These cards must come last in this list. */
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h
index 0b8fe85fb697..e99a0a255578 100644
--- a/drivers/media/video/ivtv/ivtv-cards.h
+++ b/drivers/media/video/ivtv/ivtv-cards.h
@@ -50,7 +50,8 @@
50#define IVTV_CARD_AVER_EZMAKER 23 /* AVerMedia EZMaker PCI Deluxe */ 50#define IVTV_CARD_AVER_EZMAKER 23 /* AVerMedia EZMaker PCI Deluxe */
51#define IVTV_CARD_AVER_M104 24 /* AverMedia M104 miniPCI card */ 51#define IVTV_CARD_AVER_M104 24 /* AverMedia M104 miniPCI card */
52#define IVTV_CARD_BUFFALO_MV5L 25 /* Buffalo PC-MV5L/PCI card */ 52#define IVTV_CARD_BUFFALO_MV5L 25 /* Buffalo PC-MV5L/PCI card */
53#define IVTV_CARD_LAST 25 53#define IVTV_CARD_AVER_ULTRA1500MCE 26 /* AVerMedia UltraTV 1500 MCE */
54#define IVTV_CARD_LAST 26
54 55
55/* Variants of existing cards but with the same PCI IDs. The driver 56/* Variants of existing cards but with the same PCI IDs. The driver
56 detects these based on other device information. 57 detects these based on other device information.
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 558f8a837ff4..63ea0fb66063 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -186,6 +186,7 @@ MODULE_PARM_DESC(cardtype,
186 "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n" 186 "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n"
187 "\t\t\t25 = AverMedia M104 (not yet working)\n" 187 "\t\t\t25 = AverMedia M104 (not yet working)\n"
188 "\t\t\t26 = Buffalo PC-MV5L/PCI\n" 188 "\t\t\t26 = Buffalo PC-MV5L/PCI\n"
189 "\t\t\t27 = AVerMedia UltraTV 1500 MCE\n"
189 "\t\t\t 0 = Autodetect (default)\n" 190 "\t\t\t 0 = Autodetect (default)\n"
190 "\t\t\t-1 = Ignore this card\n\t\t"); 191 "\t\t\t-1 = Ignore this card\n\t\t");
191MODULE_PARM_DESC(pal, "Set PAL standard: BGH, DK, I, M, N, Nc, 60"); 192MODULE_PARM_DESC(pal, "Set PAL standard: BGH, DK, I, M, N, Nc, 60");
@@ -218,7 +219,7 @@ MODULE_PARM_DESC(ivtv_yuv_mode,
218 "\t\t\tDefault: 0 (interlaced)"); 219 "\t\t\tDefault: 0 (interlaced)");
219MODULE_PARM_DESC(ivtv_yuv_threshold, 220MODULE_PARM_DESC(ivtv_yuv_threshold,
220 "If ivtv_yuv_mode is 2 (auto) then playback content as\n\t\tprogressive if src height <= ivtv_yuvthreshold\n" 221 "If ivtv_yuv_mode is 2 (auto) then playback content as\n\t\tprogressive if src height <= ivtv_yuvthreshold\n"
221 "\t\t\tDefault: 480");; 222 "\t\t\tDefault: 480");
222MODULE_PARM_DESC(enc_mpg_buffers, 223MODULE_PARM_DESC(enc_mpg_buffers,
223 "Encoder MPG Buffers (in MB)\n" 224 "Encoder MPG Buffers (in MB)\n"
224 "\t\t\tDefault: " __stringify(IVTV_DEFAULT_ENC_MPG_BUFFERS)); 225 "\t\t\tDefault: " __stringify(IVTV_DEFAULT_ENC_MPG_BUFFERS));
diff --git a/drivers/media/video/ivtv/ivtv-gpio.c b/drivers/media/video/ivtv/ivtv-gpio.c
index 85ac707228e7..aede061cae5d 100644
--- a/drivers/media/video/ivtv/ivtv-gpio.c
+++ b/drivers/media/video/ivtv/ivtv-gpio.c
@@ -236,18 +236,6 @@ static int subdev_s_radio(struct v4l2_subdev *sd)
236 return 0; 236 return 0;
237} 237}
238 238
239static int subdev_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
240{
241 struct ivtv *itv = sd_to_ivtv(sd);
242 u16 mask, data;
243
244 mask = itv->card->gpio_audio_input.mask;
245 data = itv->card->gpio_audio_input.tuner;
246 if (mask)
247 write_reg((read_reg(IVTV_REG_GPIO_OUT) & ~mask) | (data & mask), IVTV_REG_GPIO_OUT);
248 return 0;
249}
250
251static int subdev_s_audio_routing(struct v4l2_subdev *sd, 239static int subdev_s_audio_routing(struct v4l2_subdev *sd,
252 u32 input, u32 output, u32 config) 240 u32 input, u32 output, u32 config)
253{ 241{
@@ -344,7 +332,6 @@ static const struct v4l2_subdev_core_ops subdev_core_ops = {
344 .g_ctrl = subdev_g_ctrl, 332 .g_ctrl = subdev_g_ctrl,
345 .s_ctrl = subdev_s_ctrl, 333 .s_ctrl = subdev_s_ctrl,
346 .queryctrl = subdev_queryctrl, 334 .queryctrl = subdev_queryctrl,
347 .s_std = subdev_s_std,
348}; 335};
349 336
350static const struct v4l2_subdev_tuner_ops subdev_tuner_ops = { 337static const struct v4l2_subdev_tuner_ops subdev_tuner_ops = {
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index e52aa322b134..8f15a31d3f66 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -509,7 +509,6 @@ static struct i2c_algorithm ivtv_algo = {
509/* template for our-bit banger */ 509/* template for our-bit banger */
510static struct i2c_adapter ivtv_i2c_adap_hw_template = { 510static struct i2c_adapter ivtv_i2c_adap_hw_template = {
511 .name = "ivtv i2c driver", 511 .name = "ivtv i2c driver",
512 .id = I2C_HW_B_CX2341X,
513 .algo = &ivtv_algo, 512 .algo = &ivtv_algo,
514 .algo_data = NULL, /* filled from template */ 513 .algo_data = NULL, /* filled from template */
515 .owner = THIS_MODULE, 514 .owner = THIS_MODULE,
@@ -560,7 +559,6 @@ static int ivtv_getsda_old(void *data)
560/* template for i2c-bit-algo */ 559/* template for i2c-bit-algo */
561static struct i2c_adapter ivtv_i2c_adap_template = { 560static struct i2c_adapter ivtv_i2c_adap_template = {
562 .name = "ivtv i2c driver", 561 .name = "ivtv i2c driver",
563 .id = I2C_HW_B_CX2341X,
564 .algo = NULL, /* set by i2c-algo-bit */ 562 .algo = NULL, /* set by i2c-algo-bit */
565 .algo_data = NULL, /* filled from template */ 563 .algo_data = NULL, /* filled from template */
566 .owner = THIS_MODULE, 564 .owner = THIS_MODULE,
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index 1d66855a379a..d0765bed79c9 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1915,8 +1915,7 @@ static void __devexit meye_remove(struct pci_dev *pcidev)
1915} 1915}
1916 1916
1917static struct pci_device_id meye_pci_tbl[] = { 1917static struct pci_device_id meye_pci_tbl[] = {
1918 { PCI_VENDOR_ID_KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002, 1918 { PCI_VDEVICE(KAWASAKI, PCI_DEVICE_ID_MCHIP_KL5A72002), 0 },
1919 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
1920 { } 1919 { }
1921}; 1920};
1922 1921
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c
index 416933ca607d..cc06d5e4adcc 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -65,9 +65,10 @@ void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
65 u32 input; 65 u32 input;
66 66
67 pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo"); 67 pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo");
68 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
69 routing_schemes[sid] : NULL;
68 70
69 if ((sid < ARRAY_SIZE(routing_schemes)) && 71 if ((sp != NULL) &&
70 ((sp = routing_schemes[sid]) != NULL) &&
71 (hdw->input_val >= 0) && 72 (hdw->input_val >= 0) &&
72 (hdw->input_val < sp->cnt)) { 73 (hdw->input_val < sp->cnt)) {
73 input = sp->def[hdw->input_val]; 74 input = sp->def[hdw->input_val];
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 610bd848df24..a334b1a966a2 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -540,7 +540,6 @@ static struct i2c_algorithm pvr2_i2c_algo_template = {
540static struct i2c_adapter pvr2_i2c_adap_template = { 540static struct i2c_adapter pvr2_i2c_adap_template = {
541 .owner = THIS_MODULE, 541 .owner = THIS_MODULE,
542 .class = 0, 542 .class = 0,
543 .id = I2C_HW_B_BT848,
544}; 543};
545 544
546 545
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 8d17cf613306..f976df452a34 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1057,7 +1057,8 @@ static int pwc_create_sysfs_files(struct video_device *vdev)
1057 goto err; 1057 goto err;
1058 if (pdev->features & FEATURE_MOTOR_PANTILT) { 1058 if (pdev->features & FEATURE_MOTOR_PANTILT) {
1059 rc = device_create_file(&vdev->dev, &dev_attr_pan_tilt); 1059 rc = device_create_file(&vdev->dev, &dev_attr_pan_tilt);
1060 if (rc) goto err_button; 1060 if (rc)
1061 goto err_button;
1061 } 1062 }
1062 1063
1063 return 0; 1064 return 0;
@@ -1072,6 +1073,7 @@ err:
1072static void pwc_remove_sysfs_files(struct video_device *vdev) 1073static void pwc_remove_sysfs_files(struct video_device *vdev)
1073{ 1074{
1074 struct pwc_device *pdev = video_get_drvdata(vdev); 1075 struct pwc_device *pdev = video_get_drvdata(vdev);
1076
1075 if (pdev->features & FEATURE_MOTOR_PANTILT) 1077 if (pdev->features & FEATURE_MOTOR_PANTILT)
1076 device_remove_file(&vdev->dev, &dev_attr_pan_tilt); 1078 device_remove_file(&vdev->dev, &dev_attr_pan_tilt);
1077 device_remove_file(&vdev->dev, &dev_attr_button); 1079 device_remove_file(&vdev->dev, &dev_attr_button);
@@ -1229,13 +1231,11 @@ static void pwc_cleanup(struct pwc_device *pdev)
1229 video_unregister_device(pdev->vdev); 1231 video_unregister_device(pdev->vdev);
1230 1232
1231#ifdef CONFIG_USB_PWC_INPUT_EVDEV 1233#ifdef CONFIG_USB_PWC_INPUT_EVDEV
1232 if (pdev->button_dev) { 1234 if (pdev->button_dev)
1233 input_unregister_device(pdev->button_dev); 1235 input_unregister_device(pdev->button_dev);
1234 input_free_device(pdev->button_dev);
1235 kfree(pdev->button_dev->phys);
1236 pdev->button_dev = NULL;
1237 }
1238#endif 1236#endif
1237
1238 kfree(pdev);
1239} 1239}
1240 1240
1241/* Note that all cleanup is done in the reverse order as in _open */ 1241/* Note that all cleanup is done in the reverse order as in _open */
@@ -1281,8 +1281,6 @@ static int pwc_video_close(struct file *file)
1281 PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen); 1281 PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen);
1282 } else { 1282 } else {
1283 pwc_cleanup(pdev); 1283 pwc_cleanup(pdev);
1284 /* Free memory (don't set pdev to 0 just yet) */
1285 kfree(pdev);
1286 /* search device_hint[] table if we occupy a slot, by any chance */ 1284 /* search device_hint[] table if we occupy a slot, by any chance */
1287 for (hint = 0; hint < MAX_DEV_HINTS; hint++) 1285 for (hint = 0; hint < MAX_DEV_HINTS; hint++)
1288 if (device_hint[hint].pdev == pdev) 1286 if (device_hint[hint].pdev == pdev)
@@ -1499,13 +1497,10 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1499 struct usb_device *udev = interface_to_usbdev(intf); 1497 struct usb_device *udev = interface_to_usbdev(intf);
1500 struct pwc_device *pdev = NULL; 1498 struct pwc_device *pdev = NULL;
1501 int vendor_id, product_id, type_id; 1499 int vendor_id, product_id, type_id;
1502 int i, hint, rc; 1500 int hint, rc;
1503 int features = 0; 1501 int features = 0;
1504 int video_nr = -1; /* default: use next available device */ 1502 int video_nr = -1; /* default: use next available device */
1505 char serial_number[30], *name; 1503 char serial_number[30], *name;
1506#ifdef CONFIG_USB_PWC_INPUT_EVDEV
1507 char *phys = NULL;
1508#endif
1509 1504
1510 vendor_id = le16_to_cpu(udev->descriptor.idVendor); 1505 vendor_id = le16_to_cpu(udev->descriptor.idVendor);
1511 product_id = le16_to_cpu(udev->descriptor.idProduct); 1506 product_id = le16_to_cpu(udev->descriptor.idProduct);
@@ -1757,8 +1752,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1757 pdev->vframes = default_fps; 1752 pdev->vframes = default_fps;
1758 strcpy(pdev->serial, serial_number); 1753 strcpy(pdev->serial, serial_number);
1759 pdev->features = features; 1754 pdev->features = features;
1760 if (vendor_id == 0x046D && product_id == 0x08B5) 1755 if (vendor_id == 0x046D && product_id == 0x08B5) {
1761 {
1762 /* Logitech QuickCam Orbit 1756 /* Logitech QuickCam Orbit
1763 The ranges have been determined experimentally; they may differ from cam to cam. 1757 The ranges have been determined experimentally; they may differ from cam to cam.
1764 Also, the exact ranges left-right and up-down are different for my cam 1758 Also, the exact ranges left-right and up-down are different for my cam
@@ -1780,8 +1774,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1780 pdev->vdev = video_device_alloc(); 1774 pdev->vdev = video_device_alloc();
1781 if (!pdev->vdev) { 1775 if (!pdev->vdev) {
1782 PWC_ERROR("Err, cannot allocate video_device struture. Failing probe."); 1776 PWC_ERROR("Err, cannot allocate video_device struture. Failing probe.");
1783 kfree(pdev); 1777 rc = -ENOMEM;
1784 return -ENOMEM; 1778 goto err_free_mem;
1785 } 1779 }
1786 memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template)); 1780 memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template));
1787 pdev->vdev->parent = &intf->dev; 1781 pdev->vdev->parent = &intf->dev;
@@ -1806,25 +1800,23 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1806 } 1800 }
1807 1801
1808 pdev->vdev->release = video_device_release; 1802 pdev->vdev->release = video_device_release;
1809 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); 1803 rc = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
1810 if (i < 0) { 1804 if (rc < 0) {
1811 PWC_ERROR("Failed to register as video device (%d).\n", i); 1805 PWC_ERROR("Failed to register as video device (%d).\n", rc);
1812 rc = i; 1806 goto err_video_release;
1813 goto err;
1814 }
1815 else {
1816 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->num);
1817 } 1807 }
1818 1808
1809 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->num);
1810
1819 /* occupy slot */ 1811 /* occupy slot */
1820 if (hint < MAX_DEV_HINTS) 1812 if (hint < MAX_DEV_HINTS)
1821 device_hint[hint].pdev = pdev; 1813 device_hint[hint].pdev = pdev;
1822 1814
1823 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev); 1815 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev);
1824 usb_set_intfdata (intf, pdev); 1816 usb_set_intfdata(intf, pdev);
1825 rc = pwc_create_sysfs_files(pdev->vdev); 1817 rc = pwc_create_sysfs_files(pdev->vdev);
1826 if (rc) 1818 if (rc)
1827 goto err_unreg; 1819 goto err_video_unreg;
1828 1820
1829 /* Set the leds off */ 1821 /* Set the leds off */
1830 pwc_set_leds(pdev, 0, 0); 1822 pwc_set_leds(pdev, 0, 0);
@@ -1835,16 +1827,16 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1835 pdev->button_dev = input_allocate_device(); 1827 pdev->button_dev = input_allocate_device();
1836 if (!pdev->button_dev) { 1828 if (!pdev->button_dev) {
1837 PWC_ERROR("Err, insufficient memory for webcam snapshot button device."); 1829 PWC_ERROR("Err, insufficient memory for webcam snapshot button device.");
1838 return -ENOMEM; 1830 rc = -ENOMEM;
1831 pwc_remove_sysfs_files(pdev->vdev);
1832 goto err_video_unreg;
1839 } 1833 }
1840 1834
1835 usb_make_path(udev, pdev->button_phys, sizeof(pdev->button_phys));
1836 strlcat(pdev->button_phys, "/input0", sizeof(pdev->button_phys));
1837
1841 pdev->button_dev->name = "PWC snapshot button"; 1838 pdev->button_dev->name = "PWC snapshot button";
1842 phys = kasprintf(GFP_KERNEL,"usb-%s-%s", pdev->udev->bus->bus_name, pdev->udev->devpath); 1839 pdev->button_dev->phys = pdev->button_phys;
1843 if (!phys) {
1844 input_free_device(pdev->button_dev);
1845 return -ENOMEM;
1846 }
1847 pdev->button_dev->phys = phys;
1848 usb_to_input_id(pdev->udev, &pdev->button_dev->id); 1840 usb_to_input_id(pdev->udev, &pdev->button_dev->id);
1849 pdev->button_dev->dev.parent = &pdev->udev->dev; 1841 pdev->button_dev->dev.parent = &pdev->udev->dev;
1850 pdev->button_dev->evbit[0] = BIT_MASK(EV_KEY); 1842 pdev->button_dev->evbit[0] = BIT_MASK(EV_KEY);
@@ -1853,25 +1845,27 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1853 rc = input_register_device(pdev->button_dev); 1845 rc = input_register_device(pdev->button_dev);
1854 if (rc) { 1846 if (rc) {
1855 input_free_device(pdev->button_dev); 1847 input_free_device(pdev->button_dev);
1856 kfree(pdev->button_dev->phys);
1857 pdev->button_dev = NULL; 1848 pdev->button_dev = NULL;
1858 return rc; 1849 pwc_remove_sysfs_files(pdev->vdev);
1850 goto err_video_unreg;
1859 } 1851 }
1860#endif 1852#endif
1861 1853
1862 return 0; 1854 return 0;
1863 1855
1864err_unreg: 1856err_video_unreg:
1865 if (hint < MAX_DEV_HINTS) 1857 if (hint < MAX_DEV_HINTS)
1866 device_hint[hint].pdev = NULL; 1858 device_hint[hint].pdev = NULL;
1867 video_unregister_device(pdev->vdev); 1859 video_unregister_device(pdev->vdev);
1868err: 1860 pdev->vdev = NULL; /* So we don't try to release it below */
1869 video_device_release(pdev->vdev); /* Drip... drip... drip... */ 1861err_video_release:
1870 kfree(pdev); /* Oops, no memory leaks please */ 1862 video_device_release(pdev->vdev);
1863err_free_mem:
1864 kfree(pdev);
1871 return rc; 1865 return rc;
1872} 1866}
1873 1867
1874/* The user janked out the cable... */ 1868/* The user yanked out the cable... */
1875static void usb_pwc_disconnect(struct usb_interface *intf) 1869static void usb_pwc_disconnect(struct usb_interface *intf)
1876{ 1870{
1877 struct pwc_device *pdev; 1871 struct pwc_device *pdev;
@@ -1902,7 +1896,7 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
1902 /* Alert waiting processes */ 1896 /* Alert waiting processes */
1903 wake_up_interruptible(&pdev->frameq); 1897 wake_up_interruptible(&pdev->frameq);
1904 /* Wait until device is closed */ 1898 /* Wait until device is closed */
1905 if(pdev->vopen) { 1899 if (pdev->vopen) {
1906 mutex_lock(&pdev->modlock); 1900 mutex_lock(&pdev->modlock);
1907 pdev->unplugged = 1; 1901 pdev->unplugged = 1;
1908 mutex_unlock(&pdev->modlock); 1902 mutex_unlock(&pdev->modlock);
@@ -1911,8 +1905,6 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
1911 /* Device is closed, so we can safely unregister it */ 1905 /* Device is closed, so we can safely unregister it */
1912 PWC_DEBUG_PROBE("Unregistering video device in disconnect().\n"); 1906 PWC_DEBUG_PROBE("Unregistering video device in disconnect().\n");
1913 pwc_cleanup(pdev); 1907 pwc_cleanup(pdev);
1914 /* Free memory (don't set pdev to 0 just yet) */
1915 kfree(pdev);
1916 1908
1917disconnect_out: 1909disconnect_out:
1918 /* search device_hint[] table if we occupy a slot, by any chance */ 1910 /* search device_hint[] table if we occupy a slot, by any chance */
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index 2876ce084510..bdb4ced57496 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -1033,7 +1033,7 @@ long pwc_video_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1033 if (std->index != 0) 1033 if (std->index != 0)
1034 return -EINVAL; 1034 return -EINVAL;
1035 std->id = V4L2_STD_UNKNOWN; 1035 std->id = V4L2_STD_UNKNOWN;
1036 strncpy(std->name, "webcam", sizeof(std->name)); 1036 strlcpy(std->name, "webcam", sizeof(std->name));
1037 return 0; 1037 return 0;
1038 } 1038 }
1039 1039
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 0b658dee05a4..0902355dfa77 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -135,12 +135,6 @@
135#define DEVICE_USE_CODEC3(x) ((x)>=700) 135#define DEVICE_USE_CODEC3(x) ((x)>=700)
136#define DEVICE_USE_CODEC23(x) ((x)>=675) 136#define DEVICE_USE_CODEC23(x) ((x)>=675)
137 137
138
139#ifndef V4L2_PIX_FMT_PWC1
140#define V4L2_PIX_FMT_PWC1 v4l2_fourcc('P','W','C','1')
141#define V4L2_PIX_FMT_PWC2 v4l2_fourcc('P','W','C','2')
142#endif
143
144/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */ 138/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */
145struct pwc_iso_buf 139struct pwc_iso_buf
146{ 140{
@@ -259,6 +253,7 @@ struct pwc_device
259 int snapshot_button_status; /* set to 1 when the user push the button, reset to 0 when this value is read */ 253 int snapshot_button_status; /* set to 1 when the user push the button, reset to 0 when this value is read */
260#ifdef CONFIG_USB_PWC_INPUT_EVDEV 254#ifdef CONFIG_USB_PWC_INPUT_EVDEV
261 struct input_dev *button_dev; /* webcam snapshot button input */ 255 struct input_dev *button_dev; /* webcam snapshot button input */
256 char button_phys[64];
262#endif 257#endif
263 258
264 /*** Misc. data ***/ 259 /*** Misc. data ***/
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index c25e81af5ce0..c3e96f070973 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -40,7 +40,7 @@
40/* insmod options */ 40/* insmod options */
41static unsigned int debug; 41static unsigned int debug;
42static unsigned int xtal; 42static unsigned int xtal;
43static unsigned int rbds; 43static unsigned int mmbs;
44static unsigned int plvl; 44static unsigned int plvl;
45static unsigned int bufblocks = 100; 45static unsigned int bufblocks = 100;
46 46
@@ -48,8 +48,8 @@ module_param(debug, int, 0644);
48MODULE_PARM_DESC(debug, "enable debug messages"); 48MODULE_PARM_DESC(debug, "enable debug messages");
49module_param(xtal, int, 0); 49module_param(xtal, int, 0);
50MODULE_PARM_DESC(xtal, "select oscillator frequency (0..3), default 0"); 50MODULE_PARM_DESC(xtal, "select oscillator frequency (0..3), default 0");
51module_param(rbds, int, 0); 51module_param(mmbs, int, 0);
52MODULE_PARM_DESC(rbds, "select mode, 0=RDS, 1=RBDS, default 0"); 52MODULE_PARM_DESC(mmbs, "enable MMBS mode: 0=off (default), 1=on");
53module_param(plvl, int, 0); 53module_param(plvl, int, 0);
54MODULE_PARM_DESC(plvl, "select pause level (0..3), default 0"); 54MODULE_PARM_DESC(plvl, "select pause level (0..3), default 0");
55module_param(bufblocks, int, 0); 55module_param(bufblocks, int, 0);
@@ -78,6 +78,7 @@ struct saa6588 {
78 unsigned char last_blocknum; 78 unsigned char last_blocknum;
79 wait_queue_head_t read_queue; 79 wait_queue_head_t read_queue;
80 int data_available_for_read; 80 int data_available_for_read;
81 u8 sync;
81}; 82};
82 83
83static inline struct saa6588 *to_saa6588(struct v4l2_subdev *sd) 84static inline struct saa6588 *to_saa6588(struct v4l2_subdev *sd)
@@ -261,13 +262,16 @@ static void saa6588_i2c_poll(struct saa6588 *s)
261 unsigned char tmp; 262 unsigned char tmp;
262 263
263 /* Although we only need 3 bytes, we have to read at least 6. 264 /* Although we only need 3 bytes, we have to read at least 6.
264 SAA6588 returns garbage otherwise */ 265 SAA6588 returns garbage otherwise. */
265 if (6 != i2c_master_recv(client, &tmpbuf[0], 6)) { 266 if (6 != i2c_master_recv(client, &tmpbuf[0], 6)) {
266 if (debug > 1) 267 if (debug > 1)
267 dprintk(PREFIX "read error!\n"); 268 dprintk(PREFIX "read error!\n");
268 return; 269 return;
269 } 270 }
270 271
272 s->sync = tmpbuf[0] & 0x10;
273 if (!s->sync)
274 return;
271 blocknum = tmpbuf[0] >> 5; 275 blocknum = tmpbuf[0] >> 5;
272 if (blocknum == s->last_blocknum) { 276 if (blocknum == s->last_blocknum) {
273 if (debug > 3) 277 if (debug > 3)
@@ -286,9 +290,8 @@ static void saa6588_i2c_poll(struct saa6588 *s)
286 occurred during reception of this block. 290 occurred during reception of this block.
287 Bit 6: Corrected bit. Indicates that an error was 291 Bit 6: Corrected bit. Indicates that an error was
288 corrected for this data block. 292 corrected for this data block.
289 Bits 5-3: Received Offset. Indicates the offset received 293 Bits 5-3: Same as bits 0-2.
290 by the sync system. 294 Bits 2-0: Block number.
291 Bits 2-0: Offset Name. Indicates the offset applied to this data.
292 295
293 SAA6588 byte order is Status-MSB-LSB, so we have to swap the 296 SAA6588 byte order is Status-MSB-LSB, so we have to swap the
294 first and the last of the 3 bytes block. 297 first and the last of the 3 bytes block.
@@ -298,12 +301,21 @@ static void saa6588_i2c_poll(struct saa6588 *s)
298 tmpbuf[2] = tmpbuf[0]; 301 tmpbuf[2] = tmpbuf[0];
299 tmpbuf[0] = tmp; 302 tmpbuf[0] = tmp;
300 303
304 /* Map 'Invalid block E' to 'Invalid Block' */
305 if (blocknum == 6)
306 blocknum = V4L2_RDS_BLOCK_INVALID;
307 /* And if are not in mmbs mode, then 'Block E' is also mapped
308 to 'Invalid Block'. As far as I can tell MMBS is discontinued,
309 and if there is ever a need to support E blocks, then please
310 contact the linux-media mailinglist. */
311 else if (!mmbs && blocknum == 5)
312 blocknum = V4L2_RDS_BLOCK_INVALID;
301 tmp = blocknum; 313 tmp = blocknum;
302 tmp |= blocknum << 3; /* Received offset == Offset Name (OK ?) */ 314 tmp |= blocknum << 3; /* Received offset == Offset Name (OK ?) */
303 if ((tmpbuf[2] & 0x03) == 0x03) 315 if ((tmpbuf[2] & 0x03) == 0x03)
304 tmp |= 0x80; /* uncorrectable error */ 316 tmp |= V4L2_RDS_BLOCK_ERROR; /* uncorrectable error */
305 else if ((tmpbuf[2] & 0x03) != 0x00) 317 else if ((tmpbuf[2] & 0x03) != 0x00)
306 tmp |= 0x40; /* corrected error */ 318 tmp |= V4L2_RDS_BLOCK_CORRECTED; /* corrected error */
307 tmpbuf[2] = tmp; /* Is this enough ? Should we also check other bits ? */ 319 tmpbuf[2] = tmp; /* Is this enough ? Should we also check other bits ? */
308 320
309 spin_lock_irqsave(&s->lock, flags); 321 spin_lock_irqsave(&s->lock, flags);
@@ -321,14 +333,14 @@ static void saa6588_work(struct work_struct *work)
321 schedule_delayed_work(&s->work, msecs_to_jiffies(20)); 333 schedule_delayed_work(&s->work, msecs_to_jiffies(20));
322} 334}
323 335
324static int saa6588_configure(struct saa6588 *s) 336static void saa6588_configure(struct saa6588 *s)
325{ 337{
326 struct i2c_client *client = v4l2_get_subdevdata(&s->sd); 338 struct i2c_client *client = v4l2_get_subdevdata(&s->sd);
327 unsigned char buf[3]; 339 unsigned char buf[3];
328 int rc; 340 int rc;
329 341
330 buf[0] = cSyncRestart; 342 buf[0] = cSyncRestart;
331 if (rbds) 343 if (mmbs)
332 buf[0] |= cProcessingModeRBDS; 344 buf[0] |= cProcessingModeRBDS;
333 345
334 buf[1] = cFlywheelDefault; 346 buf[1] = cFlywheelDefault;
@@ -374,8 +386,6 @@ static int saa6588_configure(struct saa6588 *s)
374 rc = i2c_master_send(client, buf, 3); 386 rc = i2c_master_send(client, buf, 3);
375 if (rc != 3) 387 if (rc != 3)
376 printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc); 388 printk(PREFIX "i2c i/o error: rc == %d (should be 3)\n", rc);
377
378 return 0;
379} 389}
380 390
381/* ---------------------------------------------------------------------- */ 391/* ---------------------------------------------------------------------- */
@@ -416,6 +426,24 @@ static long saa6588_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
416 return 0; 426 return 0;
417} 427}
418 428
429static int saa6588_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
430{
431 struct saa6588 *s = to_saa6588(sd);
432
433 vt->capability |= V4L2_TUNER_CAP_RDS;
434 if (s->sync)
435 vt->rxsubchans |= V4L2_TUNER_SUB_RDS;
436 return 0;
437}
438
439static int saa6588_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
440{
441 struct saa6588 *s = to_saa6588(sd);
442
443 saa6588_configure(s);
444 return 0;
445}
446
419static int saa6588_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip) 447static int saa6588_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
420{ 448{
421 struct i2c_client *client = v4l2_get_subdevdata(sd); 449 struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -430,8 +458,14 @@ static const struct v4l2_subdev_core_ops saa6588_core_ops = {
430 .ioctl = saa6588_ioctl, 458 .ioctl = saa6588_ioctl,
431}; 459};
432 460
461static const struct v4l2_subdev_tuner_ops saa6588_tuner_ops = {
462 .g_tuner = saa6588_g_tuner,
463 .s_tuner = saa6588_s_tuner,
464};
465
433static const struct v4l2_subdev_ops saa6588_ops = { 466static const struct v4l2_subdev_ops saa6588_ops = {
434 .core = &saa6588_core_ops, 467 .core = &saa6588_core_ops,
468 .tuner = &saa6588_tuner_ops,
435}; 469};
436 470
437/* ---------------------------------------------------------------------- */ 471/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 5bcce092e804..22bfd62c9551 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -47,6 +47,7 @@ config VIDEO_SAA7134_DVB
47 select DVB_TDA10048 if !DVB_FE_CUSTOMISE 47 select DVB_TDA10048 if !DVB_FE_CUSTOMISE
48 select MEDIA_TUNER_TDA18271 if !MEDIA_TUNER_CUSTOMISE 48 select MEDIA_TUNER_TDA18271 if !MEDIA_TUNER_CUSTOMISE
49 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE 49 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE
50 select DVB_ZL10039 if !DVB_FE_CUSTOMISE
50 ---help--- 51 ---help---
51 This adds support for DVB cards based on the 52 This adds support for DVB cards based on the
52 Philips saa7134 chip. 53 Philips saa7134 chip.
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 63c4b8f1f541..1eabff6b2456 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -468,7 +468,7 @@ static int handle_ctrl(int has_ac3, struct saa6752hs_mpeg_params *params,
468 if (set && new != V4L2_MPEG_AUDIO_ENCODING_LAYER_2 && 468 if (set && new != V4L2_MPEG_AUDIO_ENCODING_LAYER_2 &&
469 (!has_ac3 || new != V4L2_MPEG_AUDIO_ENCODING_AC3)) 469 (!has_ac3 || new != V4L2_MPEG_AUDIO_ENCODING_AC3))
470 return -ERANGE; 470 return -ERANGE;
471 new = old; 471 params->au_encoding = new;
472 break; 472 break;
473 case V4L2_CID_MPEG_AUDIO_L2_BITRATE: 473 case V4L2_CID_MPEG_AUDIO_L2_BITRATE:
474 old = params->au_l2_bitrate; 474 old = params->au_l2_bitrate;
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 8b0b64a89874..d48c450ed77c 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -40,6 +40,7 @@ MODULE_PARM_DESC(debug,"enable debug messages [alsa]");
40 */ 40 */
41 41
42/* defaults */ 42/* defaults */
43#define MIXER_ADDR_UNSELECTED -1
43#define MIXER_ADDR_TVTUNER 0 44#define MIXER_ADDR_TVTUNER 0
44#define MIXER_ADDR_LINE1 1 45#define MIXER_ADDR_LINE1 1
45#define MIXER_ADDR_LINE2 2 46#define MIXER_ADDR_LINE2 2
@@ -68,7 +69,9 @@ typedef struct snd_card_saa7134 {
68 struct snd_card *card; 69 struct snd_card *card;
69 spinlock_t mixer_lock; 70 spinlock_t mixer_lock;
70 int mixer_volume[MIXER_ADDR_LAST+1][2]; 71 int mixer_volume[MIXER_ADDR_LAST+1][2];
71 int capture_source[MIXER_ADDR_LAST+1][2]; 72 int capture_source_addr;
73 int capture_source[2];
74 struct snd_kcontrol *capture_ctl[MIXER_ADDR_LAST+1];
72 struct pci_dev *pci; 75 struct pci_dev *pci;
73 struct saa7134_dev *dev; 76 struct saa7134_dev *dev;
74 77
@@ -314,6 +317,115 @@ static int dsp_buffer_free(struct saa7134_dev *dev)
314 return 0; 317 return 0;
315} 318}
316 319
320/*
321 * Setting the capture source and updating the ALSA controls
322 */
323static int snd_saa7134_capsrc_set(struct snd_kcontrol *kcontrol,
324 int left, int right, bool force_notify)
325{
326 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
327 int change = 0, addr = kcontrol->private_value;
328 int active, old_addr;
329 u32 anabar, xbarin;
330 int analog_io, rate;
331 struct saa7134_dev *dev;
332
333 dev = chip->dev;
334
335 spin_lock_irq(&chip->mixer_lock);
336
337 active = left != 0 || right != 0;
338 old_addr = chip->capture_source_addr;
339
340 /* The active capture source cannot be deactivated */
341 if (active) {
342 change = old_addr != addr ||
343 chip->capture_source[0] != left ||
344 chip->capture_source[1] != right;
345
346 chip->capture_source[0] = left;
347 chip->capture_source[1] = right;
348 chip->capture_source_addr = addr;
349 dev->dmasound.input = addr;
350 }
351 spin_unlock_irq(&chip->mixer_lock);
352
353 if (change) {
354 switch (dev->pci->device) {
355
356 case PCI_DEVICE_ID_PHILIPS_SAA7134:
357 switch (addr) {
358 case MIXER_ADDR_TVTUNER:
359 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL,
360 0xc0, 0xc0);
361 saa_andorb(SAA7134_SIF_SAMPLE_FREQ,
362 0x03, 0x00);
363 break;
364 case MIXER_ADDR_LINE1:
365 case MIXER_ADDR_LINE2:
366 analog_io = (MIXER_ADDR_LINE1 == addr) ?
367 0x00 : 0x08;
368 rate = (32000 == dev->dmasound.rate) ?
369 0x01 : 0x03;
370 saa_andorb(SAA7134_ANALOG_IO_SELECT,
371 0x08, analog_io);
372 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL,
373 0xc0, 0x80);
374 saa_andorb(SAA7134_SIF_SAMPLE_FREQ,
375 0x03, rate);
376 break;
377 }
378
379 break;
380 case PCI_DEVICE_ID_PHILIPS_SAA7133:
381 case PCI_DEVICE_ID_PHILIPS_SAA7135:
382 xbarin = 0x03; /* adc */
383 anabar = 0;
384 switch (addr) {
385 case MIXER_ADDR_TVTUNER:
386 xbarin = 0; /* Demodulator */
387 anabar = 2; /* DACs */
388 break;
389 case MIXER_ADDR_LINE1:
390 anabar = 0; /* aux1, aux1 */
391 break;
392 case MIXER_ADDR_LINE2:
393 anabar = 9; /* aux2, aux2 */
394 break;
395 }
396
397 /* output xbar always main channel */
398 saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1,
399 0xbbbb10);
400
401 if (left || right) {
402 /* We've got data, turn the input on */
403 saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1,
404 xbarin);
405 saa_writel(SAA7133_ANALOG_IO_SELECT, anabar);
406 } else {
407 saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1,
408 0);
409 saa_writel(SAA7133_ANALOG_IO_SELECT, 0);
410 }
411 break;
412 }
413 }
414
415 if (change) {
416 if (force_notify)
417 snd_ctl_notify(chip->card,
418 SNDRV_CTL_EVENT_MASK_VALUE,
419 &chip->capture_ctl[addr]->id);
420
421 if (old_addr != MIXER_ADDR_UNSELECTED && old_addr != addr)
422 snd_ctl_notify(chip->card,
423 SNDRV_CTL_EVENT_MASK_VALUE,
424 &chip->capture_ctl[old_addr]->id);
425 }
426
427 return change;
428}
317 429
318/* 430/*
319 * ALSA PCM preparation 431 * ALSA PCM preparation
@@ -401,6 +513,10 @@ static int snd_card_saa7134_capture_prepare(struct snd_pcm_substream * substream
401 513
402 dev->dmasound.rate = runtime->rate; 514 dev->dmasound.rate = runtime->rate;
403 515
516 /* Setup and update the card/ALSA controls */
517 snd_saa7134_capsrc_set(saa7134->capture_ctl[dev->dmasound.input], 1, 1,
518 true);
519
404 return 0; 520 return 0;
405 521
406} 522}
@@ -435,6 +551,16 @@ snd_card_saa7134_capture_pointer(struct snd_pcm_substream * substream)
435 551
436/* 552/*
437 * ALSA hardware capabilities definition 553 * ALSA hardware capabilities definition
554 *
555 * Report only 32kHz for ALSA:
556 *
557 * - SAA7133/35 uses DDEP (DemDec Easy Programming mode), which works in 32kHz
558 * only
559 * - SAA7134 for TV mode uses DemDec mode (32kHz)
560 * - Radio works in 32kHz only
561 * - When recording 48kHz from Line1/Line2, switching of capture source to TV
562 * means
563 * switching to 32kHz without any frequency translation
438 */ 564 */
439 565
440static struct snd_pcm_hardware snd_card_saa7134_capture = 566static struct snd_pcm_hardware snd_card_saa7134_capture =
@@ -448,9 +574,9 @@ static struct snd_pcm_hardware snd_card_saa7134_capture =
448 SNDRV_PCM_FMTBIT_U8 | \ 574 SNDRV_PCM_FMTBIT_U8 | \
449 SNDRV_PCM_FMTBIT_U16_LE | \ 575 SNDRV_PCM_FMTBIT_U16_LE | \
450 SNDRV_PCM_FMTBIT_U16_BE, 576 SNDRV_PCM_FMTBIT_U16_BE,
451 .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000, 577 .rates = SNDRV_PCM_RATE_32000,
452 .rate_min = 32000, 578 .rate_min = 32000,
453 .rate_max = 48000, 579 .rate_max = 32000,
454 .channels_min = 1, 580 .channels_min = 1,
455 .channels_max = 2, 581 .channels_max = 2,
456 .buffer_bytes_max = (256*1024), 582 .buffer_bytes_max = (256*1024),
@@ -836,8 +962,13 @@ static int snd_saa7134_capsrc_get(struct snd_kcontrol * kcontrol,
836 int addr = kcontrol->private_value; 962 int addr = kcontrol->private_value;
837 963
838 spin_lock_irq(&chip->mixer_lock); 964 spin_lock_irq(&chip->mixer_lock);
839 ucontrol->value.integer.value[0] = chip->capture_source[addr][0]; 965 if (chip->capture_source_addr == addr) {
840 ucontrol->value.integer.value[1] = chip->capture_source[addr][1]; 966 ucontrol->value.integer.value[0] = chip->capture_source[0];
967 ucontrol->value.integer.value[1] = chip->capture_source[1];
968 } else {
969 ucontrol->value.integer.value[0] = 0;
970 ucontrol->value.integer.value[1] = 0;
971 }
841 spin_unlock_irq(&chip->mixer_lock); 972 spin_unlock_irq(&chip->mixer_lock);
842 973
843 return 0; 974 return 0;
@@ -846,87 +977,22 @@ static int snd_saa7134_capsrc_get(struct snd_kcontrol * kcontrol,
846static int snd_saa7134_capsrc_put(struct snd_kcontrol * kcontrol, 977static int snd_saa7134_capsrc_put(struct snd_kcontrol * kcontrol,
847 struct snd_ctl_elem_value * ucontrol) 978 struct snd_ctl_elem_value * ucontrol)
848{ 979{
849 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
850 int change, addr = kcontrol->private_value;
851 int left, right; 980 int left, right;
852 u32 anabar, xbarin;
853 int analog_io, rate;
854 struct saa7134_dev *dev;
855
856 dev = chip->dev;
857
858 left = ucontrol->value.integer.value[0] & 1; 981 left = ucontrol->value.integer.value[0] & 1;
859 right = ucontrol->value.integer.value[1] & 1; 982 right = ucontrol->value.integer.value[1] & 1;
860 spin_lock_irq(&chip->mixer_lock);
861
862 change = chip->capture_source[addr][0] != left ||
863 chip->capture_source[addr][1] != right;
864 chip->capture_source[addr][0] = left;
865 chip->capture_source[addr][1] = right;
866 dev->dmasound.input=addr;
867 spin_unlock_irq(&chip->mixer_lock);
868
869
870 if (change) {
871 switch (dev->pci->device) {
872
873 case PCI_DEVICE_ID_PHILIPS_SAA7134:
874 switch (addr) {
875 case MIXER_ADDR_TVTUNER:
876 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0);
877 saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00);
878 break;
879 case MIXER_ADDR_LINE1:
880 case MIXER_ADDR_LINE2:
881 analog_io = (MIXER_ADDR_LINE1 == addr) ? 0x00 : 0x08;
882 rate = (32000 == dev->dmasound.rate) ? 0x01 : 0x03;
883 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io);
884 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80);
885 saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate);
886 break;
887 }
888
889 break;
890 case PCI_DEVICE_ID_PHILIPS_SAA7133:
891 case PCI_DEVICE_ID_PHILIPS_SAA7135:
892 xbarin = 0x03; // adc
893 anabar = 0;
894 switch (addr) {
895 case MIXER_ADDR_TVTUNER:
896 xbarin = 0; // Demodulator
897 anabar = 2; // DACs
898 break;
899 case MIXER_ADDR_LINE1:
900 anabar = 0; // aux1, aux1
901 break;
902 case MIXER_ADDR_LINE2:
903 anabar = 9; // aux2, aux2
904 break;
905 }
906
907 /* output xbar always main channel */
908 saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10);
909 983
910 if (left || right) { // We've got data, turn the input on 984 return snd_saa7134_capsrc_set(kcontrol, left, right, false);
911 saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin);
912 saa_writel(SAA7133_ANALOG_IO_SELECT, anabar);
913 } else {
914 saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0);
915 saa_writel(SAA7133_ANALOG_IO_SELECT, 0);
916 }
917 break;
918 }
919 }
920
921 return change;
922} 985}
923 986
924static struct snd_kcontrol_new snd_saa7134_controls[] = { 987static struct snd_kcontrol_new snd_saa7134_volume_controls[] = {
925SAA713x_VOLUME("Video Volume", 0, MIXER_ADDR_TVTUNER), 988SAA713x_VOLUME("Video Volume", 0, MIXER_ADDR_TVTUNER),
926SAA713x_CAPSRC("Video Capture Switch", 0, MIXER_ADDR_TVTUNER),
927SAA713x_VOLUME("Line Volume", 1, MIXER_ADDR_LINE1), 989SAA713x_VOLUME("Line Volume", 1, MIXER_ADDR_LINE1),
928SAA713x_CAPSRC("Line Capture Switch", 1, MIXER_ADDR_LINE1),
929SAA713x_VOLUME("Line Volume", 2, MIXER_ADDR_LINE2), 990SAA713x_VOLUME("Line Volume", 2, MIXER_ADDR_LINE2),
991};
992
993static struct snd_kcontrol_new snd_saa7134_capture_controls[] = {
994SAA713x_CAPSRC("Video Capture Switch", 0, MIXER_ADDR_TVTUNER),
995SAA713x_CAPSRC("Line Capture Switch", 1, MIXER_ADDR_LINE1),
930SAA713x_CAPSRC("Line Capture Switch", 2, MIXER_ADDR_LINE2), 996SAA713x_CAPSRC("Line Capture Switch", 2, MIXER_ADDR_LINE2),
931}; 997};
932 998
@@ -941,17 +1007,33 @@ SAA713x_CAPSRC("Line Capture Switch", 2, MIXER_ADDR_LINE2),
941static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) 1007static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
942{ 1008{
943 struct snd_card *card = chip->card; 1009 struct snd_card *card = chip->card;
1010 struct snd_kcontrol *kcontrol;
944 unsigned int idx; 1011 unsigned int idx;
945 int err; 1012 int err, addr;
946 1013
947 if (snd_BUG_ON(!chip)) 1014 if (snd_BUG_ON(!chip))
948 return -EINVAL; 1015 return -EINVAL;
949 strcpy(card->mixername, "SAA7134 Mixer"); 1016 strcpy(card->mixername, "SAA7134 Mixer");
950 1017
951 for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_controls); idx++) { 1018 for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_volume_controls); idx++) {
952 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_saa7134_controls[idx], chip))) < 0) 1019 kcontrol = snd_ctl_new1(&snd_saa7134_volume_controls[idx],
1020 chip);
1021 err = snd_ctl_add(card, kcontrol);
1022 if (err < 0)
953 return err; 1023 return err;
954 } 1024 }
1025
1026 for (idx = 0; idx < ARRAY_SIZE(snd_saa7134_capture_controls); idx++) {
1027 kcontrol = snd_ctl_new1(&snd_saa7134_capture_controls[idx],
1028 chip);
1029 addr = snd_saa7134_capture_controls[idx].private_value;
1030 chip->capture_ctl[addr] = kcontrol;
1031 err = snd_ctl_add(card, kcontrol);
1032 if (err < 0)
1033 return err;
1034 }
1035
1036 chip->capture_source_addr = MIXER_ADDR_UNSELECTED;
955 return 0; 1037 return 0;
956} 1038}
957 1039
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 6eebe3ef97d3..1b29487fd254 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -32,6 +32,7 @@
32#include <media/tveeprom.h> 32#include <media/tveeprom.h>
33#include "tea5767.h" 33#include "tea5767.h"
34#include "tda18271.h" 34#include "tda18271.h"
35#include "xc5000.h"
35 36
36/* commly used strings */ 37/* commly used strings */
37static char name_mute[] = "mute"; 38static char name_mute[] = "mute";
@@ -265,6 +266,56 @@ struct saa7134_board saa7134_boards[] = {
265 .gpio = 0x10000, 266 .gpio = 0x10000,
266 }, 267 },
267 }, 268 },
269 [SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM] = {
270 /* RoverMedia TV Link Pro FM (LR138 REV:I) */
271 /* Eugene Yudin <Eugene.Yudin@gmail.com> */
272 .name = "RoverMedia TV Link Pro FM",
273 .audio_clock = 0x00200000,
274 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* TCL MFPE05 2 */
275 .radio_type = UNSET,
276 .tuner_addr = ADDR_UNSET,
277 .radio_addr = ADDR_UNSET,
278 .tda9887_conf = TDA9887_PRESENT,
279 .gpiomask = 0xe000,
280 .inputs = { {
281 .name = name_tv,
282 .vmux = 1,
283 .amux = TV,
284 .gpio = 0x8000,
285 .tv = 1,
286 }, {
287 .name = name_tv_mono,
288 .vmux = 1,
289 .amux = LINE2,
290 .gpio = 0x0000,
291 .tv = 1,
292 }, {
293 .name = name_comp1,
294 .vmux = 0,
295 .amux = LINE2,
296 .gpio = 0x4000,
297 }, {
298 .name = name_comp2,
299 .vmux = 3,
300 .amux = LINE2,
301 .gpio = 0x4000,
302 }, {
303 .name = name_svideo,
304 .vmux = 8,
305 .amux = LINE2,
306 .gpio = 0x4000,
307 } },
308 .radio = {
309 .name = name_radio,
310 .amux = LINE2,
311 .gpio = 0x2000,
312 },
313 .mute = {
314 .name = name_mute,
315 .amux = TV,
316 .gpio = 0x8000,
317 },
318 },
268 [SAA7134_BOARD_EMPRESS] = { 319 [SAA7134_BOARD_EMPRESS] = {
269 /* "Gert Vervoort" <gert.vervoort@philips.com> */ 320 /* "Gert Vervoort" <gert.vervoort@philips.com> */
270 .name = "EMPRESS", 321 .name = "EMPRESS",
@@ -1364,6 +1415,42 @@ struct saa7134_board saa7134_boards[] = {
1364 .amux = LINE1, 1415 .amux = LINE1,
1365 }, 1416 },
1366 }, 1417 },
1418 [SAA7134_BOARD_AVERMEDIA_STUDIO_505] = {
1419 /* Vasiliy Temnikov <vaka@newmail.ru> */
1420 .name = "AverMedia AverTV Studio 505",
1421 .audio_clock = 0x00187de7,
1422 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
1423 .radio_type = UNSET,
1424 .tuner_addr = ADDR_UNSET,
1425 .radio_addr = ADDR_UNSET,
1426 .tda9887_conf = TDA9887_PRESENT,
1427 .inputs = { {
1428 .name = name_tv,
1429 .vmux = 1,
1430 .amux = LINE2,
1431 .tv = 1,
1432 }, {
1433 .name = name_comp1,
1434 .vmux = 0,
1435 .amux = LINE2,
1436 }, {
1437 .name = name_comp2,
1438 .vmux = 3,
1439 .amux = LINE2,
1440 },{
1441 .name = name_svideo,
1442 .vmux = 8,
1443 .amux = LINE2,
1444 } },
1445 .radio = {
1446 .name = name_radio,
1447 .amux = LINE2,
1448 },
1449 .mute = {
1450 .name = name_mute,
1451 .amux = LINE1,
1452 },
1453 },
1367 [SAA7134_BOARD_UPMOST_PURPLE_TV] = { 1454 [SAA7134_BOARD_UPMOST_PURPLE_TV] = {
1368 .name = "UPMOST PURPLE TV", 1455 .name = "UPMOST PURPLE TV",
1369 .audio_clock = 0x00187de7, 1456 .audio_clock = 0x00187de7,
@@ -1633,7 +1720,7 @@ struct saa7134_board saa7134_boards[] = {
1633 }}, 1720 }},
1634 .radio = { 1721 .radio = {
1635 .name = name_radio, 1722 .name = name_radio,
1636 .amux = LINE1, 1723 .amux = TV,
1637 .gpio = 0x00300001, 1724 .gpio = 0x00300001,
1638 }, 1725 },
1639 .mute = { 1726 .mute = {
@@ -3663,8 +3750,8 @@ struct saa7134_board saa7134_boards[] = {
3663 .amux = TV, 3750 .amux = TV,
3664 .gpio = 0x0200000, 3751 .gpio = 0x0200000,
3665 }, 3752 },
3666 }, 3753 },
3667 [SAA7134_BOARD_ASUSTeK_P7131_ANALOG] = { 3754 [SAA7134_BOARD_ASUSTeK_P7131_ANALOG] = {
3668 .name = "ASUSTeK P7131 Analog", 3755 .name = "ASUSTeK P7131 Analog",
3669 .audio_clock = 0x00187de7, 3756 .audio_clock = 0x00187de7,
3670 .tuner_type = TUNER_PHILIPS_TDA8290, 3757 .tuner_type = TUNER_PHILIPS_TDA8290,
@@ -4081,6 +4168,7 @@ struct saa7134_board saa7134_boards[] = {
4081 .radio_type = UNSET, 4168 .radio_type = UNSET,
4082 .tuner_addr = ADDR_UNSET, 4169 .tuner_addr = ADDR_UNSET,
4083 .radio_addr = ADDR_UNSET, 4170 .radio_addr = ADDR_UNSET,
4171 .rds_addr = 0x10,
4084 .tda9887_conf = TDA9887_PRESENT, 4172 .tda9887_conf = TDA9887_PRESENT,
4085 .gpiomask = 0x00008000, 4173 .gpiomask = 0x00008000,
4086 .inputs = {{ 4174 .inputs = {{
@@ -4145,6 +4233,7 @@ struct saa7134_board saa7134_boards[] = {
4145 .radio_type = UNSET, 4233 .radio_type = UNSET,
4146 .tuner_addr = ADDR_UNSET, 4234 .tuner_addr = ADDR_UNSET,
4147 .radio_addr = ADDR_UNSET, 4235 .radio_addr = ADDR_UNSET,
4236 .rds_addr = 0x10,
4148 .tda9887_conf = TDA9887_PRESENT, 4237 .tda9887_conf = TDA9887_PRESENT,
4149 .gpiomask = 0x00008000, 4238 .gpiomask = 0x00008000,
4150 .inputs = {{ 4239 .inputs = {{
@@ -4175,6 +4264,7 @@ struct saa7134_board saa7134_boards[] = {
4175 .radio_type = UNSET, 4264 .radio_type = UNSET,
4176 .tuner_addr = ADDR_UNSET, 4265 .tuner_addr = ADDR_UNSET,
4177 .radio_addr = ADDR_UNSET, 4266 .radio_addr = ADDR_UNSET,
4267 .rds_addr = 0x10,
4178 .tda9887_conf = TDA9887_PRESENT, 4268 .tda9887_conf = TDA9887_PRESENT,
4179 .gpiomask = 0x00008000, 4269 .gpiomask = 0x00008000,
4180 .inputs = {{ 4270 .inputs = {{
@@ -4350,6 +4440,7 @@ struct saa7134_board saa7134_boards[] = {
4350 .radio_type = UNSET, 4440 .radio_type = UNSET,
4351 .tuner_addr = ADDR_UNSET, 4441 .tuner_addr = ADDR_UNSET,
4352 .radio_addr = ADDR_UNSET, 4442 .radio_addr = ADDR_UNSET,
4443 .rds_addr = 0x10,
4353 .tda9887_conf = TDA9887_PRESENT, 4444 .tda9887_conf = TDA9887_PRESENT,
4354 .inputs = {{ 4445 .inputs = {{
4355 .name = name_tv, 4446 .name = name_tv,
@@ -4378,6 +4469,7 @@ struct saa7134_board saa7134_boards[] = {
4378 .radio_type = UNSET, 4469 .radio_type = UNSET,
4379 .tuner_addr = ADDR_UNSET, 4470 .tuner_addr = ADDR_UNSET,
4380 .radio_addr = ADDR_UNSET, 4471 .radio_addr = ADDR_UNSET,
4472 .rds_addr = 0x10,
4381 .tda9887_conf = TDA9887_PRESENT, 4473 .tda9887_conf = TDA9887_PRESENT,
4382 .inputs = {{ 4474 .inputs = {{
4383 .name = name_tv, 4475 .name = name_tv,
@@ -4406,6 +4498,7 @@ struct saa7134_board saa7134_boards[] = {
4406 .radio_type = UNSET, 4498 .radio_type = UNSET,
4407 .tuner_addr = ADDR_UNSET, 4499 .tuner_addr = ADDR_UNSET,
4408 .radio_addr = ADDR_UNSET, 4500 .radio_addr = ADDR_UNSET,
4501 .rds_addr = 0x10,
4409 .tda9887_conf = TDA9887_PRESENT, 4502 .tda9887_conf = TDA9887_PRESENT,
4410 .inputs = {{ 4503 .inputs = {{
4411 .name = name_tv, 4504 .name = name_tv,
@@ -4434,6 +4527,7 @@ struct saa7134_board saa7134_boards[] = {
4434 .radio_type = UNSET, 4527 .radio_type = UNSET,
4435 .tuner_addr = ADDR_UNSET, 4528 .tuner_addr = ADDR_UNSET,
4436 .radio_addr = ADDR_UNSET, 4529 .radio_addr = ADDR_UNSET,
4530 .rds_addr = 0x10,
4437 .tda9887_conf = TDA9887_PRESENT, 4531 .tda9887_conf = TDA9887_PRESENT,
4438 .inputs = {{ 4532 .inputs = {{
4439 .name = name_tv, 4533 .name = name_tv,
@@ -4540,6 +4634,7 @@ struct saa7134_board saa7134_boards[] = {
4540 .radio_type = UNSET, 4634 .radio_type = UNSET,
4541 .tuner_addr = ADDR_UNSET, 4635 .tuner_addr = ADDR_UNSET,
4542 .radio_addr = ADDR_UNSET, 4636 .radio_addr = ADDR_UNSET,
4637 .rds_addr = 0x10,
4543 .empress_addr = 0x20, 4638 .empress_addr = 0x20,
4544 .tda9887_conf = TDA9887_PRESENT, 4639 .tda9887_conf = TDA9887_PRESENT,
4545 .inputs = { { 4640 .inputs = { {
@@ -4861,7 +4956,7 @@ struct saa7134_board saa7134_boards[] = {
4861 /* Igor Kuznetsov <igk@igk.ru> */ 4956 /* Igor Kuznetsov <igk@igk.ru> */
4862 .name = "Beholder BeholdTV H6", 4957 .name = "Beholder BeholdTV H6",
4863 .audio_clock = 0x00187de7, 4958 .audio_clock = 0x00187de7,
4864 .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, 4959 .tuner_type = TUNER_PHILIPS_FMD1216MEX_MK3,
4865 .radio_type = UNSET, 4960 .radio_type = UNSET,
4866 .tuner_addr = ADDR_UNSET, 4961 .tuner_addr = ADDR_UNSET,
4867 .radio_addr = ADDR_UNSET, 4962 .radio_addr = ADDR_UNSET,
@@ -5116,6 +5211,53 @@ struct saa7134_board saa7134_boards[] = {
5116 .gpio = 0x00, 5211 .gpio = 0x00,
5117 }, 5212 },
5118 }, 5213 },
5214 [SAA7134_BOARD_VIDEOMATE_S350] = {
5215 /* Jan D. Louw <jd.louw@mweb.co.za */
5216 .name = "Compro VideoMate S350/S300",
5217 .audio_clock = 0x00187de7,
5218 .tuner_type = TUNER_ABSENT,
5219 .radio_type = UNSET,
5220 .tuner_addr = ADDR_UNSET,
5221 .radio_addr = ADDR_UNSET,
5222 .mpeg = SAA7134_MPEG_DVB,
5223 .inputs = { {
5224 .name = name_comp1,
5225 .vmux = 0,
5226 .amux = LINE1,
5227 }, {
5228 .name = name_svideo,
5229 .vmux = 8, /* Not tested */
5230 .amux = LINE1
5231 } },
5232 },
5233 [SAA7134_BOARD_BEHOLD_X7] = {
5234 /* Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com> */
5235 .name = "Beholder BeholdTV X7",
5236 .audio_clock = 0x00187de7,
5237 .tuner_type = TUNER_XC5000,
5238 .radio_type = UNSET,
5239 .tuner_addr = ADDR_UNSET,
5240 .radio_addr = ADDR_UNSET,
5241 .inputs = { {
5242 .name = name_tv,
5243 .vmux = 2,
5244 .amux = TV,
5245 .tv = 1,
5246 }, {
5247 .name = name_comp1,
5248 .vmux = 0,
5249 .amux = LINE1,
5250 }, {
5251 .name = name_svideo,
5252 .vmux = 9,
5253 .amux = LINE1,
5254 } },
5255 .radio = {
5256 .name = name_radio,
5257 .amux = TV,
5258 },
5259 },
5260
5119}; 5261};
5120 5262
5121const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 5263const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -5374,6 +5516,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
5374 .vendor = PCI_VENDOR_ID_PHILIPS, 5516 .vendor = PCI_VENDOR_ID_PHILIPS,
5375 .device = PCI_DEVICE_ID_PHILIPS_SAA7130, 5517 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
5376 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 5518 .subvendor = 0x1461, /* Avermedia Technologies Inc */
5519 .subdevice = 0xa115,
5520 .driver_data = SAA7134_BOARD_AVERMEDIA_STUDIO_505,
5521 }, {
5522 .vendor = PCI_VENDOR_ID_PHILIPS,
5523 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
5524 .subvendor = 0x1461, /* Avermedia Technologies Inc */
5377 .subdevice = 0x2108, 5525 .subdevice = 0x2108,
5378 .driver_data = SAA7134_BOARD_AVERMEDIA_305, 5526 .driver_data = SAA7134_BOARD_AVERMEDIA_305,
5379 },{ 5527 },{
@@ -6223,7 +6371,24 @@ struct pci_device_id saa7134_pci_tbl[] = {
6223 .subvendor = 0x1461, /* Avermedia Technologies Inc */ 6371 .subvendor = 0x1461, /* Avermedia Technologies Inc */
6224 .subdevice = 0xf31d, 6372 .subdevice = 0xf31d,
6225 .driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS, 6373 .driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS,
6226 6374 }, {
6375 .vendor = PCI_VENDOR_ID_PHILIPS,
6376 .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
6377 .subvendor = 0x185b,
6378 .subdevice = 0xc900,
6379 .driver_data = SAA7134_BOARD_VIDEOMATE_S350,
6380 }, {
6381 .vendor = PCI_VENDOR_ID_PHILIPS,
6382 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
6383 .subvendor = 0x5ace, /* Beholder Intl. Ltd. */
6384 .subdevice = 0x7595,
6385 .driver_data = SAA7134_BOARD_BEHOLD_X7,
6386 }, {
6387 .vendor = PCI_VENDOR_ID_PHILIPS,
6388 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
6389 .subvendor = 0x19d1, /* RoverMedia */
6390 .subdevice = 0x0138, /* LifeView FlyTV Prime30 OEM */
6391 .driver_data = SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM,
6227 }, { 6392 }, {
6228 /* --- boards without eeprom + subsystem ID --- */ 6393 /* --- boards without eeprom + subsystem ID --- */
6229 .vendor = PCI_VENDOR_ID_PHILIPS, 6394 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -6310,6 +6475,32 @@ static int saa7134_xc2028_callback(struct saa7134_dev *dev,
6310 return -EINVAL; 6475 return -EINVAL;
6311} 6476}
6312 6477
6478static int saa7134_xc5000_callback(struct saa7134_dev *dev,
6479 int command, int arg)
6480{
6481 switch (dev->board) {
6482 case SAA7134_BOARD_BEHOLD_X7:
6483 if (command == XC5000_TUNER_RESET) {
6484 /* Down and UP pheripherial RESET pin for reset all chips */
6485 saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
6486 msleep(10);
6487 saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
6488 msleep(10);
6489 }
6490 break;
6491 default:
6492 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0x06e20000);
6493 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0x06a20000);
6494 saa_andorl(SAA7133_ANALOG_IO_SELECT >> 2, 0x02, 0x02);
6495 saa_andorl(SAA7134_ANALOG_IN_CTRL1 >> 2, 0x81, 0x81);
6496 saa_andorl(SAA7134_AUDIO_CLOCK0 >> 2, 0x03187de7, 0x03187de7);
6497 saa_andorl(SAA7134_AUDIO_PLL_CTRL >> 2, 0x03, 0x03);
6498 saa_andorl(SAA7134_AUDIO_CLOCKS_PER_FIELD0 >> 2,
6499 0x0001e000, 0x0001e000);
6500 break;
6501 }
6502 return 0;
6503}
6313 6504
6314static int saa7134_tda8290_827x_callback(struct saa7134_dev *dev, 6505static int saa7134_tda8290_827x_callback(struct saa7134_dev *dev,
6315 int command, int arg) 6506 int command, int arg)
@@ -6406,6 +6597,8 @@ int saa7134_tuner_callback(void *priv, int component, int command, int arg)
6406 return saa7134_tda8290_callback(dev, command, arg); 6597 return saa7134_tda8290_callback(dev, command, arg);
6407 case TUNER_XC2028: 6598 case TUNER_XC2028:
6408 return saa7134_xc2028_callback(dev, command, arg); 6599 return saa7134_xc2028_callback(dev, command, arg);
6600 case TUNER_XC5000:
6601 return saa7134_xc5000_callback(dev, command, arg);
6409 } 6602 }
6410 } else { 6603 } else {
6411 printk(KERN_ERR "saa7134: Error - device struct undefined.\n"); 6604 printk(KERN_ERR "saa7134: Error - device struct undefined.\n");
@@ -6476,6 +6669,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6476 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: 6669 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
6477 case SAA7134_BOARD_KWORLD_XPERT: 6670 case SAA7134_BOARD_KWORLD_XPERT:
6478 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 6671 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
6672 case SAA7134_BOARD_AVERMEDIA_STUDIO_505:
6479 case SAA7134_BOARD_AVERMEDIA_305: 6673 case SAA7134_BOARD_AVERMEDIA_305:
6480 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 6674 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
6481 case SAA7134_BOARD_AVERMEDIA_307: 6675 case SAA7134_BOARD_AVERMEDIA_307:
@@ -6500,7 +6694,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6500 case SAA7134_BOARD_FLYDVBT_LR301: 6694 case SAA7134_BOARD_FLYDVBT_LR301:
6501 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 6695 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
6502 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 6696 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
6503 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG: 6697 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG:
6504 case SAA7134_BOARD_FLYDVBTDUO: 6698 case SAA7134_BOARD_FLYDVBTDUO:
6505 case SAA7134_BOARD_PROTEUS_2309: 6699 case SAA7134_BOARD_PROTEUS_2309:
6506 case SAA7134_BOARD_AVERMEDIA_A16AR: 6700 case SAA7134_BOARD_AVERMEDIA_A16AR:
@@ -6525,6 +6719,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6525 case SAA7134_BOARD_REAL_ANGEL_220: 6719 case SAA7134_BOARD_REAL_ANGEL_220:
6526 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: 6720 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
6527 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: 6721 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
6722 case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM:
6528 dev->has_remote = SAA7134_REMOTE_GPIO; 6723 dev->has_remote = SAA7134_REMOTE_GPIO;
6529 break; 6724 break;
6530 case SAA7134_BOARD_FLYDVBS_LR300: 6725 case SAA7134_BOARD_FLYDVBS_LR300:
@@ -6653,6 +6848,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6653 case SAA7134_BOARD_BEHOLD_M63: 6848 case SAA7134_BOARD_BEHOLD_M63:
6654 case SAA7134_BOARD_BEHOLD_M6_EXTRA: 6849 case SAA7134_BOARD_BEHOLD_M6_EXTRA:
6655 case SAA7134_BOARD_BEHOLD_H6: 6850 case SAA7134_BOARD_BEHOLD_H6:
6851 case SAA7134_BOARD_BEHOLD_X7:
6656 dev->has_remote = SAA7134_REMOTE_I2C; 6852 dev->has_remote = SAA7134_REMOTE_I2C;
6657 break; 6853 break;
6658 case SAA7134_BOARD_AVERMEDIA_A169_B: 6854 case SAA7134_BOARD_AVERMEDIA_A169_B:
@@ -6673,6 +6869,11 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6673 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100); 6869 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100);
6674 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x80040100, 0x00040100); 6870 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x80040100, 0x00040100);
6675 break; 6871 break;
6872 case SAA7134_BOARD_VIDEOMATE_S350:
6873 dev->has_remote = SAA7134_REMOTE_GPIO;
6874 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x00008000, 0x00008000);
6875 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00008000, 0x00008000);
6876 break;
6676 } 6877 }
6677 return 0; 6878 return 0;
6678} 6879}
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 94a023a14bbc..cb78c956d810 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -1012,8 +1012,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1012 sd = v4l2_i2c_new_probed_subdev_addr(&dev->v4l2_dev, 1012 sd = v4l2_i2c_new_probed_subdev_addr(&dev->v4l2_dev,
1013 &dev->i2c_adap, "saa6588", "saa6588", 1013 &dev->i2c_adap, "saa6588", "saa6588",
1014 saa7134_boards[dev->board].rds_addr); 1014 saa7134_boards[dev->board].rds_addr);
1015 if (sd) 1015 if (sd) {
1016 printk(KERN_INFO "%s: found RDS decoder\n", dev->name); 1016 printk(KERN_INFO "%s: found RDS decoder\n", dev->name);
1017 dev->has_rds = 1;
1018 }
1017 } 1019 }
1018 1020
1019 request_submodules(dev); 1021 request_submodules(dev);
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 98f3efd1e944..ebde21dba7e3 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -56,6 +56,7 @@
56#include "zl10353.h" 56#include "zl10353.h"
57 57
58#include "zl10036.h" 58#include "zl10036.h"
59#include "zl10039.h"
59#include "mt312.h" 60#include "mt312.h"
60 61
61MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 62MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
@@ -968,6 +969,10 @@ static struct zl10036_config avertv_a700_tuner = {
968 .tuner_address = 0x60, 969 .tuner_address = 0x60,
969}; 970};
970 971
972static struct mt312_config zl10313_compro_s350_config = {
973 .demod_address = 0x0e,
974};
975
971static struct lgdt3305_config hcw_lgdt3305_config = { 976static struct lgdt3305_config hcw_lgdt3305_config = {
972 .i2c_addr = 0x0e, 977 .i2c_addr = 0x0e,
973 .mpeg_mode = LGDT3305_MPEG_SERIAL, 978 .mpeg_mode = LGDT3305_MPEG_SERIAL,
@@ -1457,7 +1462,7 @@ static int dvb_init(struct saa7134_dev *dev)
1457 if (fe0->dvb.frontend) { 1462 if (fe0->dvb.frontend) {
1458 dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1463 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1459 &dev->i2c_adap, 0x61, 1464 &dev->i2c_adap, 0x61,
1460 TUNER_PHILIPS_FMD1216ME_MK3); 1465 TUNER_PHILIPS_FMD1216MEX_MK3);
1461 } 1466 }
1462 break; 1467 break;
1463 case SAA7134_BOARD_AVERMEDIA_A700_PRO: 1468 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
@@ -1473,6 +1478,16 @@ static int dvb_init(struct saa7134_dev *dev)
1473 } 1478 }
1474 } 1479 }
1475 break; 1480 break;
1481 case SAA7134_BOARD_VIDEOMATE_S350:
1482 fe0->dvb.frontend = dvb_attach(mt312_attach,
1483 &zl10313_compro_s350_config, &dev->i2c_adap);
1484 if (fe0->dvb.frontend)
1485 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1486 0x60, &dev->i2c_adap) == NULL)
1487 wprintk("%s: No zl10039 found!\n",
1488 __func__);
1489
1490 break;
1476 default: 1491 default:
1477 wprintk("Huh? unknown DVB card?\n"); 1492 wprintk("Huh? unknown DVB card?\n");
1478 break; 1493 break;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 6e219c2db841..e1e83c7b966e 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -394,7 +394,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
394{ 394{
395 struct card_ir *ir; 395 struct card_ir *ir;
396 struct input_dev *input_dev; 396 struct input_dev *input_dev;
397 IR_KEYTAB_TYPE *ir_codes = NULL; 397 struct ir_scancode_table *ir_codes = NULL;
398 u32 mask_keycode = 0; 398 u32 mask_keycode = 0;
399 u32 mask_keydown = 0; 399 u32 mask_keydown = 0;
400 u32 mask_keyup = 0; 400 u32 mask_keyup = 0;
@@ -415,27 +415,28 @@ int saa7134_input_init1(struct saa7134_dev *dev)
415 case SAA7134_BOARD_FLYVIDEO3000: 415 case SAA7134_BOARD_FLYVIDEO3000:
416 case SAA7134_BOARD_FLYTVPLATINUM_FM: 416 case SAA7134_BOARD_FLYTVPLATINUM_FM:
417 case SAA7134_BOARD_FLYTVPLATINUM_MINI2: 417 case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
418 ir_codes = ir_codes_flyvideo; 418 case SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM:
419 ir_codes = &ir_codes_flyvideo_table;
419 mask_keycode = 0xEC00000; 420 mask_keycode = 0xEC00000;
420 mask_keydown = 0x0040000; 421 mask_keydown = 0x0040000;
421 break; 422 break;
422 case SAA7134_BOARD_CINERGY400: 423 case SAA7134_BOARD_CINERGY400:
423 case SAA7134_BOARD_CINERGY600: 424 case SAA7134_BOARD_CINERGY600:
424 case SAA7134_BOARD_CINERGY600_MK3: 425 case SAA7134_BOARD_CINERGY600_MK3:
425 ir_codes = ir_codes_cinergy; 426 ir_codes = &ir_codes_cinergy_table;
426 mask_keycode = 0x00003f; 427 mask_keycode = 0x00003f;
427 mask_keyup = 0x040000; 428 mask_keyup = 0x040000;
428 break; 429 break;
429 case SAA7134_BOARD_ECS_TVP3XP: 430 case SAA7134_BOARD_ECS_TVP3XP:
430 case SAA7134_BOARD_ECS_TVP3XP_4CB5: 431 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
431 ir_codes = ir_codes_eztv; 432 ir_codes = &ir_codes_eztv_table;
432 mask_keycode = 0x00017c; 433 mask_keycode = 0x00017c;
433 mask_keyup = 0x000002; 434 mask_keyup = 0x000002;
434 polling = 50; // ms 435 polling = 50; // ms
435 break; 436 break;
436 case SAA7134_BOARD_KWORLD_XPERT: 437 case SAA7134_BOARD_KWORLD_XPERT:
437 case SAA7134_BOARD_AVACSSMARTTV: 438 case SAA7134_BOARD_AVACSSMARTTV:
438 ir_codes = ir_codes_pixelview; 439 ir_codes = &ir_codes_pixelview_table;
439 mask_keycode = 0x00001F; 440 mask_keycode = 0x00001F;
440 mask_keyup = 0x000020; 441 mask_keyup = 0x000020;
441 polling = 50; // ms 442 polling = 50; // ms
@@ -445,13 +446,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
445 case SAA7134_BOARD_AVERMEDIA_305: 446 case SAA7134_BOARD_AVERMEDIA_305:
446 case SAA7134_BOARD_AVERMEDIA_307: 447 case SAA7134_BOARD_AVERMEDIA_307:
447 case SAA7134_BOARD_AVERMEDIA_STUDIO_305: 448 case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
449 case SAA7134_BOARD_AVERMEDIA_STUDIO_505:
448 case SAA7134_BOARD_AVERMEDIA_STUDIO_307: 450 case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
449 case SAA7134_BOARD_AVERMEDIA_STUDIO_507: 451 case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
450 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA: 452 case SAA7134_BOARD_AVERMEDIA_STUDIO_507UA:
451 case SAA7134_BOARD_AVERMEDIA_GO_007_FM: 453 case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
452 case SAA7134_BOARD_AVERMEDIA_M102: 454 case SAA7134_BOARD_AVERMEDIA_M102:
453 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS: 455 case SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS:
454 ir_codes = ir_codes_avermedia; 456 ir_codes = &ir_codes_avermedia_table;
455 mask_keycode = 0x0007C8; 457 mask_keycode = 0x0007C8;
456 mask_keydown = 0x000010; 458 mask_keydown = 0x000010;
457 polling = 50; // ms 459 polling = 50; // ms
@@ -460,14 +462,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
460 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4); 462 saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
461 break; 463 break;
462 case SAA7134_BOARD_AVERMEDIA_M135A: 464 case SAA7134_BOARD_AVERMEDIA_M135A:
463 ir_codes = ir_codes_avermedia_m135a; 465 ir_codes = &ir_codes_avermedia_m135a_table;
464 mask_keydown = 0x0040000; 466 mask_keydown = 0x0040000;
465 mask_keycode = 0x00013f; 467 mask_keycode = 0x00013f;
466 nec_gpio = 1; 468 nec_gpio = 1;
467 break; 469 break;
468 case SAA7134_BOARD_AVERMEDIA_777: 470 case SAA7134_BOARD_AVERMEDIA_777:
469 case SAA7134_BOARD_AVERMEDIA_A16AR: 471 case SAA7134_BOARD_AVERMEDIA_A16AR:
470 ir_codes = ir_codes_avermedia; 472 ir_codes = &ir_codes_avermedia_table;
471 mask_keycode = 0x02F200; 473 mask_keycode = 0x02F200;
472 mask_keydown = 0x000400; 474 mask_keydown = 0x000400;
473 polling = 50; // ms 475 polling = 50; // ms
@@ -476,7 +478,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
476 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); 478 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
477 break; 479 break;
478 case SAA7134_BOARD_AVERMEDIA_A16D: 480 case SAA7134_BOARD_AVERMEDIA_A16D:
479 ir_codes = ir_codes_avermedia_a16d; 481 ir_codes = &ir_codes_avermedia_a16d_table;
480 mask_keycode = 0x02F200; 482 mask_keycode = 0x02F200;
481 mask_keydown = 0x000400; 483 mask_keydown = 0x000400;
482 polling = 50; /* ms */ 484 polling = 50; /* ms */
@@ -485,14 +487,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
485 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1); 487 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
486 break; 488 break;
487 case SAA7134_BOARD_KWORLD_TERMINATOR: 489 case SAA7134_BOARD_KWORLD_TERMINATOR:
488 ir_codes = ir_codes_pixelview; 490 ir_codes = &ir_codes_pixelview_table;
489 mask_keycode = 0x00001f; 491 mask_keycode = 0x00001f;
490 mask_keyup = 0x000060; 492 mask_keyup = 0x000060;
491 polling = 50; // ms 493 polling = 50; // ms
492 break; 494 break;
493 case SAA7134_BOARD_MANLI_MTV001: 495 case SAA7134_BOARD_MANLI_MTV001:
494 case SAA7134_BOARD_MANLI_MTV002: 496 case SAA7134_BOARD_MANLI_MTV002:
495 ir_codes = ir_codes_manli; 497 ir_codes = &ir_codes_manli_table;
496 mask_keycode = 0x001f00; 498 mask_keycode = 0x001f00;
497 mask_keyup = 0x004000; 499 mask_keyup = 0x004000;
498 polling = 50; /* ms */ 500 polling = 50; /* ms */
@@ -511,25 +513,25 @@ int saa7134_input_init1(struct saa7134_dev *dev)
511 case SAA7134_BOARD_BEHOLD_507_9FM: 513 case SAA7134_BOARD_BEHOLD_507_9FM:
512 case SAA7134_BOARD_BEHOLD_507RDS_MK3: 514 case SAA7134_BOARD_BEHOLD_507RDS_MK3:
513 case SAA7134_BOARD_BEHOLD_507RDS_MK5: 515 case SAA7134_BOARD_BEHOLD_507RDS_MK5:
514 ir_codes = ir_codes_manli; 516 ir_codes = &ir_codes_manli_table;
515 mask_keycode = 0x003f00; 517 mask_keycode = 0x003f00;
516 mask_keyup = 0x004000; 518 mask_keyup = 0x004000;
517 polling = 50; /* ms */ 519 polling = 50; /* ms */
518 break; 520 break;
519 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: 521 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
520 ir_codes = ir_codes_behold_columbus; 522 ir_codes = &ir_codes_behold_columbus_table;
521 mask_keycode = 0x003f00; 523 mask_keycode = 0x003f00;
522 mask_keyup = 0x004000; 524 mask_keyup = 0x004000;
523 polling = 50; // ms 525 polling = 50; // ms
524 break; 526 break;
525 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS: 527 case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
526 ir_codes = ir_codes_pctv_sedna; 528 ir_codes = &ir_codes_pctv_sedna_table;
527 mask_keycode = 0x001f00; 529 mask_keycode = 0x001f00;
528 mask_keyup = 0x004000; 530 mask_keyup = 0x004000;
529 polling = 50; // ms 531 polling = 50; // ms
530 break; 532 break;
531 case SAA7134_BOARD_GOTVIEW_7135: 533 case SAA7134_BOARD_GOTVIEW_7135:
532 ir_codes = ir_codes_gotview7135; 534 ir_codes = &ir_codes_gotview7135_table;
533 mask_keycode = 0x0003CC; 535 mask_keycode = 0x0003CC;
534 mask_keydown = 0x000010; 536 mask_keydown = 0x000010;
535 polling = 5; /* ms */ 537 polling = 5; /* ms */
@@ -538,73 +540,78 @@ int saa7134_input_init1(struct saa7134_dev *dev)
538 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 540 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
539 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 541 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
540 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII: 542 case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
541 ir_codes = ir_codes_videomate_tv_pvr; 543 ir_codes = &ir_codes_videomate_tv_pvr_table;
542 mask_keycode = 0x00003F; 544 mask_keycode = 0x00003F;
543 mask_keyup = 0x400000; 545 mask_keyup = 0x400000;
544 polling = 50; // ms 546 polling = 50; // ms
545 break; 547 break;
546 case SAA7134_BOARD_PROTEUS_2309: 548 case SAA7134_BOARD_PROTEUS_2309:
547 ir_codes = ir_codes_proteus_2309; 549 ir_codes = &ir_codes_proteus_2309_table;
548 mask_keycode = 0x00007F; 550 mask_keycode = 0x00007F;
549 mask_keyup = 0x000080; 551 mask_keyup = 0x000080;
550 polling = 50; // ms 552 polling = 50; // ms
551 break; 553 break;
552 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 554 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
553 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 555 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
554 ir_codes = ir_codes_videomate_tv_pvr; 556 ir_codes = &ir_codes_videomate_tv_pvr_table;
555 mask_keycode = 0x003F00; 557 mask_keycode = 0x003F00;
556 mask_keyup = 0x040000; 558 mask_keyup = 0x040000;
557 break; 559 break;
558 case SAA7134_BOARD_FLYDVBS_LR300: 560 case SAA7134_BOARD_FLYDVBS_LR300:
559 case SAA7134_BOARD_FLYDVBT_LR301: 561 case SAA7134_BOARD_FLYDVBT_LR301:
560 case SAA7134_BOARD_FLYDVBTDUO: 562 case SAA7134_BOARD_FLYDVBTDUO:
561 ir_codes = ir_codes_flydvb; 563 ir_codes = &ir_codes_flydvb_table;
562 mask_keycode = 0x0001F00; 564 mask_keycode = 0x0001F00;
563 mask_keydown = 0x0040000; 565 mask_keydown = 0x0040000;
564 break; 566 break;
565 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 567 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
566 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 568 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
567 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG: 569 case SAA7134_BOARD_ASUSTeK_P7131_ANALOG:
568 ir_codes = ir_codes_asus_pc39; 570 ir_codes = &ir_codes_asus_pc39_table;
569 mask_keydown = 0x0040000; 571 mask_keydown = 0x0040000;
570 rc5_gpio = 1; 572 rc5_gpio = 1;
571 break; 573 break;
572 case SAA7134_BOARD_ENCORE_ENLTV: 574 case SAA7134_BOARD_ENCORE_ENLTV:
573 case SAA7134_BOARD_ENCORE_ENLTV_FM: 575 case SAA7134_BOARD_ENCORE_ENLTV_FM:
574 ir_codes = ir_codes_encore_enltv; 576 ir_codes = &ir_codes_encore_enltv_table;
575 mask_keycode = 0x00007f; 577 mask_keycode = 0x00007f;
576 mask_keyup = 0x040000; 578 mask_keyup = 0x040000;
577 polling = 50; // ms 579 polling = 50; // ms
578 break; 580 break;
579 case SAA7134_BOARD_ENCORE_ENLTV_FM53: 581 case SAA7134_BOARD_ENCORE_ENLTV_FM53:
580 ir_codes = ir_codes_encore_enltv_fm53; 582 ir_codes = &ir_codes_encore_enltv_fm53_table;
581 mask_keydown = 0x0040000; 583 mask_keydown = 0x0040000;
582 mask_keycode = 0x00007f; 584 mask_keycode = 0x00007f;
583 nec_gpio = 1; 585 nec_gpio = 1;
584 break; 586 break;
585 case SAA7134_BOARD_10MOONSTVMASTER3: 587 case SAA7134_BOARD_10MOONSTVMASTER3:
586 ir_codes = ir_codes_encore_enltv; 588 ir_codes = &ir_codes_encore_enltv_table;
587 mask_keycode = 0x5f80000; 589 mask_keycode = 0x5f80000;
588 mask_keyup = 0x8000000; 590 mask_keyup = 0x8000000;
589 polling = 50; //ms 591 polling = 50; //ms
590 break; 592 break;
591 case SAA7134_BOARD_GENIUS_TVGO_A11MCE: 593 case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
592 ir_codes = ir_codes_genius_tvgo_a11mce; 594 ir_codes = &ir_codes_genius_tvgo_a11mce_table;
593 mask_keycode = 0xff; 595 mask_keycode = 0xff;
594 mask_keydown = 0xf00000; 596 mask_keydown = 0xf00000;
595 polling = 50; /* ms */ 597 polling = 50; /* ms */
596 break; 598 break;
597 case SAA7134_BOARD_REAL_ANGEL_220: 599 case SAA7134_BOARD_REAL_ANGEL_220:
598 ir_codes = ir_codes_real_audio_220_32_keys; 600 ir_codes = &ir_codes_real_audio_220_32_keys_table;
599 mask_keycode = 0x3f00; 601 mask_keycode = 0x3f00;
600 mask_keyup = 0x4000; 602 mask_keyup = 0x4000;
601 polling = 50; /* ms */ 603 polling = 50; /* ms */
602 break; 604 break;
603 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG: 605 case SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG:
604 ir_codes = ir_codes_kworld_plus_tv_analog; 606 ir_codes = &ir_codes_kworld_plus_tv_analog_table;
605 mask_keycode = 0x7f; 607 mask_keycode = 0x7f;
606 polling = 40; /* ms */ 608 polling = 40; /* ms */
607 break; 609 break;
610 case SAA7134_BOARD_VIDEOMATE_S350:
611 ir_codes = &ir_codes_videomate_s350_table;
612 mask_keycode = 0x003f00;
613 mask_keydown = 0x040000;
614 break;
608 } 615 }
609 if (NULL == ir_codes) { 616 if (NULL == ir_codes) {
610 printk("%s: Oops: IR config error [card=%d]\n", 617 printk("%s: Oops: IR config error [card=%d]\n",
@@ -684,8 +691,6 @@ void saa7134_input_fini(struct saa7134_dev *dev)
684 691
685void saa7134_probe_i2c_ir(struct saa7134_dev *dev) 692void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
686{ 693{
687 struct i2c_board_info info;
688 struct IR_i2c_init_data init_data;
689 const unsigned short addr_list[] = { 694 const unsigned short addr_list[] = {
690 0x7a, 0x47, 0x71, 0x2d, 695 0x7a, 0x47, 0x71, 0x2d,
691 I2C_CLIENT_END 696 I2C_CLIENT_END
@@ -705,32 +710,34 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
705 return; 710 return;
706 } 711 }
707 712
708 memset(&info, 0, sizeof(struct i2c_board_info)); 713 memset(&dev->info, 0, sizeof(dev->info));
709 memset(&init_data, 0, sizeof(struct IR_i2c_init_data)); 714 memset(&dev->init_data, 0, sizeof(dev->init_data));
710 strlcpy(info.type, "ir_video", I2C_NAME_SIZE); 715 strlcpy(dev->info.type, "ir_video", I2C_NAME_SIZE);
711 716
712 switch (dev->board) { 717 switch (dev->board) {
713 case SAA7134_BOARD_PINNACLE_PCTV_110i: 718 case SAA7134_BOARD_PINNACLE_PCTV_110i:
714 case SAA7134_BOARD_PINNACLE_PCTV_310i: 719 case SAA7134_BOARD_PINNACLE_PCTV_310i:
715 init_data.name = "Pinnacle PCTV"; 720 dev->init_data.name = "Pinnacle PCTV";
716 if (pinnacle_remote == 0) { 721 if (pinnacle_remote == 0) {
717 init_data.get_key = get_key_pinnacle_color; 722 dev->init_data.get_key = get_key_pinnacle_color;
718 init_data.ir_codes = ir_codes_pinnacle_color; 723 dev->init_data.ir_codes = &ir_codes_pinnacle_color_table;
724 dev->info.addr = 0x47;
719 } else { 725 } else {
720 init_data.get_key = get_key_pinnacle_grey; 726 dev->init_data.get_key = get_key_pinnacle_grey;
721 init_data.ir_codes = ir_codes_pinnacle_grey; 727 dev->init_data.ir_codes = &ir_codes_pinnacle_grey_table;
728 dev->info.addr = 0x47;
722 } 729 }
723 break; 730 break;
724 case SAA7134_BOARD_UPMOST_PURPLE_TV: 731 case SAA7134_BOARD_UPMOST_PURPLE_TV:
725 init_data.name = "Purple TV"; 732 dev->init_data.name = "Purple TV";
726 init_data.get_key = get_key_purpletv; 733 dev->init_data.get_key = get_key_purpletv;
727 init_data.ir_codes = ir_codes_purpletv; 734 dev->init_data.ir_codes = &ir_codes_purpletv_table;
728 break; 735 break;
729 case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS: 736 case SAA7134_BOARD_MSI_TVATANYWHERE_PLUS:
730 init_data.name = "MSI TV@nywhere Plus"; 737 dev->init_data.name = "MSI TV@nywhere Plus";
731 init_data.get_key = get_key_msi_tvanywhere_plus; 738 dev->init_data.get_key = get_key_msi_tvanywhere_plus;
732 init_data.ir_codes = ir_codes_msi_tvanywhere_plus; 739 dev->init_data.ir_codes = &ir_codes_msi_tvanywhere_plus_table;
733 info.addr = 0x30; 740 dev->info.addr = 0x30;
734 /* MSI TV@nywhere Plus controller doesn't seem to 741 /* MSI TV@nywhere Plus controller doesn't seem to
735 respond to probes unless we read something from 742 respond to probes unless we read something from
736 an existing device. Weird... 743 an existing device. Weird...
@@ -741,9 +748,9 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
741 (1 == rc) ? "yes" : "no"); 748 (1 == rc) ? "yes" : "no");
742 break; 749 break;
743 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 750 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
744 init_data.name = "HVR 1110"; 751 dev->init_data.name = "HVR 1110";
745 init_data.get_key = get_key_hvr1110; 752 dev->init_data.get_key = get_key_hvr1110;
746 init_data.ir_codes = ir_codes_hauppauge_new; 753 dev->init_data.ir_codes = &ir_codes_hauppauge_new_table;
747 break; 754 break;
748 case SAA7134_BOARD_BEHOLD_607FM_MK3: 755 case SAA7134_BOARD_BEHOLD_607FM_MK3:
749 case SAA7134_BOARD_BEHOLD_607FM_MK5: 756 case SAA7134_BOARD_BEHOLD_607FM_MK5:
@@ -757,26 +764,27 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
757 case SAA7134_BOARD_BEHOLD_M63: 764 case SAA7134_BOARD_BEHOLD_M63:
758 case SAA7134_BOARD_BEHOLD_M6_EXTRA: 765 case SAA7134_BOARD_BEHOLD_M6_EXTRA:
759 case SAA7134_BOARD_BEHOLD_H6: 766 case SAA7134_BOARD_BEHOLD_H6:
760 init_data.name = "BeholdTV"; 767 case SAA7134_BOARD_BEHOLD_X7:
761 init_data.get_key = get_key_beholdm6xx; 768 dev->init_data.name = "BeholdTV";
762 init_data.ir_codes = ir_codes_behold; 769 dev->init_data.get_key = get_key_beholdm6xx;
770 dev->init_data.ir_codes = &ir_codes_behold_table;
763 break; 771 break;
764 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501: 772 case SAA7134_BOARD_AVERMEDIA_CARDBUS_501:
765 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: 773 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
766 info.addr = 0x40; 774 dev->info.addr = 0x40;
767 break; 775 break;
768 } 776 }
769 777
770 if (init_data.name) 778 if (dev->init_data.name)
771 info.platform_data = &init_data; 779 dev->info.platform_data = &dev->init_data;
772 /* No need to probe if address is known */ 780 /* No need to probe if address is known */
773 if (info.addr) { 781 if (dev->info.addr) {
774 i2c_new_device(&dev->i2c_adap, &info); 782 i2c_new_device(&dev->i2c_adap, &dev->info);
775 return; 783 return;
776 } 784 }
777 785
778 /* Address not known, fallback to probing */ 786 /* Address not known, fallback to probing */
779 i2c_new_probed_device(&dev->i2c_adap, &info, addr_list); 787 i2c_new_probed_device(&dev->i2c_adap, &dev->info, addr_list);
780} 788}
781 789
782static int saa7134_rc5_irq(struct saa7134_dev *dev) 790static int saa7134_rc5_irq(struct saa7134_dev *dev)
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index ba87128542e0..da26f476a302 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1444,7 +1444,6 @@ video_poll(struct file *file, struct poll_table_struct *wait)
1444 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 1444 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
1445 fh->cap.read_off = 0; 1445 fh->cap.read_off = 0;
1446 } 1446 }
1447 mutex_unlock(&fh->cap.vb_lock);
1448 buf = fh->cap.read_buf; 1447 buf = fh->cap.read_buf;
1449 } 1448 }
1450 1449
@@ -1790,7 +1789,7 @@ static int saa7134_s_input(struct file *file, void *priv, unsigned int i)
1790 if (0 != err) 1789 if (0 != err)
1791 return err; 1790 return err;
1792 1791
1793 if (i < 0 || i >= SAA7134_INPUT_MAX) 1792 if (i >= SAA7134_INPUT_MAX)
1794 return -EINVAL; 1793 return -EINVAL;
1795 if (NULL == card_in(dev, i).name) 1794 if (NULL == card_in(dev, i).name)
1796 return -EINVAL; 1795 return -EINVAL;
@@ -1819,6 +1818,8 @@ static int saa7134_querycap(struct file *file, void *priv,
1819 V4L2_CAP_READWRITE | 1818 V4L2_CAP_READWRITE |
1820 V4L2_CAP_STREAMING | 1819 V4L2_CAP_STREAMING |
1821 V4L2_CAP_TUNER; 1820 V4L2_CAP_TUNER;
1821 if (dev->has_rds)
1822 cap->capabilities |= V4L2_CAP_RDS_CAPTURE;
1822 if (saa7134_no_overlay <= 0) 1823 if (saa7134_no_overlay <= 0)
1823 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY; 1824 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
1824 1825
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index fb564f14887c..d18bb9643856 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -292,6 +292,10 @@ struct saa7134_format {
292#define SAA7134_BOARD_BEHOLD_607RDS_MK5 166 292#define SAA7134_BOARD_BEHOLD_607RDS_MK5 166
293#define SAA7134_BOARD_BEHOLD_609RDS_MK3 167 293#define SAA7134_BOARD_BEHOLD_609RDS_MK3 167
294#define SAA7134_BOARD_BEHOLD_609RDS_MK5 168 294#define SAA7134_BOARD_BEHOLD_609RDS_MK5 168
295#define SAA7134_BOARD_VIDEOMATE_S350 169
296#define SAA7134_BOARD_AVERMEDIA_STUDIO_505 170
297#define SAA7134_BOARD_BEHOLD_X7 171
298#define SAA7134_BOARD_ROVERMEDIA_LINK_PRO_FM 172
295 299
296#define SAA7134_MAXBOARDS 32 300#define SAA7134_MAXBOARDS 32
297#define SAA7134_INPUT_MAX 8 301#define SAA7134_INPUT_MAX 8
@@ -539,6 +543,7 @@ struct saa7134_dev {
539 struct i2c_adapter i2c_adap; 543 struct i2c_adapter i2c_adap;
540 struct i2c_client i2c_client; 544 struct i2c_client i2c_client;
541 unsigned char eedata[256]; 545 unsigned char eedata[256];
546 int has_rds;
542 547
543 /* video overlay */ 548 /* video overlay */
544 struct v4l2_framebuffer ovbuf; 549 struct v4l2_framebuffer ovbuf;
@@ -584,6 +589,10 @@ struct saa7134_dev {
584 int nosignal; 589 int nosignal;
585 unsigned int insuspend; 590 unsigned int insuspend;
586 591
592 /* I2C keyboard data */
593 struct i2c_board_info info;
594 struct IR_i2c_init_data init_data;
595
587 /* SAA7134_MPEG_* */ 596 /* SAA7134_MPEG_* */
588 struct saa7134_ts ts; 597 struct saa7134_ts ts;
589 struct saa7134_dmaqueue ts_q; 598 struct saa7134_dmaqueue ts_q;
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h
index 38a716020d7f..36ee43a9ee95 100644
--- a/drivers/media/video/sn9c102/sn9c102_devtable.h
+++ b/drivers/media/video/sn9c102/sn9c102_devtable.h
@@ -123,8 +123,8 @@ static const struct usb_device_id sn9c102_id_table[] = {
123 { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), }, 123 { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), },
124#if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE 124#if !defined CONFIG_USB_GSPCA && !defined CONFIG_USB_GSPCA_MODULE
125 { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), }, 125 { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), },
126#endif
127 { SN9C102_USB_DEVICE(0x0c45, 0x613e, BRIDGE_SN9C120), }, 126 { SN9C102_USB_DEVICE(0x0c45, 0x613e, BRIDGE_SN9C120), },
127#endif
128 { } 128 { }
129}; 129};
130 130
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index b154bd961e3b..0b996ea4134e 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -1400,7 +1400,6 @@ static int stk_camera_probe(struct usb_interface *interface,
1400 } 1400 }
1401 1401
1402 stk_create_sysfs_files(&dev->vdev); 1402 stk_create_sysfs_files(&dev->vdev);
1403 usb_autopm_enable(dev->interface);
1404 1403
1405 return 0; 1404 return 0;
1406 1405
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 8b4e7dafce7b..6a91714125d2 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -734,10 +734,6 @@ static int stv680_start_stream (struct usb_stv *stv680)
734 return 0; 734 return 0;
735 735
736 nomem_err: 736 nomem_err:
737 for (i = 0; i < STV680_NUMSCRATCH; i++) {
738 kfree(stv680->scratch[i].data);
739 stv680->scratch[i].data = NULL;
740 }
741 for (i = 0; i < STV680_NUMSBUF; i++) { 737 for (i = 0; i < STV680_NUMSBUF; i++) {
742 usb_kill_urb(stv680->urb[i]); 738 usb_kill_urb(stv680->urb[i]);
743 usb_free_urb(stv680->urb[i]); 739 usb_free_urb(stv680->urb[i]);
@@ -745,6 +741,11 @@ static int stv680_start_stream (struct usb_stv *stv680)
745 kfree(stv680->sbuf[i].data); 741 kfree(stv680->sbuf[i].data);
746 stv680->sbuf[i].data = NULL; 742 stv680->sbuf[i].data = NULL;
747 } 743 }
744 /* used in irq, free only as all URBs are dead */
745 for (i = 0; i < STV680_NUMSCRATCH; i++) {
746 kfree(stv680->scratch[i].data);
747 stv680->scratch[i].data = NULL;
748 }
748 return -ENOMEM; 749 return -ENOMEM;
749 750
750} 751}
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 537594211a90..2816f1839230 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -819,8 +819,8 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
819 819
820 fe_tuner_ops->get_frequency(&t->fe, &abs_freq); 820 fe_tuner_ops->get_frequency(&t->fe, &abs_freq);
821 f->frequency = (V4L2_TUNER_RADIO == t->mode) ? 821 f->frequency = (V4L2_TUNER_RADIO == t->mode) ?
822 (abs_freq * 2 + 125/2) / 125 : 822 DIV_ROUND_CLOSEST(abs_freq * 2, 125) :
823 (abs_freq + 62500/2) / 62500; 823 DIV_ROUND_CLOSEST(abs_freq, 62500);
824 return 0; 824 return 0;
825 } 825 }
826 f->frequency = (V4L2_TUNER_RADIO == t->mode) ? 826 f->frequency = (V4L2_TUNER_RADIO == t->mode) ?
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index ac02808106c1..d533ea57e7b1 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -646,14 +646,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
646 tvee->has_radio = 1; 646 tvee->has_radio = 1;
647 } 647 }
648 648
649 if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { 649 if (tuner1 < ARRAY_SIZE(hauppauge_tuner)) {
650 tvee->tuner_type = hauppauge_tuner[tuner1].id; 650 tvee->tuner_type = hauppauge_tuner[tuner1].id;
651 t_name1 = hauppauge_tuner[tuner1].name; 651 t_name1 = hauppauge_tuner[tuner1].name;
652 } else { 652 } else {
653 t_name1 = "unknown"; 653 t_name1 = "unknown";
654 } 654 }
655 655
656 if (tuner2 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { 656 if (tuner2 < ARRAY_SIZE(hauppauge_tuner)) {
657 tvee->tuner2_type = hauppauge_tuner[tuner2].id; 657 tvee->tuner2_type = hauppauge_tuner[tuner2].id;
658 t_name2 = hauppauge_tuner[tuner2].name; 658 t_name2 = hauppauge_tuner[tuner2].name;
659 } else { 659 } else {
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 36a6ba92df27..c3225a561748 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -34,7 +34,7 @@
34static struct uvc_control_info uvc_ctrls[] = { 34static struct uvc_control_info uvc_ctrls[] = {
35 { 35 {
36 .entity = UVC_GUID_UVC_PROCESSING, 36 .entity = UVC_GUID_UVC_PROCESSING,
37 .selector = PU_BRIGHTNESS_CONTROL, 37 .selector = UVC_PU_BRIGHTNESS_CONTROL,
38 .index = 0, 38 .index = 0,
39 .size = 2, 39 .size = 2,
40 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 40 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -42,7 +42,7 @@ static struct uvc_control_info uvc_ctrls[] = {
42 }, 42 },
43 { 43 {
44 .entity = UVC_GUID_UVC_PROCESSING, 44 .entity = UVC_GUID_UVC_PROCESSING,
45 .selector = PU_CONTRAST_CONTROL, 45 .selector = UVC_PU_CONTRAST_CONTROL,
46 .index = 1, 46 .index = 1,
47 .size = 2, 47 .size = 2,
48 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 48 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -50,7 +50,7 @@ static struct uvc_control_info uvc_ctrls[] = {
50 }, 50 },
51 { 51 {
52 .entity = UVC_GUID_UVC_PROCESSING, 52 .entity = UVC_GUID_UVC_PROCESSING,
53 .selector = PU_HUE_CONTROL, 53 .selector = UVC_PU_HUE_CONTROL,
54 .index = 2, 54 .index = 2,
55 .size = 2, 55 .size = 2,
56 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 56 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -58,7 +58,7 @@ static struct uvc_control_info uvc_ctrls[] = {
58 }, 58 },
59 { 59 {
60 .entity = UVC_GUID_UVC_PROCESSING, 60 .entity = UVC_GUID_UVC_PROCESSING,
61 .selector = PU_SATURATION_CONTROL, 61 .selector = UVC_PU_SATURATION_CONTROL,
62 .index = 3, 62 .index = 3,
63 .size = 2, 63 .size = 2,
64 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 64 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -66,7 +66,7 @@ static struct uvc_control_info uvc_ctrls[] = {
66 }, 66 },
67 { 67 {
68 .entity = UVC_GUID_UVC_PROCESSING, 68 .entity = UVC_GUID_UVC_PROCESSING,
69 .selector = PU_SHARPNESS_CONTROL, 69 .selector = UVC_PU_SHARPNESS_CONTROL,
70 .index = 4, 70 .index = 4,
71 .size = 2, 71 .size = 2,
72 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 72 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -74,7 +74,7 @@ static struct uvc_control_info uvc_ctrls[] = {
74 }, 74 },
75 { 75 {
76 .entity = UVC_GUID_UVC_PROCESSING, 76 .entity = UVC_GUID_UVC_PROCESSING,
77 .selector = PU_GAMMA_CONTROL, 77 .selector = UVC_PU_GAMMA_CONTROL,
78 .index = 5, 78 .index = 5,
79 .size = 2, 79 .size = 2,
80 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 80 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -82,7 +82,7 @@ static struct uvc_control_info uvc_ctrls[] = {
82 }, 82 },
83 { 83 {
84 .entity = UVC_GUID_UVC_PROCESSING, 84 .entity = UVC_GUID_UVC_PROCESSING,
85 .selector = PU_WHITE_BALANCE_TEMPERATURE_CONTROL, 85 .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
86 .index = 6, 86 .index = 6,
87 .size = 2, 87 .size = 2,
88 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 88 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -90,7 +90,7 @@ static struct uvc_control_info uvc_ctrls[] = {
90 }, 90 },
91 { 91 {
92 .entity = UVC_GUID_UVC_PROCESSING, 92 .entity = UVC_GUID_UVC_PROCESSING,
93 .selector = PU_WHITE_BALANCE_COMPONENT_CONTROL, 93 .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
94 .index = 7, 94 .index = 7,
95 .size = 4, 95 .size = 4,
96 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 96 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -98,7 +98,7 @@ static struct uvc_control_info uvc_ctrls[] = {
98 }, 98 },
99 { 99 {
100 .entity = UVC_GUID_UVC_PROCESSING, 100 .entity = UVC_GUID_UVC_PROCESSING,
101 .selector = PU_BACKLIGHT_COMPENSATION_CONTROL, 101 .selector = UVC_PU_BACKLIGHT_COMPENSATION_CONTROL,
102 .index = 8, 102 .index = 8,
103 .size = 2, 103 .size = 2,
104 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 104 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -106,7 +106,7 @@ static struct uvc_control_info uvc_ctrls[] = {
106 }, 106 },
107 { 107 {
108 .entity = UVC_GUID_UVC_PROCESSING, 108 .entity = UVC_GUID_UVC_PROCESSING,
109 .selector = PU_GAIN_CONTROL, 109 .selector = UVC_PU_GAIN_CONTROL,
110 .index = 9, 110 .index = 9,
111 .size = 2, 111 .size = 2,
112 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 112 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -114,7 +114,7 @@ static struct uvc_control_info uvc_ctrls[] = {
114 }, 114 },
115 { 115 {
116 .entity = UVC_GUID_UVC_PROCESSING, 116 .entity = UVC_GUID_UVC_PROCESSING,
117 .selector = PU_POWER_LINE_FREQUENCY_CONTROL, 117 .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
118 .index = 10, 118 .index = 10,
119 .size = 1, 119 .size = 1,
120 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 120 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -122,7 +122,7 @@ static struct uvc_control_info uvc_ctrls[] = {
122 }, 122 },
123 { 123 {
124 .entity = UVC_GUID_UVC_PROCESSING, 124 .entity = UVC_GUID_UVC_PROCESSING,
125 .selector = PU_HUE_AUTO_CONTROL, 125 .selector = UVC_PU_HUE_AUTO_CONTROL,
126 .index = 11, 126 .index = 11,
127 .size = 1, 127 .size = 1,
128 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 128 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -130,7 +130,7 @@ static struct uvc_control_info uvc_ctrls[] = {
130 }, 130 },
131 { 131 {
132 .entity = UVC_GUID_UVC_PROCESSING, 132 .entity = UVC_GUID_UVC_PROCESSING,
133 .selector = PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, 133 .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL,
134 .index = 12, 134 .index = 12,
135 .size = 1, 135 .size = 1,
136 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 136 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -138,7 +138,7 @@ static struct uvc_control_info uvc_ctrls[] = {
138 }, 138 },
139 { 139 {
140 .entity = UVC_GUID_UVC_PROCESSING, 140 .entity = UVC_GUID_UVC_PROCESSING,
141 .selector = PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL, 141 .selector = UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL,
142 .index = 13, 142 .index = 13,
143 .size = 1, 143 .size = 1,
144 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 144 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -146,7 +146,7 @@ static struct uvc_control_info uvc_ctrls[] = {
146 }, 146 },
147 { 147 {
148 .entity = UVC_GUID_UVC_PROCESSING, 148 .entity = UVC_GUID_UVC_PROCESSING,
149 .selector = PU_DIGITAL_MULTIPLIER_CONTROL, 149 .selector = UVC_PU_DIGITAL_MULTIPLIER_CONTROL,
150 .index = 14, 150 .index = 14,
151 .size = 2, 151 .size = 2,
152 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 152 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -154,7 +154,7 @@ static struct uvc_control_info uvc_ctrls[] = {
154 }, 154 },
155 { 155 {
156 .entity = UVC_GUID_UVC_PROCESSING, 156 .entity = UVC_GUID_UVC_PROCESSING,
157 .selector = PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL, 157 .selector = UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL,
158 .index = 15, 158 .index = 15,
159 .size = 2, 159 .size = 2,
160 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 160 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -162,21 +162,21 @@ static struct uvc_control_info uvc_ctrls[] = {
162 }, 162 },
163 { 163 {
164 .entity = UVC_GUID_UVC_PROCESSING, 164 .entity = UVC_GUID_UVC_PROCESSING,
165 .selector = PU_ANALOG_VIDEO_STANDARD_CONTROL, 165 .selector = UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL,
166 .index = 16, 166 .index = 16,
167 .size = 1, 167 .size = 1,
168 .flags = UVC_CONTROL_GET_CUR, 168 .flags = UVC_CONTROL_GET_CUR,
169 }, 169 },
170 { 170 {
171 .entity = UVC_GUID_UVC_PROCESSING, 171 .entity = UVC_GUID_UVC_PROCESSING,
172 .selector = PU_ANALOG_LOCK_STATUS_CONTROL, 172 .selector = UVC_PU_ANALOG_LOCK_STATUS_CONTROL,
173 .index = 17, 173 .index = 17,
174 .size = 1, 174 .size = 1,
175 .flags = UVC_CONTROL_GET_CUR, 175 .flags = UVC_CONTROL_GET_CUR,
176 }, 176 },
177 { 177 {
178 .entity = UVC_GUID_UVC_CAMERA, 178 .entity = UVC_GUID_UVC_CAMERA,
179 .selector = CT_SCANNING_MODE_CONTROL, 179 .selector = UVC_CT_SCANNING_MODE_CONTROL,
180 .index = 0, 180 .index = 0,
181 .size = 1, 181 .size = 1,
182 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 182 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -184,7 +184,7 @@ static struct uvc_control_info uvc_ctrls[] = {
184 }, 184 },
185 { 185 {
186 .entity = UVC_GUID_UVC_CAMERA, 186 .entity = UVC_GUID_UVC_CAMERA,
187 .selector = CT_AE_MODE_CONTROL, 187 .selector = UVC_CT_AE_MODE_CONTROL,
188 .index = 1, 188 .index = 1,
189 .size = 1, 189 .size = 1,
190 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 190 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -193,7 +193,7 @@ static struct uvc_control_info uvc_ctrls[] = {
193 }, 193 },
194 { 194 {
195 .entity = UVC_GUID_UVC_CAMERA, 195 .entity = UVC_GUID_UVC_CAMERA,
196 .selector = CT_AE_PRIORITY_CONTROL, 196 .selector = UVC_CT_AE_PRIORITY_CONTROL,
197 .index = 2, 197 .index = 2,
198 .size = 1, 198 .size = 1,
199 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 199 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -201,7 +201,7 @@ static struct uvc_control_info uvc_ctrls[] = {
201 }, 201 },
202 { 202 {
203 .entity = UVC_GUID_UVC_CAMERA, 203 .entity = UVC_GUID_UVC_CAMERA,
204 .selector = CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, 204 .selector = UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL,
205 .index = 3, 205 .index = 3,
206 .size = 4, 206 .size = 4,
207 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 207 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -209,7 +209,7 @@ static struct uvc_control_info uvc_ctrls[] = {
209 }, 209 },
210 { 210 {
211 .entity = UVC_GUID_UVC_CAMERA, 211 .entity = UVC_GUID_UVC_CAMERA,
212 .selector = CT_EXPOSURE_TIME_RELATIVE_CONTROL, 212 .selector = UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL,
213 .index = 4, 213 .index = 4,
214 .size = 1, 214 .size = 1,
215 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 215 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -217,7 +217,7 @@ static struct uvc_control_info uvc_ctrls[] = {
217 }, 217 },
218 { 218 {
219 .entity = UVC_GUID_UVC_CAMERA, 219 .entity = UVC_GUID_UVC_CAMERA,
220 .selector = CT_FOCUS_ABSOLUTE_CONTROL, 220 .selector = UVC_CT_FOCUS_ABSOLUTE_CONTROL,
221 .index = 5, 221 .index = 5,
222 .size = 2, 222 .size = 2,
223 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 223 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -225,7 +225,7 @@ static struct uvc_control_info uvc_ctrls[] = {
225 }, 225 },
226 { 226 {
227 .entity = UVC_GUID_UVC_CAMERA, 227 .entity = UVC_GUID_UVC_CAMERA,
228 .selector = CT_FOCUS_RELATIVE_CONTROL, 228 .selector = UVC_CT_FOCUS_RELATIVE_CONTROL,
229 .index = 6, 229 .index = 6,
230 .size = 2, 230 .size = 2,
231 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 231 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -233,7 +233,7 @@ static struct uvc_control_info uvc_ctrls[] = {
233 }, 233 },
234 { 234 {
235 .entity = UVC_GUID_UVC_CAMERA, 235 .entity = UVC_GUID_UVC_CAMERA,
236 .selector = CT_IRIS_ABSOLUTE_CONTROL, 236 .selector = UVC_CT_IRIS_ABSOLUTE_CONTROL,
237 .index = 7, 237 .index = 7,
238 .size = 2, 238 .size = 2,
239 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 239 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -241,7 +241,7 @@ static struct uvc_control_info uvc_ctrls[] = {
241 }, 241 },
242 { 242 {
243 .entity = UVC_GUID_UVC_CAMERA, 243 .entity = UVC_GUID_UVC_CAMERA,
244 .selector = CT_IRIS_RELATIVE_CONTROL, 244 .selector = UVC_CT_IRIS_RELATIVE_CONTROL,
245 .index = 8, 245 .index = 8,
246 .size = 1, 246 .size = 1,
247 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 247 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -249,7 +249,7 @@ static struct uvc_control_info uvc_ctrls[] = {
249 }, 249 },
250 { 250 {
251 .entity = UVC_GUID_UVC_CAMERA, 251 .entity = UVC_GUID_UVC_CAMERA,
252 .selector = CT_ZOOM_ABSOLUTE_CONTROL, 252 .selector = UVC_CT_ZOOM_ABSOLUTE_CONTROL,
253 .index = 9, 253 .index = 9,
254 .size = 2, 254 .size = 2,
255 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 255 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -257,7 +257,7 @@ static struct uvc_control_info uvc_ctrls[] = {
257 }, 257 },
258 { 258 {
259 .entity = UVC_GUID_UVC_CAMERA, 259 .entity = UVC_GUID_UVC_CAMERA,
260 .selector = CT_ZOOM_RELATIVE_CONTROL, 260 .selector = UVC_CT_ZOOM_RELATIVE_CONTROL,
261 .index = 10, 261 .index = 10,
262 .size = 3, 262 .size = 3,
263 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 263 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -265,7 +265,7 @@ static struct uvc_control_info uvc_ctrls[] = {
265 }, 265 },
266 { 266 {
267 .entity = UVC_GUID_UVC_CAMERA, 267 .entity = UVC_GUID_UVC_CAMERA,
268 .selector = CT_PANTILT_ABSOLUTE_CONTROL, 268 .selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL,
269 .index = 11, 269 .index = 11,
270 .size = 8, 270 .size = 8,
271 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 271 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -273,7 +273,7 @@ static struct uvc_control_info uvc_ctrls[] = {
273 }, 273 },
274 { 274 {
275 .entity = UVC_GUID_UVC_CAMERA, 275 .entity = UVC_GUID_UVC_CAMERA,
276 .selector = CT_PANTILT_RELATIVE_CONTROL, 276 .selector = UVC_CT_PANTILT_RELATIVE_CONTROL,
277 .index = 12, 277 .index = 12,
278 .size = 4, 278 .size = 4,
279 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 279 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -281,7 +281,7 @@ static struct uvc_control_info uvc_ctrls[] = {
281 }, 281 },
282 { 282 {
283 .entity = UVC_GUID_UVC_CAMERA, 283 .entity = UVC_GUID_UVC_CAMERA,
284 .selector = CT_ROLL_ABSOLUTE_CONTROL, 284 .selector = UVC_CT_ROLL_ABSOLUTE_CONTROL,
285 .index = 13, 285 .index = 13,
286 .size = 2, 286 .size = 2,
287 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 287 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -289,7 +289,7 @@ static struct uvc_control_info uvc_ctrls[] = {
289 }, 289 },
290 { 290 {
291 .entity = UVC_GUID_UVC_CAMERA, 291 .entity = UVC_GUID_UVC_CAMERA,
292 .selector = CT_ROLL_RELATIVE_CONTROL, 292 .selector = UVC_CT_ROLL_RELATIVE_CONTROL,
293 .index = 14, 293 .index = 14,
294 .size = 2, 294 .size = 2,
295 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE 295 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_RANGE
@@ -297,7 +297,7 @@ static struct uvc_control_info uvc_ctrls[] = {
297 }, 297 },
298 { 298 {
299 .entity = UVC_GUID_UVC_CAMERA, 299 .entity = UVC_GUID_UVC_CAMERA,
300 .selector = CT_FOCUS_AUTO_CONTROL, 300 .selector = UVC_CT_FOCUS_AUTO_CONTROL,
301 .index = 17, 301 .index = 17,
302 .size = 1, 302 .size = 1,
303 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 303 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -305,7 +305,7 @@ static struct uvc_control_info uvc_ctrls[] = {
305 }, 305 },
306 { 306 {
307 .entity = UVC_GUID_UVC_CAMERA, 307 .entity = UVC_GUID_UVC_CAMERA,
308 .selector = CT_PRIVACY_CONTROL, 308 .selector = UVC_CT_PRIVACY_CONTROL,
309 .index = 18, 309 .index = 18,
310 .size = 1, 310 .size = 1,
311 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR 311 .flags = UVC_CONTROL_SET_CUR | UVC_CONTROL_GET_CUR
@@ -332,13 +332,13 @@ static __s32 uvc_ctrl_get_zoom(struct uvc_control_mapping *mapping,
332 __s8 zoom = (__s8)data[0]; 332 __s8 zoom = (__s8)data[0];
333 333
334 switch (query) { 334 switch (query) {
335 case GET_CUR: 335 case UVC_GET_CUR:
336 return (zoom == 0) ? 0 : (zoom > 0 ? data[2] : -data[2]); 336 return (zoom == 0) ? 0 : (zoom > 0 ? data[2] : -data[2]);
337 337
338 case GET_MIN: 338 case UVC_GET_MIN:
339 case GET_MAX: 339 case UVC_GET_MAX:
340 case GET_RES: 340 case UVC_GET_RES:
341 case GET_DEF: 341 case UVC_GET_DEF:
342 default: 342 default:
343 return data[2]; 343 return data[2];
344 } 344 }
@@ -356,7 +356,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
356 .id = V4L2_CID_BRIGHTNESS, 356 .id = V4L2_CID_BRIGHTNESS,
357 .name = "Brightness", 357 .name = "Brightness",
358 .entity = UVC_GUID_UVC_PROCESSING, 358 .entity = UVC_GUID_UVC_PROCESSING,
359 .selector = PU_BRIGHTNESS_CONTROL, 359 .selector = UVC_PU_BRIGHTNESS_CONTROL,
360 .size = 16, 360 .size = 16,
361 .offset = 0, 361 .offset = 0,
362 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 362 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -366,7 +366,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
366 .id = V4L2_CID_CONTRAST, 366 .id = V4L2_CID_CONTRAST,
367 .name = "Contrast", 367 .name = "Contrast",
368 .entity = UVC_GUID_UVC_PROCESSING, 368 .entity = UVC_GUID_UVC_PROCESSING,
369 .selector = PU_CONTRAST_CONTROL, 369 .selector = UVC_PU_CONTRAST_CONTROL,
370 .size = 16, 370 .size = 16,
371 .offset = 0, 371 .offset = 0,
372 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 372 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -376,7 +376,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
376 .id = V4L2_CID_HUE, 376 .id = V4L2_CID_HUE,
377 .name = "Hue", 377 .name = "Hue",
378 .entity = UVC_GUID_UVC_PROCESSING, 378 .entity = UVC_GUID_UVC_PROCESSING,
379 .selector = PU_HUE_CONTROL, 379 .selector = UVC_PU_HUE_CONTROL,
380 .size = 16, 380 .size = 16,
381 .offset = 0, 381 .offset = 0,
382 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 382 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -386,7 +386,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
386 .id = V4L2_CID_SATURATION, 386 .id = V4L2_CID_SATURATION,
387 .name = "Saturation", 387 .name = "Saturation",
388 .entity = UVC_GUID_UVC_PROCESSING, 388 .entity = UVC_GUID_UVC_PROCESSING,
389 .selector = PU_SATURATION_CONTROL, 389 .selector = UVC_PU_SATURATION_CONTROL,
390 .size = 16, 390 .size = 16,
391 .offset = 0, 391 .offset = 0,
392 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 392 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -396,7 +396,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
396 .id = V4L2_CID_SHARPNESS, 396 .id = V4L2_CID_SHARPNESS,
397 .name = "Sharpness", 397 .name = "Sharpness",
398 .entity = UVC_GUID_UVC_PROCESSING, 398 .entity = UVC_GUID_UVC_PROCESSING,
399 .selector = PU_SHARPNESS_CONTROL, 399 .selector = UVC_PU_SHARPNESS_CONTROL,
400 .size = 16, 400 .size = 16,
401 .offset = 0, 401 .offset = 0,
402 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 402 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -406,7 +406,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
406 .id = V4L2_CID_GAMMA, 406 .id = V4L2_CID_GAMMA,
407 .name = "Gamma", 407 .name = "Gamma",
408 .entity = UVC_GUID_UVC_PROCESSING, 408 .entity = UVC_GUID_UVC_PROCESSING,
409 .selector = PU_GAMMA_CONTROL, 409 .selector = UVC_PU_GAMMA_CONTROL,
410 .size = 16, 410 .size = 16,
411 .offset = 0, 411 .offset = 0,
412 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 412 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -416,7 +416,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
416 .id = V4L2_CID_BACKLIGHT_COMPENSATION, 416 .id = V4L2_CID_BACKLIGHT_COMPENSATION,
417 .name = "Backlight Compensation", 417 .name = "Backlight Compensation",
418 .entity = UVC_GUID_UVC_PROCESSING, 418 .entity = UVC_GUID_UVC_PROCESSING,
419 .selector = PU_BACKLIGHT_COMPENSATION_CONTROL, 419 .selector = UVC_PU_BACKLIGHT_COMPENSATION_CONTROL,
420 .size = 16, 420 .size = 16,
421 .offset = 0, 421 .offset = 0,
422 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 422 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -426,7 +426,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
426 .id = V4L2_CID_GAIN, 426 .id = V4L2_CID_GAIN,
427 .name = "Gain", 427 .name = "Gain",
428 .entity = UVC_GUID_UVC_PROCESSING, 428 .entity = UVC_GUID_UVC_PROCESSING,
429 .selector = PU_GAIN_CONTROL, 429 .selector = UVC_PU_GAIN_CONTROL,
430 .size = 16, 430 .size = 16,
431 .offset = 0, 431 .offset = 0,
432 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 432 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -436,7 +436,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
436 .id = V4L2_CID_POWER_LINE_FREQUENCY, 436 .id = V4L2_CID_POWER_LINE_FREQUENCY,
437 .name = "Power Line Frequency", 437 .name = "Power Line Frequency",
438 .entity = UVC_GUID_UVC_PROCESSING, 438 .entity = UVC_GUID_UVC_PROCESSING,
439 .selector = PU_POWER_LINE_FREQUENCY_CONTROL, 439 .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL,
440 .size = 2, 440 .size = 2,
441 .offset = 0, 441 .offset = 0,
442 .v4l2_type = V4L2_CTRL_TYPE_MENU, 442 .v4l2_type = V4L2_CTRL_TYPE_MENU,
@@ -448,7 +448,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
448 .id = V4L2_CID_HUE_AUTO, 448 .id = V4L2_CID_HUE_AUTO,
449 .name = "Hue, Auto", 449 .name = "Hue, Auto",
450 .entity = UVC_GUID_UVC_PROCESSING, 450 .entity = UVC_GUID_UVC_PROCESSING,
451 .selector = PU_HUE_AUTO_CONTROL, 451 .selector = UVC_PU_HUE_AUTO_CONTROL,
452 .size = 1, 452 .size = 1,
453 .offset = 0, 453 .offset = 0,
454 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, 454 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -458,7 +458,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
458 .id = V4L2_CID_EXPOSURE_AUTO, 458 .id = V4L2_CID_EXPOSURE_AUTO,
459 .name = "Exposure, Auto", 459 .name = "Exposure, Auto",
460 .entity = UVC_GUID_UVC_CAMERA, 460 .entity = UVC_GUID_UVC_CAMERA,
461 .selector = CT_AE_MODE_CONTROL, 461 .selector = UVC_CT_AE_MODE_CONTROL,
462 .size = 4, 462 .size = 4,
463 .offset = 0, 463 .offset = 0,
464 .v4l2_type = V4L2_CTRL_TYPE_MENU, 464 .v4l2_type = V4L2_CTRL_TYPE_MENU,
@@ -470,7 +470,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
470 .id = V4L2_CID_EXPOSURE_AUTO_PRIORITY, 470 .id = V4L2_CID_EXPOSURE_AUTO_PRIORITY,
471 .name = "Exposure, Auto Priority", 471 .name = "Exposure, Auto Priority",
472 .entity = UVC_GUID_UVC_CAMERA, 472 .entity = UVC_GUID_UVC_CAMERA,
473 .selector = CT_AE_PRIORITY_CONTROL, 473 .selector = UVC_CT_AE_PRIORITY_CONTROL,
474 .size = 1, 474 .size = 1,
475 .offset = 0, 475 .offset = 0,
476 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, 476 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -480,7 +480,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
480 .id = V4L2_CID_EXPOSURE_ABSOLUTE, 480 .id = V4L2_CID_EXPOSURE_ABSOLUTE,
481 .name = "Exposure (Absolute)", 481 .name = "Exposure (Absolute)",
482 .entity = UVC_GUID_UVC_CAMERA, 482 .entity = UVC_GUID_UVC_CAMERA,
483 .selector = CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, 483 .selector = UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL,
484 .size = 32, 484 .size = 32,
485 .offset = 0, 485 .offset = 0,
486 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 486 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -490,7 +490,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
490 .id = V4L2_CID_AUTO_WHITE_BALANCE, 490 .id = V4L2_CID_AUTO_WHITE_BALANCE,
491 .name = "White Balance Temperature, Auto", 491 .name = "White Balance Temperature, Auto",
492 .entity = UVC_GUID_UVC_PROCESSING, 492 .entity = UVC_GUID_UVC_PROCESSING,
493 .selector = PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, 493 .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL,
494 .size = 1, 494 .size = 1,
495 .offset = 0, 495 .offset = 0,
496 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, 496 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -500,7 +500,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
500 .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE, 500 .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE,
501 .name = "White Balance Temperature", 501 .name = "White Balance Temperature",
502 .entity = UVC_GUID_UVC_PROCESSING, 502 .entity = UVC_GUID_UVC_PROCESSING,
503 .selector = PU_WHITE_BALANCE_TEMPERATURE_CONTROL, 503 .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL,
504 .size = 16, 504 .size = 16,
505 .offset = 0, 505 .offset = 0,
506 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 506 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -510,7 +510,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
510 .id = V4L2_CID_AUTO_WHITE_BALANCE, 510 .id = V4L2_CID_AUTO_WHITE_BALANCE,
511 .name = "White Balance Component, Auto", 511 .name = "White Balance Component, Auto",
512 .entity = UVC_GUID_UVC_PROCESSING, 512 .entity = UVC_GUID_UVC_PROCESSING,
513 .selector = PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL, 513 .selector = UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL,
514 .size = 1, 514 .size = 1,
515 .offset = 0, 515 .offset = 0,
516 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, 516 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -520,7 +520,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
520 .id = V4L2_CID_BLUE_BALANCE, 520 .id = V4L2_CID_BLUE_BALANCE,
521 .name = "White Balance Blue Component", 521 .name = "White Balance Blue Component",
522 .entity = UVC_GUID_UVC_PROCESSING, 522 .entity = UVC_GUID_UVC_PROCESSING,
523 .selector = PU_WHITE_BALANCE_COMPONENT_CONTROL, 523 .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
524 .size = 16, 524 .size = 16,
525 .offset = 0, 525 .offset = 0,
526 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 526 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -530,7 +530,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
530 .id = V4L2_CID_RED_BALANCE, 530 .id = V4L2_CID_RED_BALANCE,
531 .name = "White Balance Red Component", 531 .name = "White Balance Red Component",
532 .entity = UVC_GUID_UVC_PROCESSING, 532 .entity = UVC_GUID_UVC_PROCESSING,
533 .selector = PU_WHITE_BALANCE_COMPONENT_CONTROL, 533 .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL,
534 .size = 16, 534 .size = 16,
535 .offset = 16, 535 .offset = 16,
536 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 536 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -540,7 +540,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
540 .id = V4L2_CID_FOCUS_ABSOLUTE, 540 .id = V4L2_CID_FOCUS_ABSOLUTE,
541 .name = "Focus (absolute)", 541 .name = "Focus (absolute)",
542 .entity = UVC_GUID_UVC_CAMERA, 542 .entity = UVC_GUID_UVC_CAMERA,
543 .selector = CT_FOCUS_ABSOLUTE_CONTROL, 543 .selector = UVC_CT_FOCUS_ABSOLUTE_CONTROL,
544 .size = 16, 544 .size = 16,
545 .offset = 0, 545 .offset = 0,
546 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 546 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -550,7 +550,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
550 .id = V4L2_CID_FOCUS_AUTO, 550 .id = V4L2_CID_FOCUS_AUTO,
551 .name = "Focus, Auto", 551 .name = "Focus, Auto",
552 .entity = UVC_GUID_UVC_CAMERA, 552 .entity = UVC_GUID_UVC_CAMERA,
553 .selector = CT_FOCUS_AUTO_CONTROL, 553 .selector = UVC_CT_FOCUS_AUTO_CONTROL,
554 .size = 1, 554 .size = 1,
555 .offset = 0, 555 .offset = 0,
556 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, 556 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -560,7 +560,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
560 .id = V4L2_CID_ZOOM_ABSOLUTE, 560 .id = V4L2_CID_ZOOM_ABSOLUTE,
561 .name = "Zoom, Absolute", 561 .name = "Zoom, Absolute",
562 .entity = UVC_GUID_UVC_CAMERA, 562 .entity = UVC_GUID_UVC_CAMERA,
563 .selector = CT_ZOOM_ABSOLUTE_CONTROL, 563 .selector = UVC_CT_ZOOM_ABSOLUTE_CONTROL,
564 .size = 16, 564 .size = 16,
565 .offset = 0, 565 .offset = 0,
566 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 566 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -570,7 +570,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
570 .id = V4L2_CID_ZOOM_CONTINUOUS, 570 .id = V4L2_CID_ZOOM_CONTINUOUS,
571 .name = "Zoom, Continuous", 571 .name = "Zoom, Continuous",
572 .entity = UVC_GUID_UVC_CAMERA, 572 .entity = UVC_GUID_UVC_CAMERA,
573 .selector = CT_ZOOM_RELATIVE_CONTROL, 573 .selector = UVC_CT_ZOOM_RELATIVE_CONTROL,
574 .size = 0, 574 .size = 0,
575 .offset = 0, 575 .offset = 0,
576 .v4l2_type = V4L2_CTRL_TYPE_INTEGER, 576 .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
@@ -582,7 +582,7 @@ static struct uvc_control_mapping uvc_ctrl_mappings[] = {
582 .id = V4L2_CID_PRIVACY, 582 .id = V4L2_CID_PRIVACY,
583 .name = "Privacy", 583 .name = "Privacy",
584 .entity = UVC_GUID_UVC_CAMERA, 584 .entity = UVC_GUID_UVC_CAMERA,
585 .selector = CT_PRIVACY_CONTROL, 585 .selector = UVC_CT_PRIVACY_CONTROL,
586 .size = 1, 586 .size = 1,
587 .offset = 0, 587 .offset = 0,
588 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN, 588 .v4l2_type = V4L2_CTRL_TYPE_BOOLEAN,
@@ -675,16 +675,16 @@ static const __u8 uvc_media_transport_input_guid[16] =
675static int uvc_entity_match_guid(struct uvc_entity *entity, __u8 guid[16]) 675static int uvc_entity_match_guid(struct uvc_entity *entity, __u8 guid[16])
676{ 676{
677 switch (UVC_ENTITY_TYPE(entity)) { 677 switch (UVC_ENTITY_TYPE(entity)) {
678 case ITT_CAMERA: 678 case UVC_ITT_CAMERA:
679 return memcmp(uvc_camera_guid, guid, 16) == 0; 679 return memcmp(uvc_camera_guid, guid, 16) == 0;
680 680
681 case ITT_MEDIA_TRANSPORT_INPUT: 681 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
682 return memcmp(uvc_media_transport_input_guid, guid, 16) == 0; 682 return memcmp(uvc_media_transport_input_guid, guid, 16) == 0;
683 683
684 case VC_PROCESSING_UNIT: 684 case UVC_VC_PROCESSING_UNIT:
685 return memcmp(uvc_processing_guid, guid, 16) == 0; 685 return memcmp(uvc_processing_guid, guid, 16) == 0;
686 686
687 case VC_EXTENSION_UNIT: 687 case UVC_VC_EXTENSION_UNIT:
688 return memcmp(entity->extension.guidExtensionCode, 688 return memcmp(entity->extension.guidExtensionCode,
689 guid, 16) == 0; 689 guid, 16) == 0;
690 690
@@ -729,7 +729,7 @@ static void __uvc_find_control(struct uvc_entity *entity, __u32 v4l2_id,
729 } 729 }
730} 730}
731 731
732struct uvc_control *uvc_find_control(struct uvc_video_device *video, 732struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
733 __u32 v4l2_id, struct uvc_control_mapping **mapping) 733 __u32 v4l2_id, struct uvc_control_mapping **mapping)
734{ 734{
735 struct uvc_control *ctrl = NULL; 735 struct uvc_control *ctrl = NULL;
@@ -742,17 +742,17 @@ struct uvc_control *uvc_find_control(struct uvc_video_device *video,
742 v4l2_id &= V4L2_CTRL_ID_MASK; 742 v4l2_id &= V4L2_CTRL_ID_MASK;
743 743
744 /* Find the control. */ 744 /* Find the control. */
745 __uvc_find_control(video->processing, v4l2_id, mapping, &ctrl, next); 745 __uvc_find_control(chain->processing, v4l2_id, mapping, &ctrl, next);
746 if (ctrl && !next) 746 if (ctrl && !next)
747 return ctrl; 747 return ctrl;
748 748
749 list_for_each_entry(entity, &video->iterms, chain) { 749 list_for_each_entry(entity, &chain->iterms, chain) {
750 __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next); 750 __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next);
751 if (ctrl && !next) 751 if (ctrl && !next)
752 return ctrl; 752 return ctrl;
753 } 753 }
754 754
755 list_for_each_entry(entity, &video->extensions, chain) { 755 list_for_each_entry(entity, &chain->extensions, chain) {
756 __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next); 756 __uvc_find_control(entity, v4l2_id, mapping, &ctrl, next);
757 if (ctrl && !next) 757 if (ctrl && !next)
758 return ctrl; 758 return ctrl;
@@ -765,7 +765,7 @@ struct uvc_control *uvc_find_control(struct uvc_video_device *video,
765 return ctrl; 765 return ctrl;
766} 766}
767 767
768int uvc_query_v4l2_ctrl(struct uvc_video_device *video, 768int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
769 struct v4l2_queryctrl *v4l2_ctrl) 769 struct v4l2_queryctrl *v4l2_ctrl)
770{ 770{
771 struct uvc_control *ctrl; 771 struct uvc_control *ctrl;
@@ -775,7 +775,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
775 __u8 *data; 775 __u8 *data;
776 int ret; 776 int ret;
777 777
778 ctrl = uvc_find_control(video, v4l2_ctrl->id, &mapping); 778 ctrl = uvc_find_control(chain, v4l2_ctrl->id, &mapping);
779 if (ctrl == NULL) 779 if (ctrl == NULL)
780 return -EINVAL; 780 return -EINVAL;
781 781
@@ -793,11 +793,13 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
793 v4l2_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; 793 v4l2_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
794 794
795 if (ctrl->info->flags & UVC_CONTROL_GET_DEF) { 795 if (ctrl->info->flags & UVC_CONTROL_GET_DEF) {
796 if ((ret = uvc_query_ctrl(video->dev, GET_DEF, ctrl->entity->id, 796 ret = uvc_query_ctrl(chain->dev, UVC_GET_DEF, ctrl->entity->id,
797 video->dev->intfnum, ctrl->info->selector, 797 chain->dev->intfnum, ctrl->info->selector,
798 data, ctrl->info->size)) < 0) 798 data, ctrl->info->size);
799 if (ret < 0)
799 goto out; 800 goto out;
800 v4l2_ctrl->default_value = mapping->get(mapping, GET_DEF, data); 801 v4l2_ctrl->default_value =
802 mapping->get(mapping, UVC_GET_DEF, data);
801 } 803 }
802 804
803 switch (mapping->v4l2_type) { 805 switch (mapping->v4l2_type) {
@@ -829,25 +831,28 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
829 } 831 }
830 832
831 if (ctrl->info->flags & UVC_CONTROL_GET_MIN) { 833 if (ctrl->info->flags & UVC_CONTROL_GET_MIN) {
832 if ((ret = uvc_query_ctrl(video->dev, GET_MIN, ctrl->entity->id, 834 ret = uvc_query_ctrl(chain->dev, UVC_GET_MIN, ctrl->entity->id,
833 video->dev->intfnum, ctrl->info->selector, 835 chain->dev->intfnum, ctrl->info->selector,
834 data, ctrl->info->size)) < 0) 836 data, ctrl->info->size);
837 if (ret < 0)
835 goto out; 838 goto out;
836 v4l2_ctrl->minimum = mapping->get(mapping, GET_MIN, data); 839 v4l2_ctrl->minimum = mapping->get(mapping, UVC_GET_MIN, data);
837 } 840 }
838 if (ctrl->info->flags & UVC_CONTROL_GET_MAX) { 841 if (ctrl->info->flags & UVC_CONTROL_GET_MAX) {
839 if ((ret = uvc_query_ctrl(video->dev, GET_MAX, ctrl->entity->id, 842 ret = uvc_query_ctrl(chain->dev, UVC_GET_MAX, ctrl->entity->id,
840 video->dev->intfnum, ctrl->info->selector, 843 chain->dev->intfnum, ctrl->info->selector,
841 data, ctrl->info->size)) < 0) 844 data, ctrl->info->size);
845 if (ret < 0)
842 goto out; 846 goto out;
843 v4l2_ctrl->maximum = mapping->get(mapping, GET_MAX, data); 847 v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX, data);
844 } 848 }
845 if (ctrl->info->flags & UVC_CONTROL_GET_RES) { 849 if (ctrl->info->flags & UVC_CONTROL_GET_RES) {
846 if ((ret = uvc_query_ctrl(video->dev, GET_RES, ctrl->entity->id, 850 ret = uvc_query_ctrl(chain->dev, UVC_GET_RES, ctrl->entity->id,
847 video->dev->intfnum, ctrl->info->selector, 851 chain->dev->intfnum, ctrl->info->selector,
848 data, ctrl->info->size)) < 0) 852 data, ctrl->info->size);
853 if (ret < 0)
849 goto out; 854 goto out;
850 v4l2_ctrl->step = mapping->get(mapping, GET_RES, data); 855 v4l2_ctrl->step = mapping->get(mapping, UVC_GET_RES, data);
851 } 856 }
852 857
853 ret = 0; 858 ret = 0;
@@ -881,9 +886,9 @@ out:
881 * (UVC_CTRL_DATA_BACKUP) for all dirty controls. Both functions release the 886 * (UVC_CTRL_DATA_BACKUP) for all dirty controls. Both functions release the
882 * control lock. 887 * control lock.
883 */ 888 */
884int uvc_ctrl_begin(struct uvc_video_device *video) 889int uvc_ctrl_begin(struct uvc_video_chain *chain)
885{ 890{
886 return mutex_lock_interruptible(&video->ctrl_mutex) ? -ERESTARTSYS : 0; 891 return mutex_lock_interruptible(&chain->ctrl_mutex) ? -ERESTARTSYS : 0;
887} 892}
888 893
889static int uvc_ctrl_commit_entity(struct uvc_device *dev, 894static int uvc_ctrl_commit_entity(struct uvc_device *dev,
@@ -912,7 +917,7 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
912 continue; 917 continue;
913 918
914 if (!rollback) 919 if (!rollback)
915 ret = uvc_query_ctrl(dev, SET_CUR, ctrl->entity->id, 920 ret = uvc_query_ctrl(dev, UVC_SET_CUR, ctrl->entity->id,
916 dev->intfnum, ctrl->info->selector, 921 dev->intfnum, ctrl->info->selector,
917 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), 922 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
918 ctrl->info->size); 923 ctrl->info->size);
@@ -933,34 +938,34 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
933 return 0; 938 return 0;
934} 939}
935 940
936int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback) 941int __uvc_ctrl_commit(struct uvc_video_chain *chain, int rollback)
937{ 942{
938 struct uvc_entity *entity; 943 struct uvc_entity *entity;
939 int ret = 0; 944 int ret = 0;
940 945
941 /* Find the control. */ 946 /* Find the control. */
942 ret = uvc_ctrl_commit_entity(video->dev, video->processing, rollback); 947 ret = uvc_ctrl_commit_entity(chain->dev, chain->processing, rollback);
943 if (ret < 0) 948 if (ret < 0)
944 goto done; 949 goto done;
945 950
946 list_for_each_entry(entity, &video->iterms, chain) { 951 list_for_each_entry(entity, &chain->iterms, chain) {
947 ret = uvc_ctrl_commit_entity(video->dev, entity, rollback); 952 ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback);
948 if (ret < 0) 953 if (ret < 0)
949 goto done; 954 goto done;
950 } 955 }
951 956
952 list_for_each_entry(entity, &video->extensions, chain) { 957 list_for_each_entry(entity, &chain->extensions, chain) {
953 ret = uvc_ctrl_commit_entity(video->dev, entity, rollback); 958 ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback);
954 if (ret < 0) 959 if (ret < 0)
955 goto done; 960 goto done;
956 } 961 }
957 962
958done: 963done:
959 mutex_unlock(&video->ctrl_mutex); 964 mutex_unlock(&chain->ctrl_mutex);
960 return ret; 965 return ret;
961} 966}
962 967
963int uvc_ctrl_get(struct uvc_video_device *video, 968int uvc_ctrl_get(struct uvc_video_chain *chain,
964 struct v4l2_ext_control *xctrl) 969 struct v4l2_ext_control *xctrl)
965{ 970{
966 struct uvc_control *ctrl; 971 struct uvc_control *ctrl;
@@ -969,13 +974,13 @@ int uvc_ctrl_get(struct uvc_video_device *video,
969 unsigned int i; 974 unsigned int i;
970 int ret; 975 int ret;
971 976
972 ctrl = uvc_find_control(video, xctrl->id, &mapping); 977 ctrl = uvc_find_control(chain, xctrl->id, &mapping);
973 if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_GET_CUR) == 0) 978 if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_GET_CUR) == 0)
974 return -EINVAL; 979 return -EINVAL;
975 980
976 if (!ctrl->loaded) { 981 if (!ctrl->loaded) {
977 ret = uvc_query_ctrl(video->dev, GET_CUR, ctrl->entity->id, 982 ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, ctrl->entity->id,
978 video->dev->intfnum, ctrl->info->selector, 983 chain->dev->intfnum, ctrl->info->selector,
979 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), 984 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
980 ctrl->info->size); 985 ctrl->info->size);
981 if (ret < 0) 986 if (ret < 0)
@@ -984,7 +989,7 @@ int uvc_ctrl_get(struct uvc_video_device *video,
984 ctrl->loaded = 1; 989 ctrl->loaded = 1;
985 } 990 }
986 991
987 xctrl->value = mapping->get(mapping, GET_CUR, 992 xctrl->value = mapping->get(mapping, UVC_GET_CUR,
988 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT)); 993 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
989 994
990 if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) { 995 if (mapping->v4l2_type == V4L2_CTRL_TYPE_MENU) {
@@ -1000,7 +1005,7 @@ int uvc_ctrl_get(struct uvc_video_device *video,
1000 return 0; 1005 return 0;
1001} 1006}
1002 1007
1003int uvc_ctrl_set(struct uvc_video_device *video, 1008int uvc_ctrl_set(struct uvc_video_chain *chain,
1004 struct v4l2_ext_control *xctrl) 1009 struct v4l2_ext_control *xctrl)
1005{ 1010{
1006 struct uvc_control *ctrl; 1011 struct uvc_control *ctrl;
@@ -1008,7 +1013,7 @@ int uvc_ctrl_set(struct uvc_video_device *video,
1008 s32 value = xctrl->value; 1013 s32 value = xctrl->value;
1009 int ret; 1014 int ret;
1010 1015
1011 ctrl = uvc_find_control(video, xctrl->id, &mapping); 1016 ctrl = uvc_find_control(chain, xctrl->id, &mapping);
1012 if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_SET_CUR) == 0) 1017 if (ctrl == NULL || (ctrl->info->flags & UVC_CONTROL_SET_CUR) == 0)
1013 return -EINVAL; 1018 return -EINVAL;
1014 1019
@@ -1023,8 +1028,8 @@ int uvc_ctrl_set(struct uvc_video_device *video,
1023 memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), 1028 memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
1024 0, ctrl->info->size); 1029 0, ctrl->info->size);
1025 } else { 1030 } else {
1026 ret = uvc_query_ctrl(video->dev, GET_CUR, 1031 ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR,
1027 ctrl->entity->id, video->dev->intfnum, 1032 ctrl->entity->id, chain->dev->intfnum,
1028 ctrl->info->selector, 1033 ctrl->info->selector,
1029 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT), 1034 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
1030 ctrl->info->size); 1035 ctrl->info->size);
@@ -1053,7 +1058,7 @@ int uvc_ctrl_set(struct uvc_video_device *video,
1053 * Dynamic controls 1058 * Dynamic controls
1054 */ 1059 */
1055 1060
1056int uvc_xu_ctrl_query(struct uvc_video_device *video, 1061int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
1057 struct uvc_xu_control *xctrl, int set) 1062 struct uvc_xu_control *xctrl, int set)
1058{ 1063{
1059 struct uvc_entity *entity; 1064 struct uvc_entity *entity;
@@ -1063,7 +1068,7 @@ int uvc_xu_ctrl_query(struct uvc_video_device *video,
1063 int ret; 1068 int ret;
1064 1069
1065 /* Find the extension unit. */ 1070 /* Find the extension unit. */
1066 list_for_each_entry(entity, &video->extensions, chain) { 1071 list_for_each_entry(entity, &chain->extensions, chain) {
1067 if (entity->id == xctrl->unit) 1072 if (entity->id == xctrl->unit)
1068 break; 1073 break;
1069 } 1074 }
@@ -1102,7 +1107,7 @@ int uvc_xu_ctrl_query(struct uvc_video_device *video,
1102 (!set && !(ctrl->info->flags & UVC_CONTROL_GET_CUR))) 1107 (!set && !(ctrl->info->flags & UVC_CONTROL_GET_CUR)))
1103 return -EINVAL; 1108 return -EINVAL;
1104 1109
1105 if (mutex_lock_interruptible(&video->ctrl_mutex)) 1110 if (mutex_lock_interruptible(&chain->ctrl_mutex))
1106 return -ERESTARTSYS; 1111 return -ERESTARTSYS;
1107 1112
1108 memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), 1113 memcpy(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP),
@@ -1115,9 +1120,9 @@ int uvc_xu_ctrl_query(struct uvc_video_device *video,
1115 goto out; 1120 goto out;
1116 } 1121 }
1117 1122
1118 ret = uvc_query_ctrl(video->dev, set ? SET_CUR : GET_CUR, xctrl->unit, 1123 ret = uvc_query_ctrl(chain->dev, set ? UVC_SET_CUR : UVC_GET_CUR,
1119 video->dev->intfnum, xctrl->selector, data, 1124 xctrl->unit, chain->dev->intfnum, xctrl->selector,
1120 xctrl->size); 1125 data, xctrl->size);
1121 if (ret < 0) 1126 if (ret < 0)
1122 goto out; 1127 goto out;
1123 1128
@@ -1132,7 +1137,7 @@ out:
1132 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP), 1137 uvc_ctrl_data(ctrl, UVC_CTRL_DATA_BACKUP),
1133 xctrl->size); 1138 xctrl->size);
1134 1139
1135 mutex_unlock(&video->ctrl_mutex); 1140 mutex_unlock(&chain->ctrl_mutex);
1136 return ret; 1141 return ret;
1137} 1142}
1138 1143
@@ -1211,7 +1216,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
1211 if (!found) 1216 if (!found)
1212 return; 1217 return;
1213 1218
1214 if (UVC_ENTITY_TYPE(entity) == VC_EXTENSION_UNIT) { 1219 if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) {
1215 /* Check if the device control information and length match 1220 /* Check if the device control information and length match
1216 * the user supplied information. 1221 * the user supplied information.
1217 */ 1222 */
@@ -1219,8 +1224,9 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
1219 __le16 size; 1224 __le16 size;
1220 __u8 inf; 1225 __u8 inf;
1221 1226
1222 if ((ret = uvc_query_ctrl(dev, GET_LEN, ctrl->entity->id, 1227 ret = uvc_query_ctrl(dev, UVC_GET_LEN, ctrl->entity->id,
1223 dev->intfnum, info->selector, (__u8 *)&size, 2)) < 0) { 1228 dev->intfnum, info->selector, (__u8 *)&size, 2);
1229 if (ret < 0) {
1224 uvc_trace(UVC_TRACE_CONTROL, "GET_LEN failed on " 1230 uvc_trace(UVC_TRACE_CONTROL, "GET_LEN failed on "
1225 "control " UVC_GUID_FORMAT "/%u (%d).\n", 1231 "control " UVC_GUID_FORMAT "/%u (%d).\n",
1226 UVC_GUID_ARGS(info->entity), info->selector, 1232 UVC_GUID_ARGS(info->entity), info->selector,
@@ -1236,8 +1242,9 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev,
1236 return; 1242 return;
1237 } 1243 }
1238 1244
1239 if ((ret = uvc_query_ctrl(dev, GET_INFO, ctrl->entity->id, 1245 ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id,
1240 dev->intfnum, info->selector, &inf, 1)) < 0) { 1246 dev->intfnum, info->selector, &inf, 1);
1247 if (ret < 0) {
1241 uvc_trace(UVC_TRACE_CONTROL, "GET_INFO failed on " 1248 uvc_trace(UVC_TRACE_CONTROL, "GET_INFO failed on "
1242 "control " UVC_GUID_FORMAT "/%u (%d).\n", 1249 "control " UVC_GUID_FORMAT "/%u (%d).\n",
1243 UVC_GUID_ARGS(info->entity), info->selector, 1250 UVC_GUID_ARGS(info->entity), info->selector,
@@ -1391,7 +1398,7 @@ uvc_ctrl_prune_entity(struct uvc_device *dev, struct uvc_entity *entity)
1391 unsigned int size; 1398 unsigned int size;
1392 unsigned int i; 1399 unsigned int i;
1393 1400
1394 if (UVC_ENTITY_TYPE(entity) != VC_PROCESSING_UNIT) 1401 if (UVC_ENTITY_TYPE(entity) != UVC_VC_PROCESSING_UNIT)
1395 return; 1402 return;
1396 1403
1397 controls = entity->processing.bmControls; 1404 controls = entity->processing.bmControls;
@@ -1427,13 +1434,13 @@ int uvc_ctrl_init_device(struct uvc_device *dev)
1427 unsigned int bControlSize = 0, ncontrols = 0; 1434 unsigned int bControlSize = 0, ncontrols = 0;
1428 __u8 *bmControls = NULL; 1435 __u8 *bmControls = NULL;
1429 1436
1430 if (UVC_ENTITY_TYPE(entity) == VC_EXTENSION_UNIT) { 1437 if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) {
1431 bmControls = entity->extension.bmControls; 1438 bmControls = entity->extension.bmControls;
1432 bControlSize = entity->extension.bControlSize; 1439 bControlSize = entity->extension.bControlSize;
1433 } else if (UVC_ENTITY_TYPE(entity) == VC_PROCESSING_UNIT) { 1440 } else if (UVC_ENTITY_TYPE(entity) == UVC_VC_PROCESSING_UNIT) {
1434 bmControls = entity->processing.bmControls; 1441 bmControls = entity->processing.bmControls;
1435 bControlSize = entity->processing.bControlSize; 1442 bControlSize = entity->processing.bControlSize;
1436 } else if (UVC_ENTITY_TYPE(entity) == ITT_CAMERA) { 1443 } else if (UVC_ENTITY_TYPE(entity) == UVC_ITT_CAMERA) {
1437 bmControls = entity->camera.bmControls; 1444 bmControls = entity->camera.bmControls;
1438 bControlSize = entity->camera.bControlSize; 1445 bControlSize = entity->camera.bControlSize;
1439 } 1446 }
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index 04b47832fa0a..8756be569154 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -249,23 +249,23 @@ static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
249 249
250 list_for_each_entry_continue(entity, &dev->entities, list) { 250 list_for_each_entry_continue(entity, &dev->entities, list) {
251 switch (UVC_ENTITY_TYPE(entity)) { 251 switch (UVC_ENTITY_TYPE(entity)) {
252 case TT_STREAMING: 252 case UVC_TT_STREAMING:
253 if (entity->output.bSourceID == id) 253 if (entity->output.bSourceID == id)
254 return entity; 254 return entity;
255 break; 255 break;
256 256
257 case VC_PROCESSING_UNIT: 257 case UVC_VC_PROCESSING_UNIT:
258 if (entity->processing.bSourceID == id) 258 if (entity->processing.bSourceID == id)
259 return entity; 259 return entity;
260 break; 260 break;
261 261
262 case VC_SELECTOR_UNIT: 262 case UVC_VC_SELECTOR_UNIT:
263 for (i = 0; i < entity->selector.bNrInPins; ++i) 263 for (i = 0; i < entity->selector.bNrInPins; ++i)
264 if (entity->selector.baSourceID[i] == id) 264 if (entity->selector.baSourceID[i] == id)
265 return entity; 265 return entity;
266 break; 266 break;
267 267
268 case VC_EXTENSION_UNIT: 268 case UVC_VC_EXTENSION_UNIT:
269 for (i = 0; i < entity->extension.bNrInPins; ++i) 269 for (i = 0; i < entity->extension.bNrInPins; ++i)
270 if (entity->extension.baSourceID[i] == id) 270 if (entity->extension.baSourceID[i] == id)
271 return entity; 271 return entity;
@@ -276,8 +276,20 @@ static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
276 return NULL; 276 return NULL;
277} 277}
278 278
279static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id)
280{
281 struct uvc_streaming *stream;
282
283 list_for_each_entry(stream, &dev->streams, list) {
284 if (stream->header.bTerminalLink == id)
285 return stream;
286 }
287
288 return NULL;
289}
290
279/* ------------------------------------------------------------------------ 291/* ------------------------------------------------------------------------
280 * Descriptors handling 292 * Descriptors parsing
281 */ 293 */
282 294
283static int uvc_parse_format(struct uvc_device *dev, 295static int uvc_parse_format(struct uvc_device *dev,
@@ -297,9 +309,9 @@ static int uvc_parse_format(struct uvc_device *dev,
297 format->index = buffer[3]; 309 format->index = buffer[3];
298 310
299 switch (buffer[2]) { 311 switch (buffer[2]) {
300 case VS_FORMAT_UNCOMPRESSED: 312 case UVC_VS_FORMAT_UNCOMPRESSED:
301 case VS_FORMAT_FRAME_BASED: 313 case UVC_VS_FORMAT_FRAME_BASED:
302 n = buffer[2] == VS_FORMAT_UNCOMPRESSED ? 27 : 28; 314 n = buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED ? 27 : 28;
303 if (buflen < n) { 315 if (buflen < n) {
304 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " 316 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
305 "interface %d FORMAT error\n", 317 "interface %d FORMAT error\n",
@@ -325,16 +337,16 @@ static int uvc_parse_format(struct uvc_device *dev,
325 } 337 }
326 338
327 format->bpp = buffer[21]; 339 format->bpp = buffer[21];
328 if (buffer[2] == VS_FORMAT_UNCOMPRESSED) { 340 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
329 ftype = VS_FRAME_UNCOMPRESSED; 341 ftype = UVC_VS_FRAME_UNCOMPRESSED;
330 } else { 342 } else {
331 ftype = VS_FRAME_FRAME_BASED; 343 ftype = UVC_VS_FRAME_FRAME_BASED;
332 if (buffer[27]) 344 if (buffer[27])
333 format->flags = UVC_FMT_FLAG_COMPRESSED; 345 format->flags = UVC_FMT_FLAG_COMPRESSED;
334 } 346 }
335 break; 347 break;
336 348
337 case VS_FORMAT_MJPEG: 349 case UVC_VS_FORMAT_MJPEG:
338 if (buflen < 11) { 350 if (buflen < 11) {
339 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " 351 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
340 "interface %d FORMAT error\n", 352 "interface %d FORMAT error\n",
@@ -347,10 +359,10 @@ static int uvc_parse_format(struct uvc_device *dev,
347 format->fcc = V4L2_PIX_FMT_MJPEG; 359 format->fcc = V4L2_PIX_FMT_MJPEG;
348 format->flags = UVC_FMT_FLAG_COMPRESSED; 360 format->flags = UVC_FMT_FLAG_COMPRESSED;
349 format->bpp = 0; 361 format->bpp = 0;
350 ftype = VS_FRAME_MJPEG; 362 ftype = UVC_VS_FRAME_MJPEG;
351 break; 363 break;
352 364
353 case VS_FORMAT_DV: 365 case UVC_VS_FORMAT_DV:
354 if (buflen < 9) { 366 if (buflen < 9) {
355 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " 367 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
356 "interface %d FORMAT error\n", 368 "interface %d FORMAT error\n",
@@ -395,8 +407,8 @@ static int uvc_parse_format(struct uvc_device *dev,
395 format->nframes = 1; 407 format->nframes = 1;
396 break; 408 break;
397 409
398 case VS_FORMAT_MPEG2TS: 410 case UVC_VS_FORMAT_MPEG2TS:
399 case VS_FORMAT_STREAM_BASED: 411 case UVC_VS_FORMAT_STREAM_BASED:
400 /* Not supported yet. */ 412 /* Not supported yet. */
401 default: 413 default:
402 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " 414 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
@@ -416,7 +428,7 @@ static int uvc_parse_format(struct uvc_device *dev,
416 */ 428 */
417 while (buflen > 2 && buffer[2] == ftype) { 429 while (buflen > 2 && buffer[2] == ftype) {
418 frame = &format->frame[format->nframes]; 430 frame = &format->frame[format->nframes];
419 if (ftype != VS_FRAME_FRAME_BASED) 431 if (ftype != UVC_VS_FRAME_FRAME_BASED)
420 n = buflen > 25 ? buffer[25] : 0; 432 n = buflen > 25 ? buffer[25] : 0;
421 else 433 else
422 n = buflen > 21 ? buffer[21] : 0; 434 n = buflen > 21 ? buffer[21] : 0;
@@ -436,7 +448,7 @@ static int uvc_parse_format(struct uvc_device *dev,
436 frame->wHeight = get_unaligned_le16(&buffer[7]); 448 frame->wHeight = get_unaligned_le16(&buffer[7]);
437 frame->dwMinBitRate = get_unaligned_le32(&buffer[9]); 449 frame->dwMinBitRate = get_unaligned_le32(&buffer[9]);
438 frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]); 450 frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]);
439 if (ftype != VS_FRAME_FRAME_BASED) { 451 if (ftype != UVC_VS_FRAME_FRAME_BASED) {
440 frame->dwMaxVideoFrameBufferSize = 452 frame->dwMaxVideoFrameBufferSize =
441 get_unaligned_le32(&buffer[17]); 453 get_unaligned_le32(&buffer[17]);
442 frame->dwDefaultFrameInterval = 454 frame->dwDefaultFrameInterval =
@@ -491,12 +503,12 @@ static int uvc_parse_format(struct uvc_device *dev,
491 buffer += buffer[0]; 503 buffer += buffer[0];
492 } 504 }
493 505
494 if (buflen > 2 && buffer[2] == VS_STILL_IMAGE_FRAME) { 506 if (buflen > 2 && buffer[2] == UVC_VS_STILL_IMAGE_FRAME) {
495 buflen -= buffer[0]; 507 buflen -= buffer[0];
496 buffer += buffer[0]; 508 buffer += buffer[0];
497 } 509 }
498 510
499 if (buflen > 2 && buffer[2] == VS_COLORFORMAT) { 511 if (buflen > 2 && buffer[2] == UVC_VS_COLORFORMAT) {
500 if (buflen < 6) { 512 if (buflen < 6) {
501 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " 513 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
502 "interface %d COLORFORMAT error\n", 514 "interface %d COLORFORMAT error\n",
@@ -530,7 +542,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
530 int ret = -EINVAL; 542 int ret = -EINVAL;
531 543
532 if (intf->cur_altsetting->desc.bInterfaceSubClass 544 if (intf->cur_altsetting->desc.bInterfaceSubClass
533 != SC_VIDEOSTREAMING) { 545 != UVC_SC_VIDEOSTREAMING) {
534 uvc_trace(UVC_TRACE_DESCR, "device %d interface %d isn't a " 546 uvc_trace(UVC_TRACE_DESCR, "device %d interface %d isn't a "
535 "video streaming interface\n", dev->udev->devnum, 547 "video streaming interface\n", dev->udev->devnum,
536 intf->altsetting[0].desc.bInterfaceNumber); 548 intf->altsetting[0].desc.bInterfaceNumber);
@@ -551,6 +563,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
551 } 563 }
552 564
553 mutex_init(&streaming->mutex); 565 mutex_init(&streaming->mutex);
566 streaming->dev = dev;
554 streaming->intf = usb_get_intf(intf); 567 streaming->intf = usb_get_intf(intf);
555 streaming->intfnum = intf->cur_altsetting->desc.bInterfaceNumber; 568 streaming->intfnum = intf->cur_altsetting->desc.bInterfaceNumber;
556 569
@@ -589,12 +602,12 @@ static int uvc_parse_streaming(struct uvc_device *dev,
589 602
590 /* Parse the header descriptor. */ 603 /* Parse the header descriptor. */
591 switch (buffer[2]) { 604 switch (buffer[2]) {
592 case VS_OUTPUT_HEADER: 605 case UVC_VS_OUTPUT_HEADER:
593 streaming->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 606 streaming->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
594 size = 9; 607 size = 9;
595 break; 608 break;
596 609
597 case VS_INPUT_HEADER: 610 case UVC_VS_INPUT_HEADER:
598 streaming->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 611 streaming->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
599 size = 13; 612 size = 13;
600 break; 613 break;
@@ -618,7 +631,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
618 631
619 streaming->header.bNumFormats = p; 632 streaming->header.bNumFormats = p;
620 streaming->header.bEndpointAddress = buffer[6]; 633 streaming->header.bEndpointAddress = buffer[6];
621 if (buffer[2] == VS_INPUT_HEADER) { 634 if (buffer[2] == UVC_VS_INPUT_HEADER) {
622 streaming->header.bmInfo = buffer[7]; 635 streaming->header.bmInfo = buffer[7];
623 streaming->header.bTerminalLink = buffer[8]; 636 streaming->header.bTerminalLink = buffer[8];
624 streaming->header.bStillCaptureMethod = buffer[9]; 637 streaming->header.bStillCaptureMethod = buffer[9];
@@ -644,15 +657,15 @@ static int uvc_parse_streaming(struct uvc_device *dev,
644 _buflen = buflen; 657 _buflen = buflen;
645 658
646 /* Count the format and frame descriptors. */ 659 /* Count the format and frame descriptors. */
647 while (_buflen > 2 && _buffer[1] == CS_INTERFACE) { 660 while (_buflen > 2 && _buffer[1] == USB_DT_CS_INTERFACE) {
648 switch (_buffer[2]) { 661 switch (_buffer[2]) {
649 case VS_FORMAT_UNCOMPRESSED: 662 case UVC_VS_FORMAT_UNCOMPRESSED:
650 case VS_FORMAT_MJPEG: 663 case UVC_VS_FORMAT_MJPEG:
651 case VS_FORMAT_FRAME_BASED: 664 case UVC_VS_FORMAT_FRAME_BASED:
652 nformats++; 665 nformats++;
653 break; 666 break;
654 667
655 case VS_FORMAT_DV: 668 case UVC_VS_FORMAT_DV:
656 /* DV format has no frame descriptor. We will create a 669 /* DV format has no frame descriptor. We will create a
657 * dummy frame descriptor with a dummy frame interval. 670 * dummy frame descriptor with a dummy frame interval.
658 */ 671 */
@@ -661,22 +674,22 @@ static int uvc_parse_streaming(struct uvc_device *dev,
661 nintervals++; 674 nintervals++;
662 break; 675 break;
663 676
664 case VS_FORMAT_MPEG2TS: 677 case UVC_VS_FORMAT_MPEG2TS:
665 case VS_FORMAT_STREAM_BASED: 678 case UVC_VS_FORMAT_STREAM_BASED:
666 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming " 679 uvc_trace(UVC_TRACE_DESCR, "device %d videostreaming "
667 "interface %d FORMAT %u is not supported.\n", 680 "interface %d FORMAT %u is not supported.\n",
668 dev->udev->devnum, 681 dev->udev->devnum,
669 alts->desc.bInterfaceNumber, _buffer[2]); 682 alts->desc.bInterfaceNumber, _buffer[2]);
670 break; 683 break;
671 684
672 case VS_FRAME_UNCOMPRESSED: 685 case UVC_VS_FRAME_UNCOMPRESSED:
673 case VS_FRAME_MJPEG: 686 case UVC_VS_FRAME_MJPEG:
674 nframes++; 687 nframes++;
675 if (_buflen > 25) 688 if (_buflen > 25)
676 nintervals += _buffer[25] ? _buffer[25] : 3; 689 nintervals += _buffer[25] ? _buffer[25] : 3;
677 break; 690 break;
678 691
679 case VS_FRAME_FRAME_BASED: 692 case UVC_VS_FRAME_FRAME_BASED:
680 nframes++; 693 nframes++;
681 if (_buflen > 21) 694 if (_buflen > 21)
682 nintervals += _buffer[21] ? _buffer[21] : 3; 695 nintervals += _buffer[21] ? _buffer[21] : 3;
@@ -709,12 +722,12 @@ static int uvc_parse_streaming(struct uvc_device *dev,
709 streaming->nformats = nformats; 722 streaming->nformats = nformats;
710 723
711 /* Parse the format descriptors. */ 724 /* Parse the format descriptors. */
712 while (buflen > 2 && buffer[1] == CS_INTERFACE) { 725 while (buflen > 2 && buffer[1] == USB_DT_CS_INTERFACE) {
713 switch (buffer[2]) { 726 switch (buffer[2]) {
714 case VS_FORMAT_UNCOMPRESSED: 727 case UVC_VS_FORMAT_UNCOMPRESSED:
715 case VS_FORMAT_MJPEG: 728 case UVC_VS_FORMAT_MJPEG:
716 case VS_FORMAT_DV: 729 case UVC_VS_FORMAT_DV:
717 case VS_FORMAT_FRAME_BASED: 730 case UVC_VS_FORMAT_FRAME_BASED:
718 format->frame = frame; 731 format->frame = frame;
719 ret = uvc_parse_format(dev, streaming, format, 732 ret = uvc_parse_format(dev, streaming, format,
720 &interval, buffer, buflen); 733 &interval, buffer, buflen);
@@ -751,7 +764,7 @@ static int uvc_parse_streaming(struct uvc_device *dev,
751 streaming->maxpsize = psize; 764 streaming->maxpsize = psize;
752 } 765 }
753 766
754 list_add_tail(&streaming->list, &dev->streaming); 767 list_add_tail(&streaming->list, &dev->streams);
755 return 0; 768 return 0;
756 769
757error: 770error:
@@ -819,7 +832,7 @@ static int uvc_parse_vendor_control(struct uvc_device *dev,
819 return -ENOMEM; 832 return -ENOMEM;
820 833
821 unit->id = buffer[3]; 834 unit->id = buffer[3];
822 unit->type = VC_EXTENSION_UNIT; 835 unit->type = UVC_VC_EXTENSION_UNIT;
823 memcpy(unit->extension.guidExtensionCode, &buffer[4], 16); 836 memcpy(unit->extension.guidExtensionCode, &buffer[4], 16);
824 unit->extension.bNumControls = buffer[20]; 837 unit->extension.bNumControls = buffer[20];
825 unit->extension.bNrInPins = get_unaligned_le16(&buffer[21]); 838 unit->extension.bNrInPins = get_unaligned_le16(&buffer[21]);
@@ -856,7 +869,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
856 __u16 type; 869 __u16 type;
857 870
858 switch (buffer[2]) { 871 switch (buffer[2]) {
859 case VC_HEADER: 872 case UVC_VC_HEADER:
860 n = buflen >= 12 ? buffer[11] : 0; 873 n = buflen >= 12 ? buffer[11] : 0;
861 874
862 if (buflen < 12 || buflen < 12 + n) { 875 if (buflen < 12 || buflen < 12 + n) {
@@ -883,7 +896,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
883 } 896 }
884 break; 897 break;
885 898
886 case VC_INPUT_TERMINAL: 899 case UVC_VC_INPUT_TERMINAL:
887 if (buflen < 8) { 900 if (buflen < 8) {
888 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " 901 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
889 "interface %d INPUT_TERMINAL error\n", 902 "interface %d INPUT_TERMINAL error\n",
@@ -908,11 +921,11 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
908 p = 0; 921 p = 0;
909 len = 8; 922 len = 8;
910 923
911 if (type == ITT_CAMERA) { 924 if (type == UVC_ITT_CAMERA) {
912 n = buflen >= 15 ? buffer[14] : 0; 925 n = buflen >= 15 ? buffer[14] : 0;
913 len = 15; 926 len = 15;
914 927
915 } else if (type == ITT_MEDIA_TRANSPORT_INPUT) { 928 } else if (type == UVC_ITT_MEDIA_TRANSPORT_INPUT) {
916 n = buflen >= 9 ? buffer[8] : 0; 929 n = buflen >= 9 ? buffer[8] : 0;
917 p = buflen >= 10 + n ? buffer[9+n] : 0; 930 p = buflen >= 10 + n ? buffer[9+n] : 0;
918 len = 10; 931 len = 10;
@@ -932,7 +945,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
932 term->id = buffer[3]; 945 term->id = buffer[3];
933 term->type = type | UVC_TERM_INPUT; 946 term->type = type | UVC_TERM_INPUT;
934 947
935 if (UVC_ENTITY_TYPE(term) == ITT_CAMERA) { 948 if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA) {
936 term->camera.bControlSize = n; 949 term->camera.bControlSize = n;
937 term->camera.bmControls = (__u8 *)term + sizeof *term; 950 term->camera.bmControls = (__u8 *)term + sizeof *term;
938 term->camera.wObjectiveFocalLengthMin = 951 term->camera.wObjectiveFocalLengthMin =
@@ -942,7 +955,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
942 term->camera.wOcularFocalLength = 955 term->camera.wOcularFocalLength =
943 get_unaligned_le16(&buffer[12]); 956 get_unaligned_le16(&buffer[12]);
944 memcpy(term->camera.bmControls, &buffer[15], n); 957 memcpy(term->camera.bmControls, &buffer[15], n);
945 } else if (UVC_ENTITY_TYPE(term) == ITT_MEDIA_TRANSPORT_INPUT) { 958 } else if (UVC_ENTITY_TYPE(term) ==
959 UVC_ITT_MEDIA_TRANSPORT_INPUT) {
946 term->media.bControlSize = n; 960 term->media.bControlSize = n;
947 term->media.bmControls = (__u8 *)term + sizeof *term; 961 term->media.bmControls = (__u8 *)term + sizeof *term;
948 term->media.bTransportModeSize = p; 962 term->media.bTransportModeSize = p;
@@ -955,9 +969,9 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
955 if (buffer[7] != 0) 969 if (buffer[7] != 0)
956 usb_string(udev, buffer[7], term->name, 970 usb_string(udev, buffer[7], term->name,
957 sizeof term->name); 971 sizeof term->name);
958 else if (UVC_ENTITY_TYPE(term) == ITT_CAMERA) 972 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_CAMERA)
959 sprintf(term->name, "Camera %u", buffer[3]); 973 sprintf(term->name, "Camera %u", buffer[3]);
960 else if (UVC_ENTITY_TYPE(term) == ITT_MEDIA_TRANSPORT_INPUT) 974 else if (UVC_ENTITY_TYPE(term) == UVC_ITT_MEDIA_TRANSPORT_INPUT)
961 sprintf(term->name, "Media %u", buffer[3]); 975 sprintf(term->name, "Media %u", buffer[3]);
962 else 976 else
963 sprintf(term->name, "Input %u", buffer[3]); 977 sprintf(term->name, "Input %u", buffer[3]);
@@ -965,7 +979,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
965 list_add_tail(&term->list, &dev->entities); 979 list_add_tail(&term->list, &dev->entities);
966 break; 980 break;
967 981
968 case VC_OUTPUT_TERMINAL: 982 case UVC_VC_OUTPUT_TERMINAL:
969 if (buflen < 9) { 983 if (buflen < 9) {
970 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol " 984 uvc_trace(UVC_TRACE_DESCR, "device %d videocontrol "
971 "interface %d OUTPUT_TERMINAL error\n", 985 "interface %d OUTPUT_TERMINAL error\n",
@@ -1002,7 +1016,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
1002 list_add_tail(&term->list, &dev->entities); 1016 list_add_tail(&term->list, &dev->entities);
1003 break; 1017 break;
1004 1018
1005 case VC_SELECTOR_UNIT: 1019 case UVC_VC_SELECTOR_UNIT:
1006 p = buflen >= 5 ? buffer[4] : 0; 1020 p = buflen >= 5 ? buffer[4] : 0;
1007 1021
1008 if (buflen < 5 || buflen < 6 + p) { 1022 if (buflen < 5 || buflen < 6 + p) {
@@ -1031,7 +1045,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
1031 list_add_tail(&unit->list, &dev->entities); 1045 list_add_tail(&unit->list, &dev->entities);
1032 break; 1046 break;
1033 1047
1034 case VC_PROCESSING_UNIT: 1048 case UVC_VC_PROCESSING_UNIT:
1035 n = buflen >= 8 ? buffer[7] : 0; 1049 n = buflen >= 8 ? buffer[7] : 0;
1036 p = dev->uvc_version >= 0x0110 ? 10 : 9; 1050 p = dev->uvc_version >= 0x0110 ? 10 : 9;
1037 1051
@@ -1066,7 +1080,7 @@ static int uvc_parse_standard_control(struct uvc_device *dev,
1066 list_add_tail(&unit->list, &dev->entities); 1080 list_add_tail(&unit->list, &dev->entities);
1067 break; 1081 break;
1068 1082
1069 case VC_EXTENSION_UNIT: 1083 case UVC_VC_EXTENSION_UNIT:
1070 p = buflen >= 22 ? buffer[21] : 0; 1084 p = buflen >= 22 ? buffer[21] : 0;
1071 n = buflen >= 24 + p ? buffer[22+p] : 0; 1085 n = buflen >= 24 + p ? buffer[22+p] : 0;
1072 1086
@@ -1158,43 +1172,40 @@ next_descriptor:
1158} 1172}
1159 1173
1160/* ------------------------------------------------------------------------ 1174/* ------------------------------------------------------------------------
1161 * USB probe and disconnect 1175 * UVC device scan
1162 */ 1176 */
1163 1177
1164/* 1178/*
1165 * Unregister the video devices.
1166 */
1167static void uvc_unregister_video(struct uvc_device *dev)
1168{
1169 if (dev->video.vdev) {
1170 if (dev->video.vdev->minor == -1)
1171 video_device_release(dev->video.vdev);
1172 else
1173 video_unregister_device(dev->video.vdev);
1174 dev->video.vdev = NULL;
1175 }
1176}
1177
1178/*
1179 * Scan the UVC descriptors to locate a chain starting at an Output Terminal 1179 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
1180 * and containing the following units: 1180 * and containing the following units:
1181 * 1181 *
1182 * - one Output Terminal (USB Streaming or Display) 1182 * - one or more Output Terminals (USB Streaming or Display)
1183 * - zero or one Processing Unit 1183 * - zero or one Processing Unit
1184 * - zero, one or mode single-input Selector Units 1184 * - zero, one or more single-input Selector Units
1185 * - zero or one multiple-input Selector Units, provided all inputs are 1185 * - zero or one multiple-input Selector Units, provided all inputs are
1186 * connected to input terminals 1186 * connected to input terminals
1187 * - zero, one or mode single-input Extension Units 1187 * - zero, one or mode single-input Extension Units
1188 * - one or more Input Terminals (Camera, External or USB Streaming) 1188 * - one or more Input Terminals (Camera, External or USB Streaming)
1189 * 1189 *
1190 * A side forward scan is made on each detected entity to check for additional 1190 * The terminal and units must match on of the following structures:
1191 * extension units. 1191 *
1192 * ITT_*(0) -> +---------+ +---------+ +---------+ -> TT_STREAMING(0)
1193 * ... | SU{0,1} | -> | PU{0,1} | -> | XU{0,n} | ...
1194 * ITT_*(n) -> +---------+ +---------+ +---------+ -> TT_STREAMING(n)
1195 *
1196 * +---------+ +---------+ -> OTT_*(0)
1197 * TT_STREAMING -> | PU{0,1} | -> | XU{0,n} | ...
1198 * +---------+ +---------+ -> OTT_*(n)
1199 *
1200 * The Processing Unit and Extension Units can be in any order. Additional
1201 * Extension Units connected to the main chain as single-unit branches are
1202 * also supported. Single-input Selector Units are ignored.
1192 */ 1203 */
1193static int uvc_scan_chain_entity(struct uvc_video_device *video, 1204static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
1194 struct uvc_entity *entity) 1205 struct uvc_entity *entity)
1195{ 1206{
1196 switch (UVC_ENTITY_TYPE(entity)) { 1207 switch (UVC_ENTITY_TYPE(entity)) {
1197 case VC_EXTENSION_UNIT: 1208 case UVC_VC_EXTENSION_UNIT:
1198 if (uvc_trace_param & UVC_TRACE_PROBE) 1209 if (uvc_trace_param & UVC_TRACE_PROBE)
1199 printk(" <- XU %d", entity->id); 1210 printk(" <- XU %d", entity->id);
1200 1211
@@ -1204,23 +1215,23 @@ static int uvc_scan_chain_entity(struct uvc_video_device *video,
1204 return -1; 1215 return -1;
1205 } 1216 }
1206 1217
1207 list_add_tail(&entity->chain, &video->extensions); 1218 list_add_tail(&entity->chain, &chain->extensions);
1208 break; 1219 break;
1209 1220
1210 case VC_PROCESSING_UNIT: 1221 case UVC_VC_PROCESSING_UNIT:
1211 if (uvc_trace_param & UVC_TRACE_PROBE) 1222 if (uvc_trace_param & UVC_TRACE_PROBE)
1212 printk(" <- PU %d", entity->id); 1223 printk(" <- PU %d", entity->id);
1213 1224
1214 if (video->processing != NULL) { 1225 if (chain->processing != NULL) {
1215 uvc_trace(UVC_TRACE_DESCR, "Found multiple " 1226 uvc_trace(UVC_TRACE_DESCR, "Found multiple "
1216 "Processing Units in chain.\n"); 1227 "Processing Units in chain.\n");
1217 return -1; 1228 return -1;
1218 } 1229 }
1219 1230
1220 video->processing = entity; 1231 chain->processing = entity;
1221 break; 1232 break;
1222 1233
1223 case VC_SELECTOR_UNIT: 1234 case UVC_VC_SELECTOR_UNIT:
1224 if (uvc_trace_param & UVC_TRACE_PROBE) 1235 if (uvc_trace_param & UVC_TRACE_PROBE)
1225 printk(" <- SU %d", entity->id); 1236 printk(" <- SU %d", entity->id);
1226 1237
@@ -1228,25 +1239,25 @@ static int uvc_scan_chain_entity(struct uvc_video_device *video,
1228 if (entity->selector.bNrInPins == 1) 1239 if (entity->selector.bNrInPins == 1)
1229 break; 1240 break;
1230 1241
1231 if (video->selector != NULL) { 1242 if (chain->selector != NULL) {
1232 uvc_trace(UVC_TRACE_DESCR, "Found multiple Selector " 1243 uvc_trace(UVC_TRACE_DESCR, "Found multiple Selector "
1233 "Units in chain.\n"); 1244 "Units in chain.\n");
1234 return -1; 1245 return -1;
1235 } 1246 }
1236 1247
1237 video->selector = entity; 1248 chain->selector = entity;
1238 break; 1249 break;
1239 1250
1240 case ITT_VENDOR_SPECIFIC: 1251 case UVC_ITT_VENDOR_SPECIFIC:
1241 case ITT_CAMERA: 1252 case UVC_ITT_CAMERA:
1242 case ITT_MEDIA_TRANSPORT_INPUT: 1253 case UVC_ITT_MEDIA_TRANSPORT_INPUT:
1243 if (uvc_trace_param & UVC_TRACE_PROBE) 1254 if (uvc_trace_param & UVC_TRACE_PROBE)
1244 printk(" <- IT %d\n", entity->id); 1255 printk(" <- IT %d\n", entity->id);
1245 1256
1246 list_add_tail(&entity->chain, &video->iterms); 1257 list_add_tail(&entity->chain, &chain->iterms);
1247 break; 1258 break;
1248 1259
1249 case TT_STREAMING: 1260 case UVC_TT_STREAMING:
1250 if (uvc_trace_param & UVC_TRACE_PROBE) 1261 if (uvc_trace_param & UVC_TRACE_PROBE)
1251 printk(" <- IT %d\n", entity->id); 1262 printk(" <- IT %d\n", entity->id);
1252 1263
@@ -1256,14 +1267,7 @@ static int uvc_scan_chain_entity(struct uvc_video_device *video,
1256 return -1; 1267 return -1;
1257 } 1268 }
1258 1269
1259 if (video->sterm != NULL) { 1270 list_add_tail(&entity->chain, &chain->iterms);
1260 uvc_trace(UVC_TRACE_DESCR, "Found multiple streaming "
1261 "entities in chain.\n");
1262 return -1;
1263 }
1264
1265 list_add_tail(&entity->chain, &video->iterms);
1266 video->sterm = entity;
1267 break; 1271 break;
1268 1272
1269 default: 1273 default:
@@ -1275,7 +1279,7 @@ static int uvc_scan_chain_entity(struct uvc_video_device *video,
1275 return 0; 1279 return 0;
1276} 1280}
1277 1281
1278static int uvc_scan_chain_forward(struct uvc_video_device *video, 1282static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
1279 struct uvc_entity *entity, struct uvc_entity *prev) 1283 struct uvc_entity *entity, struct uvc_entity *prev)
1280{ 1284{
1281 struct uvc_entity *forward; 1285 struct uvc_entity *forward;
@@ -1286,28 +1290,51 @@ static int uvc_scan_chain_forward(struct uvc_video_device *video,
1286 found = 0; 1290 found = 0;
1287 1291
1288 while (1) { 1292 while (1) {
1289 forward = uvc_entity_by_reference(video->dev, entity->id, 1293 forward = uvc_entity_by_reference(chain->dev, entity->id,
1290 forward); 1294 forward);
1291 if (forward == NULL) 1295 if (forward == NULL)
1292 break; 1296 break;
1293 1297 if (forward == prev)
1294 if (UVC_ENTITY_TYPE(forward) != VC_EXTENSION_UNIT ||
1295 forward == prev)
1296 continue; 1298 continue;
1297 1299
1298 if (forward->extension.bNrInPins != 1) { 1300 switch (UVC_ENTITY_TYPE(forward)) {
1299 uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has " 1301 case UVC_VC_EXTENSION_UNIT:
1300 "more than 1 input pin.\n", entity->id); 1302 if (forward->extension.bNrInPins != 1) {
1301 return -1; 1303 uvc_trace(UVC_TRACE_DESCR, "Extension unit %d "
1302 } 1304 "has more than 1 input pin.\n",
1305 entity->id);
1306 return -EINVAL;
1307 }
1308
1309 list_add_tail(&forward->chain, &chain->extensions);
1310 if (uvc_trace_param & UVC_TRACE_PROBE) {
1311 if (!found)
1312 printk(" (->");
1303 1313
1304 list_add_tail(&forward->chain, &video->extensions); 1314 printk(" XU %d", forward->id);
1305 if (uvc_trace_param & UVC_TRACE_PROBE) { 1315 found = 1;
1306 if (!found) 1316 }
1307 printk(" (-> XU"); 1317 break;
1318
1319 case UVC_OTT_VENDOR_SPECIFIC:
1320 case UVC_OTT_DISPLAY:
1321 case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
1322 case UVC_TT_STREAMING:
1323 if (UVC_ENTITY_IS_ITERM(forward)) {
1324 uvc_trace(UVC_TRACE_DESCR, "Unsupported input "
1325 "terminal %u.\n", forward->id);
1326 return -EINVAL;
1327 }
1308 1328
1309 printk(" %d", forward->id); 1329 list_add_tail(&forward->chain, &chain->oterms);
1310 found = 1; 1330 if (uvc_trace_param & UVC_TRACE_PROBE) {
1331 if (!found)
1332 printk(" (->");
1333
1334 printk(" OT %d", forward->id);
1335 found = 1;
1336 }
1337 break;
1311 } 1338 }
1312 } 1339 }
1313 if (found) 1340 if (found)
@@ -1316,22 +1343,22 @@ static int uvc_scan_chain_forward(struct uvc_video_device *video,
1316 return 0; 1343 return 0;
1317} 1344}
1318 1345
1319static int uvc_scan_chain_backward(struct uvc_video_device *video, 1346static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
1320 struct uvc_entity *entity) 1347 struct uvc_entity *entity)
1321{ 1348{
1322 struct uvc_entity *term; 1349 struct uvc_entity *term;
1323 int id = -1, i; 1350 int id = -1, i;
1324 1351
1325 switch (UVC_ENTITY_TYPE(entity)) { 1352 switch (UVC_ENTITY_TYPE(entity)) {
1326 case VC_EXTENSION_UNIT: 1353 case UVC_VC_EXTENSION_UNIT:
1327 id = entity->extension.baSourceID[0]; 1354 id = entity->extension.baSourceID[0];
1328 break; 1355 break;
1329 1356
1330 case VC_PROCESSING_UNIT: 1357 case UVC_VC_PROCESSING_UNIT:
1331 id = entity->processing.bSourceID; 1358 id = entity->processing.bSourceID;
1332 break; 1359 break;
1333 1360
1334 case VC_SELECTOR_UNIT: 1361 case UVC_VC_SELECTOR_UNIT:
1335 /* Single-input selector units are ignored. */ 1362 /* Single-input selector units are ignored. */
1336 if (entity->selector.bNrInPins == 1) { 1363 if (entity->selector.bNrInPins == 1) {
1337 id = entity->selector.baSourceID[0]; 1364 id = entity->selector.baSourceID[0];
@@ -1341,10 +1368,10 @@ static int uvc_scan_chain_backward(struct uvc_video_device *video,
1341 if (uvc_trace_param & UVC_TRACE_PROBE) 1368 if (uvc_trace_param & UVC_TRACE_PROBE)
1342 printk(" <- IT"); 1369 printk(" <- IT");
1343 1370
1344 video->selector = entity; 1371 chain->selector = entity;
1345 for (i = 0; i < entity->selector.bNrInPins; ++i) { 1372 for (i = 0; i < entity->selector.bNrInPins; ++i) {
1346 id = entity->selector.baSourceID[i]; 1373 id = entity->selector.baSourceID[i];
1347 term = uvc_entity_by_id(video->dev, id); 1374 term = uvc_entity_by_id(chain->dev, id);
1348 if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) { 1375 if (term == NULL || !UVC_ENTITY_IS_ITERM(term)) {
1349 uvc_trace(UVC_TRACE_DESCR, "Selector unit %d " 1376 uvc_trace(UVC_TRACE_DESCR, "Selector unit %d "
1350 "input %d isn't connected to an " 1377 "input %d isn't connected to an "
@@ -1355,8 +1382,8 @@ static int uvc_scan_chain_backward(struct uvc_video_device *video,
1355 if (uvc_trace_param & UVC_TRACE_PROBE) 1382 if (uvc_trace_param & UVC_TRACE_PROBE)
1356 printk(" %d", term->id); 1383 printk(" %d", term->id);
1357 1384
1358 list_add_tail(&term->chain, &video->iterms); 1385 list_add_tail(&term->chain, &chain->iterms);
1359 uvc_scan_chain_forward(video, term, entity); 1386 uvc_scan_chain_forward(chain, term, entity);
1360 } 1387 }
1361 1388
1362 if (uvc_trace_param & UVC_TRACE_PROBE) 1389 if (uvc_trace_param & UVC_TRACE_PROBE)
@@ -1369,125 +1396,170 @@ static int uvc_scan_chain_backward(struct uvc_video_device *video,
1369 return id; 1396 return id;
1370} 1397}
1371 1398
1372static int uvc_scan_chain(struct uvc_video_device *video) 1399static int uvc_scan_chain(struct uvc_video_chain *chain,
1400 struct uvc_entity *oterm)
1373{ 1401{
1374 struct uvc_entity *entity, *prev; 1402 struct uvc_entity *entity, *prev;
1375 int id; 1403 int id;
1376 1404
1377 entity = video->oterm; 1405 entity = oterm;
1406 list_add_tail(&entity->chain, &chain->oterms);
1378 uvc_trace(UVC_TRACE_PROBE, "Scanning UVC chain: OT %d", entity->id); 1407 uvc_trace(UVC_TRACE_PROBE, "Scanning UVC chain: OT %d", entity->id);
1379 1408
1380 if (UVC_ENTITY_TYPE(entity) == TT_STREAMING)
1381 video->sterm = entity;
1382
1383 id = entity->output.bSourceID; 1409 id = entity->output.bSourceID;
1384 while (id != 0) { 1410 while (id != 0) {
1385 prev = entity; 1411 prev = entity;
1386 entity = uvc_entity_by_id(video->dev, id); 1412 entity = uvc_entity_by_id(chain->dev, id);
1387 if (entity == NULL) { 1413 if (entity == NULL) {
1388 uvc_trace(UVC_TRACE_DESCR, "Found reference to " 1414 uvc_trace(UVC_TRACE_DESCR, "Found reference to "
1389 "unknown entity %d.\n", id); 1415 "unknown entity %d.\n", id);
1390 return -1; 1416 return -EINVAL;
1417 }
1418
1419 if (entity->chain.next || entity->chain.prev) {
1420 uvc_trace(UVC_TRACE_DESCR, "Found reference to "
1421 "entity %d already in chain.\n", id);
1422 return -EINVAL;
1391 } 1423 }
1392 1424
1393 /* Process entity */ 1425 /* Process entity */
1394 if (uvc_scan_chain_entity(video, entity) < 0) 1426 if (uvc_scan_chain_entity(chain, entity) < 0)
1395 return -1; 1427 return -EINVAL;
1396 1428
1397 /* Forward scan */ 1429 /* Forward scan */
1398 if (uvc_scan_chain_forward(video, entity, prev) < 0) 1430 if (uvc_scan_chain_forward(chain, entity, prev) < 0)
1399 return -1; 1431 return -EINVAL;
1400 1432
1401 /* Stop when a terminal is found. */ 1433 /* Stop when a terminal is found. */
1402 if (!UVC_ENTITY_IS_UNIT(entity)) 1434 if (UVC_ENTITY_IS_TERM(entity))
1403 break; 1435 break;
1404 1436
1405 /* Backward scan */ 1437 /* Backward scan */
1406 id = uvc_scan_chain_backward(video, entity); 1438 id = uvc_scan_chain_backward(chain, entity);
1407 if (id < 0) 1439 if (id < 0)
1408 return id; 1440 return id;
1409 } 1441 }
1410 1442
1411 if (video->sterm == NULL) { 1443 return 0;
1412 uvc_trace(UVC_TRACE_DESCR, "No streaming entity found in " 1444}
1413 "chain.\n"); 1445
1414 return -1; 1446static unsigned int uvc_print_terms(struct list_head *terms, char *buffer)
1447{
1448 struct uvc_entity *term;
1449 unsigned int nterms = 0;
1450 char *p = buffer;
1451
1452 list_for_each_entry(term, terms, chain) {
1453 p += sprintf(p, "%u", term->id);
1454 if (term->chain.next != terms) {
1455 p += sprintf(p, ",");
1456 if (++nterms >= 4) {
1457 p += sprintf(p, "...");
1458 break;
1459 }
1460 }
1415 } 1461 }
1416 1462
1417 return 0; 1463 return p - buffer;
1464}
1465
1466static const char *uvc_print_chain(struct uvc_video_chain *chain)
1467{
1468 static char buffer[43];
1469 char *p = buffer;
1470
1471 p += uvc_print_terms(&chain->iterms, p);
1472 p += sprintf(p, " -> ");
1473 uvc_print_terms(&chain->oterms, p);
1474
1475 return buffer;
1418} 1476}
1419 1477
1420/* 1478/*
1421 * Register the video devices. 1479 * Scan the device for video chains and register video devices.
1422 *
1423 * The driver currently supports a single video device per control interface
1424 * only. The terminal and units must match the following structure:
1425 * 1480 *
1426 * ITT_* -> VC_PROCESSING_UNIT -> VC_EXTENSION_UNIT{0,n} -> TT_STREAMING 1481 * Chains are scanned starting at their output terminals and walked backwards.
1427 * TT_STREAMING -> VC_PROCESSING_UNIT -> VC_EXTENSION_UNIT{0,n} -> OTT_*
1428 *
1429 * The Extension Units, if present, must have a single input pin. The
1430 * Processing Unit and Extension Units can be in any order. Additional
1431 * Extension Units connected to the main chain as single-unit branches are
1432 * also supported.
1433 */ 1482 */
1434static int uvc_register_video(struct uvc_device *dev) 1483static int uvc_scan_device(struct uvc_device *dev)
1435{ 1484{
1436 struct video_device *vdev; 1485 struct uvc_video_chain *chain;
1437 struct uvc_entity *term; 1486 struct uvc_entity *term;
1438 int found = 0, ret;
1439 1487
1440 /* Check if the control interface matches the structure we expect. */
1441 list_for_each_entry(term, &dev->entities, list) { 1488 list_for_each_entry(term, &dev->entities, list) {
1442 struct uvc_streaming *streaming; 1489 if (!UVC_ENTITY_IS_OTERM(term))
1443
1444 if (!UVC_ENTITY_IS_TERM(term) || !UVC_ENTITY_IS_OTERM(term))
1445 continue; 1490 continue;
1446 1491
1447 memset(&dev->video, 0, sizeof dev->video); 1492 /* If the terminal is already included in a chain, skip it.
1448 mutex_init(&dev->video.ctrl_mutex); 1493 * This can happen for chains that have multiple output
1449 INIT_LIST_HEAD(&dev->video.iterms); 1494 * terminals, where all output terminals beside the first one
1450 INIT_LIST_HEAD(&dev->video.extensions); 1495 * will be inserted in the chain in forward scans.
1451 dev->video.oterm = term; 1496 */
1452 dev->video.dev = dev; 1497 if (term->chain.next || term->chain.prev)
1453 if (uvc_scan_chain(&dev->video) < 0)
1454 continue; 1498 continue;
1455 1499
1456 list_for_each_entry(streaming, &dev->streaming, list) { 1500 chain = kzalloc(sizeof(*chain), GFP_KERNEL);
1457 if (streaming->header.bTerminalLink == 1501 if (chain == NULL)
1458 dev->video.sterm->id) { 1502 return -ENOMEM;
1459 dev->video.streaming = streaming; 1503
1460 found = 1; 1504 INIT_LIST_HEAD(&chain->iterms);
1461 break; 1505 INIT_LIST_HEAD(&chain->oterms);
1462 } 1506 INIT_LIST_HEAD(&chain->extensions);
1507 mutex_init(&chain->ctrl_mutex);
1508 chain->dev = dev;
1509
1510 if (uvc_scan_chain(chain, term) < 0) {
1511 kfree(chain);
1512 continue;
1463 } 1513 }
1464 1514
1465 if (found) 1515 uvc_trace(UVC_TRACE_PROBE, "Found a valid video chain (%s).\n",
1466 break; 1516 uvc_print_chain(chain));
1517
1518 list_add_tail(&chain->list, &dev->chains);
1467 } 1519 }
1468 1520
1469 if (!found) { 1521 if (list_empty(&dev->chains)) {
1470 uvc_printk(KERN_INFO, "No valid video chain found.\n"); 1522 uvc_printk(KERN_INFO, "No valid video chain found.\n");
1471 return -1; 1523 return -1;
1472 } 1524 }
1473 1525
1474 if (uvc_trace_param & UVC_TRACE_PROBE) { 1526 return 0;
1475 uvc_printk(KERN_INFO, "Found a valid video chain ("); 1527}
1476 list_for_each_entry(term, &dev->video.iterms, chain) { 1528
1477 printk("%d", term->id); 1529/* ------------------------------------------------------------------------
1478 if (term->chain.next != &dev->video.iterms) 1530 * Video device registration and unregistration
1479 printk(","); 1531 */
1480 } 1532
1481 printk(" -> %d).\n", dev->video.oterm->id); 1533/*
1534 * Unregister the video devices.
1535 */
1536static void uvc_unregister_video(struct uvc_device *dev)
1537{
1538 struct uvc_streaming *stream;
1539
1540 list_for_each_entry(stream, &dev->streams, list) {
1541 if (stream->vdev == NULL)
1542 continue;
1543
1544 if (stream->vdev->minor == -1)
1545 video_device_release(stream->vdev);
1546 else
1547 video_unregister_device(stream->vdev);
1548 stream->vdev = NULL;
1482 } 1549 }
1550}
1483 1551
1484 /* Initialize the video buffers queue. */ 1552static int uvc_register_video(struct uvc_device *dev,
1485 uvc_queue_init(&dev->video.queue, dev->video.streaming->type); 1553 struct uvc_streaming *stream)
1554{
1555 struct video_device *vdev;
1556 int ret;
1486 1557
1487 /* Initialize the streaming interface with default streaming 1558 /* Initialize the streaming interface with default streaming
1488 * parameters. 1559 * parameters.
1489 */ 1560 */
1490 if ((ret = uvc_video_init(&dev->video)) < 0) { 1561 ret = uvc_video_init(stream);
1562 if (ret < 0) {
1491 uvc_printk(KERN_ERR, "Failed to initialize the device " 1563 uvc_printk(KERN_ERR, "Failed to initialize the device "
1492 "(%d).\n", ret); 1564 "(%d).\n", ret);
1493 return ret; 1565 return ret;
@@ -1495,8 +1567,11 @@ static int uvc_register_video(struct uvc_device *dev)
1495 1567
1496 /* Register the device with V4L. */ 1568 /* Register the device with V4L. */
1497 vdev = video_device_alloc(); 1569 vdev = video_device_alloc();
1498 if (vdev == NULL) 1570 if (vdev == NULL) {
1499 return -1; 1571 uvc_printk(KERN_ERR, "Failed to allocate video device (%d).\n",
1572 ret);
1573 return -ENOMEM;
1574 }
1500 1575
1501 /* We already hold a reference to dev->udev. The video device will be 1576 /* We already hold a reference to dev->udev. The video device will be
1502 * unregistered before the reference is released, so we don't need to 1577 * unregistered before the reference is released, so we don't need to
@@ -1511,19 +1586,74 @@ static int uvc_register_video(struct uvc_device *dev)
1511 /* Set the driver data before calling video_register_device, otherwise 1586 /* Set the driver data before calling video_register_device, otherwise
1512 * uvc_v4l2_open might race us. 1587 * uvc_v4l2_open might race us.
1513 */ 1588 */
1514 dev->video.vdev = vdev; 1589 stream->vdev = vdev;
1515 video_set_drvdata(vdev, &dev->video); 1590 video_set_drvdata(vdev, stream);
1516 1591
1517 if (video_register_device(vdev, VFL_TYPE_GRABBER, -1) < 0) { 1592 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
1518 dev->video.vdev = NULL; 1593 if (ret < 0) {
1594 uvc_printk(KERN_ERR, "Failed to register video device (%d).\n",
1595 ret);
1596 stream->vdev = NULL;
1519 video_device_release(vdev); 1597 video_device_release(vdev);
1520 return -1; 1598 return ret;
1521 } 1599 }
1522 1600
1523 return 0; 1601 return 0;
1524} 1602}
1525 1603
1526/* 1604/*
1605 * Register all video devices in all chains.
1606 */
1607static int uvc_register_terms(struct uvc_device *dev,
1608 struct uvc_video_chain *chain, struct list_head *terms)
1609{
1610 struct uvc_streaming *stream;
1611 struct uvc_entity *term;
1612 int ret;
1613
1614 list_for_each_entry(term, terms, chain) {
1615 if (UVC_ENTITY_TYPE(term) != UVC_TT_STREAMING)
1616 continue;
1617
1618 stream = uvc_stream_by_id(dev, term->id);
1619 if (stream == NULL) {
1620 uvc_printk(KERN_INFO, "No streaming interface found "
1621 "for terminal %u.", term->id);
1622 continue;
1623 }
1624
1625 stream->chain = chain;
1626 ret = uvc_register_video(dev, stream);
1627 if (ret < 0)
1628 return ret;
1629 }
1630
1631 return 0;
1632}
1633
1634static int uvc_register_chains(struct uvc_device *dev)
1635{
1636 struct uvc_video_chain *chain;
1637 int ret;
1638
1639 list_for_each_entry(chain, &dev->chains, list) {
1640 ret = uvc_register_terms(dev, chain, &chain->iterms);
1641 if (ret < 0)
1642 return ret;
1643
1644 ret = uvc_register_terms(dev, chain, &chain->oterms);
1645 if (ret < 0)
1646 return ret;
1647 }
1648
1649 return 0;
1650}
1651
1652/* ------------------------------------------------------------------------
1653 * USB probe, disconnect, suspend and resume
1654 */
1655
1656/*
1527 * Delete the UVC device. 1657 * Delete the UVC device.
1528 * 1658 *
1529 * Called by the kernel when the last reference to the uvc_device structure 1659 * Called by the kernel when the last reference to the uvc_device structure
@@ -1544,7 +1674,7 @@ void uvc_delete(struct kref *kref)
1544 struct uvc_device *dev = container_of(kref, struct uvc_device, kref); 1674 struct uvc_device *dev = container_of(kref, struct uvc_device, kref);
1545 struct list_head *p, *n; 1675 struct list_head *p, *n;
1546 1676
1547 /* Unregister the video device. */ 1677 /* Unregister the video devices. */
1548 uvc_unregister_video(dev); 1678 uvc_unregister_video(dev);
1549 usb_put_intf(dev->intf); 1679 usb_put_intf(dev->intf);
1550 usb_put_dev(dev->udev); 1680 usb_put_dev(dev->udev);
@@ -1552,13 +1682,19 @@ void uvc_delete(struct kref *kref)
1552 uvc_status_cleanup(dev); 1682 uvc_status_cleanup(dev);
1553 uvc_ctrl_cleanup_device(dev); 1683 uvc_ctrl_cleanup_device(dev);
1554 1684
1685 list_for_each_safe(p, n, &dev->chains) {
1686 struct uvc_video_chain *chain;
1687 chain = list_entry(p, struct uvc_video_chain, list);
1688 kfree(chain);
1689 }
1690
1555 list_for_each_safe(p, n, &dev->entities) { 1691 list_for_each_safe(p, n, &dev->entities) {
1556 struct uvc_entity *entity; 1692 struct uvc_entity *entity;
1557 entity = list_entry(p, struct uvc_entity, list); 1693 entity = list_entry(p, struct uvc_entity, list);
1558 kfree(entity); 1694 kfree(entity);
1559 } 1695 }
1560 1696
1561 list_for_each_safe(p, n, &dev->streaming) { 1697 list_for_each_safe(p, n, &dev->streams) {
1562 struct uvc_streaming *streaming; 1698 struct uvc_streaming *streaming;
1563 streaming = list_entry(p, struct uvc_streaming, list); 1699 streaming = list_entry(p, struct uvc_streaming, list);
1564 usb_driver_release_interface(&uvc_driver.driver, 1700 usb_driver_release_interface(&uvc_driver.driver,
@@ -1592,7 +1728,8 @@ static int uvc_probe(struct usb_interface *intf,
1592 return -ENOMEM; 1728 return -ENOMEM;
1593 1729
1594 INIT_LIST_HEAD(&dev->entities); 1730 INIT_LIST_HEAD(&dev->entities);
1595 INIT_LIST_HEAD(&dev->streaming); 1731 INIT_LIST_HEAD(&dev->chains);
1732 INIT_LIST_HEAD(&dev->streams);
1596 kref_init(&dev->kref); 1733 kref_init(&dev->kref);
1597 atomic_set(&dev->users, 0); 1734 atomic_set(&dev->users, 0);
1598 1735
@@ -1633,8 +1770,12 @@ static int uvc_probe(struct usb_interface *intf,
1633 if (uvc_ctrl_init_device(dev) < 0) 1770 if (uvc_ctrl_init_device(dev) < 0)
1634 goto error; 1771 goto error;
1635 1772
1636 /* Register the video devices. */ 1773 /* Scan the device for video chains. */
1637 if (uvc_register_video(dev) < 0) 1774 if (uvc_scan_device(dev) < 0)
1775 goto error;
1776
1777 /* Register video devices. */
1778 if (uvc_register_chains(dev) < 0)
1638 goto error; 1779 goto error;
1639 1780
1640 /* Save our data pointer in the interface data. */ 1781 /* Save our data pointer in the interface data. */
@@ -1664,7 +1805,8 @@ static void uvc_disconnect(struct usb_interface *intf)
1664 */ 1805 */
1665 usb_set_intfdata(intf, NULL); 1806 usb_set_intfdata(intf, NULL);
1666 1807
1667 if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOSTREAMING) 1808 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
1809 UVC_SC_VIDEOSTREAMING)
1668 return; 1810 return;
1669 1811
1670 /* uvc_v4l2_open() might race uvc_disconnect(). A static driver-wide 1812 /* uvc_v4l2_open() might race uvc_disconnect(). A static driver-wide
@@ -1687,31 +1829,36 @@ static void uvc_disconnect(struct usb_interface *intf)
1687static int uvc_suspend(struct usb_interface *intf, pm_message_t message) 1829static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
1688{ 1830{
1689 struct uvc_device *dev = usb_get_intfdata(intf); 1831 struct uvc_device *dev = usb_get_intfdata(intf);
1832 struct uvc_streaming *stream;
1690 1833
1691 uvc_trace(UVC_TRACE_SUSPEND, "Suspending interface %u\n", 1834 uvc_trace(UVC_TRACE_SUSPEND, "Suspending interface %u\n",
1692 intf->cur_altsetting->desc.bInterfaceNumber); 1835 intf->cur_altsetting->desc.bInterfaceNumber);
1693 1836
1694 /* Controls are cached on the fly so they don't need to be saved. */ 1837 /* Controls are cached on the fly so they don't need to be saved. */
1695 if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOCONTROL) 1838 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
1839 UVC_SC_VIDEOCONTROL)
1696 return uvc_status_suspend(dev); 1840 return uvc_status_suspend(dev);
1697 1841
1698 if (dev->video.streaming->intf != intf) { 1842 list_for_each_entry(stream, &dev->streams, list) {
1699 uvc_trace(UVC_TRACE_SUSPEND, "Suspend: video streaming USB " 1843 if (stream->intf == intf)
1700 "interface mismatch.\n"); 1844 return uvc_video_suspend(stream);
1701 return -EINVAL;
1702 } 1845 }
1703 1846
1704 return uvc_video_suspend(&dev->video); 1847 uvc_trace(UVC_TRACE_SUSPEND, "Suspend: video streaming USB interface "
1848 "mismatch.\n");
1849 return -EINVAL;
1705} 1850}
1706 1851
1707static int __uvc_resume(struct usb_interface *intf, int reset) 1852static int __uvc_resume(struct usb_interface *intf, int reset)
1708{ 1853{
1709 struct uvc_device *dev = usb_get_intfdata(intf); 1854 struct uvc_device *dev = usb_get_intfdata(intf);
1855 struct uvc_streaming *stream;
1710 1856
1711 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n", 1857 uvc_trace(UVC_TRACE_SUSPEND, "Resuming interface %u\n",
1712 intf->cur_altsetting->desc.bInterfaceNumber); 1858 intf->cur_altsetting->desc.bInterfaceNumber);
1713 1859
1714 if (intf->cur_altsetting->desc.bInterfaceSubClass == SC_VIDEOCONTROL) { 1860 if (intf->cur_altsetting->desc.bInterfaceSubClass ==
1861 UVC_SC_VIDEOCONTROL) {
1715 if (reset) { 1862 if (reset) {
1716 int ret = uvc_ctrl_resume_device(dev); 1863 int ret = uvc_ctrl_resume_device(dev);
1717 1864
@@ -1722,13 +1869,14 @@ static int __uvc_resume(struct usb_interface *intf, int reset)
1722 return uvc_status_resume(dev); 1869 return uvc_status_resume(dev);
1723 } 1870 }
1724 1871
1725 if (dev->video.streaming->intf != intf) { 1872 list_for_each_entry(stream, &dev->streams, list) {
1726 uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB " 1873 if (stream->intf == intf)
1727 "interface mismatch.\n"); 1874 return uvc_video_resume(stream);
1728 return -EINVAL;
1729 } 1875 }
1730 1876
1731 return uvc_video_resume(&dev->video); 1877 uvc_trace(UVC_TRACE_SUSPEND, "Resume: video streaming USB interface "
1878 "mismatch.\n");
1879 return -EINVAL;
1732} 1880}
1733 1881
1734static int uvc_resume(struct usb_interface *intf) 1882static int uvc_resume(struct usb_interface *intf)
@@ -1880,7 +2028,8 @@ static struct usb_device_id uvc_ids[] = {
1880 .bInterfaceClass = USB_CLASS_VIDEO, 2028 .bInterfaceClass = USB_CLASS_VIDEO,
1881 .bInterfaceSubClass = 1, 2029 .bInterfaceSubClass = 1,
1882 .bInterfaceProtocol = 0, 2030 .bInterfaceProtocol = 0,
1883 .driver_info = UVC_QUIRK_PROBE_MINMAX }, 2031 .driver_info = UVC_QUIRK_PROBE_MINMAX
2032 | UVC_QUIRK_PROBE_DEF },
1884 /* Syntek (HP Spartan) */ 2033 /* Syntek (HP Spartan) */
1885 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 2034 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1886 | USB_DEVICE_ID_MATCH_INT_INFO, 2035 | USB_DEVICE_ID_MATCH_INT_INFO,
@@ -1943,7 +2092,8 @@ static struct usb_device_id uvc_ids[] = {
1943 .bInterfaceClass = USB_CLASS_VIDEO, 2092 .bInterfaceClass = USB_CLASS_VIDEO,
1944 .bInterfaceSubClass = 1, 2093 .bInterfaceSubClass = 1,
1945 .bInterfaceProtocol = 0, 2094 .bInterfaceProtocol = 0,
1946 .driver_info = UVC_QUIRK_PROBE_EXTRAFIELDS }, 2095 .driver_info = UVC_QUIRK_PROBE_MINMAX
2096 | UVC_QUIRK_PROBE_EXTRAFIELDS },
1947 /* Ecamm Pico iMage */ 2097 /* Ecamm Pico iMage */
1948 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE 2098 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1949 | USB_DEVICE_ID_MATCH_INT_INFO, 2099 | USB_DEVICE_ID_MATCH_INT_INFO,
diff --git a/drivers/media/video/uvc/uvc_isight.c b/drivers/media/video/uvc/uvc_isight.c
index 436f462685a0..a9285b570dbe 100644
--- a/drivers/media/video/uvc/uvc_isight.c
+++ b/drivers/media/video/uvc/uvc_isight.c
@@ -99,7 +99,7 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,
99 return 0; 99 return 0;
100} 100}
101 101
102void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video, 102void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
103 struct uvc_buffer *buf) 103 struct uvc_buffer *buf)
104{ 104{
105 int ret, i; 105 int ret, i;
@@ -120,7 +120,7 @@ void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video,
120 * processes the data of the first payload of the new frame. 120 * processes the data of the first payload of the new frame.
121 */ 121 */
122 do { 122 do {
123 ret = isight_decode(&video->queue, buf, 123 ret = isight_decode(&stream->queue, buf,
124 urb->transfer_buffer + 124 urb->transfer_buffer +
125 urb->iso_frame_desc[i].offset, 125 urb->iso_frame_desc[i].offset,
126 urb->iso_frame_desc[i].actual_length); 126 urb->iso_frame_desc[i].actual_length);
@@ -130,7 +130,8 @@ void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video,
130 130
131 if (buf->state == UVC_BUF_STATE_DONE || 131 if (buf->state == UVC_BUF_STATE_DONE ||
132 buf->state == UVC_BUF_STATE_ERROR) 132 buf->state == UVC_BUF_STATE_ERROR)
133 buf = uvc_queue_next_buffer(&video->queue, buf); 133 buf = uvc_queue_next_buffer(&stream->queue,
134 buf);
134 } while (ret == -EAGAIN); 135 } while (ret == -EAGAIN);
135 } 136 }
136} 137}
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index 5e77cad29690..9e7351569b5d 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -40,7 +40,7 @@
40 * table for the controls that can be mapped directly, and handle the others 40 * table for the controls that can be mapped directly, and handle the others
41 * manually. 41 * manually.
42 */ 42 */
43static int uvc_v4l2_query_menu(struct uvc_video_device *video, 43static int uvc_v4l2_query_menu(struct uvc_video_chain *chain,
44 struct v4l2_querymenu *query_menu) 44 struct v4l2_querymenu *query_menu)
45{ 45{
46 struct uvc_menu_info *menu_info; 46 struct uvc_menu_info *menu_info;
@@ -49,7 +49,7 @@ static int uvc_v4l2_query_menu(struct uvc_video_device *video,
49 u32 index = query_menu->index; 49 u32 index = query_menu->index;
50 u32 id = query_menu->id; 50 u32 id = query_menu->id;
51 51
52 ctrl = uvc_find_control(video, query_menu->id, &mapping); 52 ctrl = uvc_find_control(chain, query_menu->id, &mapping);
53 if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU) 53 if (ctrl == NULL || mapping->v4l2_type != V4L2_CTRL_TYPE_MENU)
54 return -EINVAL; 54 return -EINVAL;
55 55
@@ -103,7 +103,7 @@ static __u32 uvc_try_frame_interval(struct uvc_frame *frame, __u32 interval)
103 return interval; 103 return interval;
104} 104}
105 105
106static int uvc_v4l2_try_format(struct uvc_video_device *video, 106static int uvc_v4l2_try_format(struct uvc_streaming *stream,
107 struct v4l2_format *fmt, struct uvc_streaming_control *probe, 107 struct v4l2_format *fmt, struct uvc_streaming_control *probe,
108 struct uvc_format **uvc_format, struct uvc_frame **uvc_frame) 108 struct uvc_format **uvc_format, struct uvc_frame **uvc_frame)
109{ 109{
@@ -116,7 +116,7 @@ static int uvc_v4l2_try_format(struct uvc_video_device *video,
116 int ret = 0; 116 int ret = 0;
117 __u8 *fcc; 117 __u8 *fcc;
118 118
119 if (fmt->type != video->streaming->type) 119 if (fmt->type != stream->type)
120 return -EINVAL; 120 return -EINVAL;
121 121
122 fcc = (__u8 *)&fmt->fmt.pix.pixelformat; 122 fcc = (__u8 *)&fmt->fmt.pix.pixelformat;
@@ -126,8 +126,8 @@ static int uvc_v4l2_try_format(struct uvc_video_device *video,
126 fmt->fmt.pix.width, fmt->fmt.pix.height); 126 fmt->fmt.pix.width, fmt->fmt.pix.height);
127 127
128 /* Check if the hardware supports the requested format. */ 128 /* Check if the hardware supports the requested format. */
129 for (i = 0; i < video->streaming->nformats; ++i) { 129 for (i = 0; i < stream->nformats; ++i) {
130 format = &video->streaming->format[i]; 130 format = &stream->format[i];
131 if (format->fcc == fmt->fmt.pix.pixelformat) 131 if (format->fcc == fmt->fmt.pix.pixelformat)
132 break; 132 break;
133 } 133 }
@@ -191,12 +191,13 @@ static int uvc_v4l2_try_format(struct uvc_video_device *video,
191 * developers test their webcams with the Linux driver as well as with 191 * developers test their webcams with the Linux driver as well as with
192 * the Windows driver). 192 * the Windows driver).
193 */ 193 */
194 if (video->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS) 194 if (stream->dev->quirks & UVC_QUIRK_PROBE_EXTRAFIELDS)
195 probe->dwMaxVideoFrameSize = 195 probe->dwMaxVideoFrameSize =
196 video->streaming->ctrl.dwMaxVideoFrameSize; 196 stream->ctrl.dwMaxVideoFrameSize;
197 197
198 /* Probe the device. */ 198 /* Probe the device. */
199 if ((ret = uvc_probe_video(video, probe)) < 0) 199 ret = uvc_probe_video(stream, probe);
200 if (ret < 0)
200 goto done; 201 goto done;
201 202
202 fmt->fmt.pix.width = frame->wWidth; 203 fmt->fmt.pix.width = frame->wWidth;
@@ -216,13 +217,13 @@ done:
216 return ret; 217 return ret;
217} 218}
218 219
219static int uvc_v4l2_get_format(struct uvc_video_device *video, 220static int uvc_v4l2_get_format(struct uvc_streaming *stream,
220 struct v4l2_format *fmt) 221 struct v4l2_format *fmt)
221{ 222{
222 struct uvc_format *format = video->streaming->cur_format; 223 struct uvc_format *format = stream->cur_format;
223 struct uvc_frame *frame = video->streaming->cur_frame; 224 struct uvc_frame *frame = stream->cur_frame;
224 225
225 if (fmt->type != video->streaming->type) 226 if (fmt->type != stream->type)
226 return -EINVAL; 227 return -EINVAL;
227 228
228 if (format == NULL || frame == NULL) 229 if (format == NULL || frame == NULL)
@@ -233,14 +234,14 @@ static int uvc_v4l2_get_format(struct uvc_video_device *video,
233 fmt->fmt.pix.height = frame->wHeight; 234 fmt->fmt.pix.height = frame->wHeight;
234 fmt->fmt.pix.field = V4L2_FIELD_NONE; 235 fmt->fmt.pix.field = V4L2_FIELD_NONE;
235 fmt->fmt.pix.bytesperline = format->bpp * frame->wWidth / 8; 236 fmt->fmt.pix.bytesperline = format->bpp * frame->wWidth / 8;
236 fmt->fmt.pix.sizeimage = video->streaming->ctrl.dwMaxVideoFrameSize; 237 fmt->fmt.pix.sizeimage = stream->ctrl.dwMaxVideoFrameSize;
237 fmt->fmt.pix.colorspace = format->colorspace; 238 fmt->fmt.pix.colorspace = format->colorspace;
238 fmt->fmt.pix.priv = 0; 239 fmt->fmt.pix.priv = 0;
239 240
240 return 0; 241 return 0;
241} 242}
242 243
243static int uvc_v4l2_set_format(struct uvc_video_device *video, 244static int uvc_v4l2_set_format(struct uvc_streaming *stream,
244 struct v4l2_format *fmt) 245 struct v4l2_format *fmt)
245{ 246{
246 struct uvc_streaming_control probe; 247 struct uvc_streaming_control probe;
@@ -248,39 +249,39 @@ static int uvc_v4l2_set_format(struct uvc_video_device *video,
248 struct uvc_frame *frame; 249 struct uvc_frame *frame;
249 int ret; 250 int ret;
250 251
251 if (fmt->type != video->streaming->type) 252 if (fmt->type != stream->type)
252 return -EINVAL; 253 return -EINVAL;
253 254
254 if (uvc_queue_allocated(&video->queue)) 255 if (uvc_queue_allocated(&stream->queue))
255 return -EBUSY; 256 return -EBUSY;
256 257
257 ret = uvc_v4l2_try_format(video, fmt, &probe, &format, &frame); 258 ret = uvc_v4l2_try_format(stream, fmt, &probe, &format, &frame);
258 if (ret < 0) 259 if (ret < 0)
259 return ret; 260 return ret;
260 261
261 memcpy(&video->streaming->ctrl, &probe, sizeof probe); 262 memcpy(&stream->ctrl, &probe, sizeof probe);
262 video->streaming->cur_format = format; 263 stream->cur_format = format;
263 video->streaming->cur_frame = frame; 264 stream->cur_frame = frame;
264 265
265 return 0; 266 return 0;
266} 267}
267 268
268static int uvc_v4l2_get_streamparm(struct uvc_video_device *video, 269static int uvc_v4l2_get_streamparm(struct uvc_streaming *stream,
269 struct v4l2_streamparm *parm) 270 struct v4l2_streamparm *parm)
270{ 271{
271 uint32_t numerator, denominator; 272 uint32_t numerator, denominator;
272 273
273 if (parm->type != video->streaming->type) 274 if (parm->type != stream->type)
274 return -EINVAL; 275 return -EINVAL;
275 276
276 numerator = video->streaming->ctrl.dwFrameInterval; 277 numerator = stream->ctrl.dwFrameInterval;
277 denominator = 10000000; 278 denominator = 10000000;
278 uvc_simplify_fraction(&numerator, &denominator, 8, 333); 279 uvc_simplify_fraction(&numerator, &denominator, 8, 333);
279 280
280 memset(parm, 0, sizeof *parm); 281 memset(parm, 0, sizeof *parm);
281 parm->type = video->streaming->type; 282 parm->type = stream->type;
282 283
283 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 284 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
284 parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; 285 parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
285 parm->parm.capture.capturemode = 0; 286 parm->parm.capture.capturemode = 0;
286 parm->parm.capture.timeperframe.numerator = numerator; 287 parm->parm.capture.timeperframe.numerator = numerator;
@@ -297,19 +298,19 @@ static int uvc_v4l2_get_streamparm(struct uvc_video_device *video,
297 return 0; 298 return 0;
298} 299}
299 300
300static int uvc_v4l2_set_streamparm(struct uvc_video_device *video, 301static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
301 struct v4l2_streamparm *parm) 302 struct v4l2_streamparm *parm)
302{ 303{
303 struct uvc_frame *frame = video->streaming->cur_frame; 304 struct uvc_frame *frame = stream->cur_frame;
304 struct uvc_streaming_control probe; 305 struct uvc_streaming_control probe;
305 struct v4l2_fract timeperframe; 306 struct v4l2_fract timeperframe;
306 uint32_t interval; 307 uint32_t interval;
307 int ret; 308 int ret;
308 309
309 if (parm->type != video->streaming->type) 310 if (parm->type != stream->type)
310 return -EINVAL; 311 return -EINVAL;
311 312
312 if (uvc_queue_streaming(&video->queue)) 313 if (uvc_queue_streaming(&stream->queue))
313 return -EBUSY; 314 return -EBUSY;
314 315
315 if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 316 if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -317,7 +318,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_video_device *video,
317 else 318 else
318 timeperframe = parm->parm.output.timeperframe; 319 timeperframe = parm->parm.output.timeperframe;
319 320
320 memcpy(&probe, &video->streaming->ctrl, sizeof probe); 321 memcpy(&probe, &stream->ctrl, sizeof probe);
321 interval = uvc_fraction_to_interval(timeperframe.numerator, 322 interval = uvc_fraction_to_interval(timeperframe.numerator,
322 timeperframe.denominator); 323 timeperframe.denominator);
323 324
@@ -326,10 +327,11 @@ static int uvc_v4l2_set_streamparm(struct uvc_video_device *video,
326 probe.dwFrameInterval = uvc_try_frame_interval(frame, interval); 327 probe.dwFrameInterval = uvc_try_frame_interval(frame, interval);
327 328
328 /* Probe the device with the new settings. */ 329 /* Probe the device with the new settings. */
329 if ((ret = uvc_probe_video(video, &probe)) < 0) 330 ret = uvc_probe_video(stream, &probe);
331 if (ret < 0)
330 return ret; 332 return ret;
331 333
332 memcpy(&video->streaming->ctrl, &probe, sizeof probe); 334 memcpy(&stream->ctrl, &probe, sizeof probe);
333 335
334 /* Return the actual frame period. */ 336 /* Return the actual frame period. */
335 timeperframe.numerator = probe.dwFrameInterval; 337 timeperframe.numerator = probe.dwFrameInterval;
@@ -382,8 +384,8 @@ static int uvc_acquire_privileges(struct uvc_fh *handle)
382 384
383 /* Check if the device already has a privileged handle. */ 385 /* Check if the device already has a privileged handle. */
384 mutex_lock(&uvc_driver.open_mutex); 386 mutex_lock(&uvc_driver.open_mutex);
385 if (atomic_inc_return(&handle->device->active) != 1) { 387 if (atomic_inc_return(&handle->stream->active) != 1) {
386 atomic_dec(&handle->device->active); 388 atomic_dec(&handle->stream->active);
387 ret = -EBUSY; 389 ret = -EBUSY;
388 goto done; 390 goto done;
389 } 391 }
@@ -398,7 +400,7 @@ done:
398static void uvc_dismiss_privileges(struct uvc_fh *handle) 400static void uvc_dismiss_privileges(struct uvc_fh *handle)
399{ 401{
400 if (handle->state == UVC_HANDLE_ACTIVE) 402 if (handle->state == UVC_HANDLE_ACTIVE)
401 atomic_dec(&handle->device->active); 403 atomic_dec(&handle->stream->active);
402 404
403 handle->state = UVC_HANDLE_PASSIVE; 405 handle->state = UVC_HANDLE_PASSIVE;
404} 406}
@@ -414,45 +416,47 @@ static int uvc_has_privileges(struct uvc_fh *handle)
414 416
415static int uvc_v4l2_open(struct file *file) 417static int uvc_v4l2_open(struct file *file)
416{ 418{
417 struct uvc_video_device *video; 419 struct uvc_streaming *stream;
418 struct uvc_fh *handle; 420 struct uvc_fh *handle;
419 int ret = 0; 421 int ret = 0;
420 422
421 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n"); 423 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_open\n");
422 mutex_lock(&uvc_driver.open_mutex); 424 mutex_lock(&uvc_driver.open_mutex);
423 video = video_drvdata(file); 425 stream = video_drvdata(file);
424 426
425 if (video->dev->state & UVC_DEV_DISCONNECTED) { 427 if (stream->dev->state & UVC_DEV_DISCONNECTED) {
426 ret = -ENODEV; 428 ret = -ENODEV;
427 goto done; 429 goto done;
428 } 430 }
429 431
430 ret = usb_autopm_get_interface(video->dev->intf); 432 ret = usb_autopm_get_interface(stream->dev->intf);
431 if (ret < 0) 433 if (ret < 0)
432 goto done; 434 goto done;
433 435
434 /* Create the device handle. */ 436 /* Create the device handle. */
435 handle = kzalloc(sizeof *handle, GFP_KERNEL); 437 handle = kzalloc(sizeof *handle, GFP_KERNEL);
436 if (handle == NULL) { 438 if (handle == NULL) {
437 usb_autopm_put_interface(video->dev->intf); 439 usb_autopm_put_interface(stream->dev->intf);
438 ret = -ENOMEM; 440 ret = -ENOMEM;
439 goto done; 441 goto done;
440 } 442 }
441 443
442 if (atomic_inc_return(&video->dev->users) == 1) { 444 if (atomic_inc_return(&stream->dev->users) == 1) {
443 if ((ret = uvc_status_start(video->dev)) < 0) { 445 ret = uvc_status_start(stream->dev);
444 usb_autopm_put_interface(video->dev->intf); 446 if (ret < 0) {
445 atomic_dec(&video->dev->users); 447 usb_autopm_put_interface(stream->dev->intf);
448 atomic_dec(&stream->dev->users);
446 kfree(handle); 449 kfree(handle);
447 goto done; 450 goto done;
448 } 451 }
449 } 452 }
450 453
451 handle->device = video; 454 handle->chain = stream->chain;
455 handle->stream = stream;
452 handle->state = UVC_HANDLE_PASSIVE; 456 handle->state = UVC_HANDLE_PASSIVE;
453 file->private_data = handle; 457 file->private_data = handle;
454 458
455 kref_get(&video->dev->kref); 459 kref_get(&stream->dev->kref);
456 460
457done: 461done:
458 mutex_unlock(&uvc_driver.open_mutex); 462 mutex_unlock(&uvc_driver.open_mutex);
@@ -461,20 +465,20 @@ done:
461 465
462static int uvc_v4l2_release(struct file *file) 466static int uvc_v4l2_release(struct file *file)
463{ 467{
464 struct uvc_video_device *video = video_drvdata(file);
465 struct uvc_fh *handle = (struct uvc_fh *)file->private_data; 468 struct uvc_fh *handle = (struct uvc_fh *)file->private_data;
469 struct uvc_streaming *stream = handle->stream;
466 470
467 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n"); 471 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_release\n");
468 472
469 /* Only free resources if this is a privileged handle. */ 473 /* Only free resources if this is a privileged handle. */
470 if (uvc_has_privileges(handle)) { 474 if (uvc_has_privileges(handle)) {
471 uvc_video_enable(video, 0); 475 uvc_video_enable(stream, 0);
472 476
473 mutex_lock(&video->queue.mutex); 477 mutex_lock(&stream->queue.mutex);
474 if (uvc_free_buffers(&video->queue) < 0) 478 if (uvc_free_buffers(&stream->queue) < 0)
475 uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to " 479 uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to "
476 "free buffers.\n"); 480 "free buffers.\n");
477 mutex_unlock(&video->queue.mutex); 481 mutex_unlock(&stream->queue.mutex);
478 } 482 }
479 483
480 /* Release the file handle. */ 484 /* Release the file handle. */
@@ -482,19 +486,20 @@ static int uvc_v4l2_release(struct file *file)
482 kfree(handle); 486 kfree(handle);
483 file->private_data = NULL; 487 file->private_data = NULL;
484 488
485 if (atomic_dec_return(&video->dev->users) == 0) 489 if (atomic_dec_return(&stream->dev->users) == 0)
486 uvc_status_stop(video->dev); 490 uvc_status_stop(stream->dev);
487 491
488 usb_autopm_put_interface(video->dev->intf); 492 usb_autopm_put_interface(stream->dev->intf);
489 kref_put(&video->dev->kref, uvc_delete); 493 kref_put(&stream->dev->kref, uvc_delete);
490 return 0; 494 return 0;
491} 495}
492 496
493static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) 497static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
494{ 498{
495 struct video_device *vdev = video_devdata(file); 499 struct video_device *vdev = video_devdata(file);
496 struct uvc_video_device *video = video_get_drvdata(vdev);
497 struct uvc_fh *handle = (struct uvc_fh *)file->private_data; 500 struct uvc_fh *handle = (struct uvc_fh *)file->private_data;
501 struct uvc_video_chain *chain = handle->chain;
502 struct uvc_streaming *stream = handle->stream;
498 long ret = 0; 503 long ret = 0;
499 504
500 switch (cmd) { 505 switch (cmd) {
@@ -506,10 +511,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
506 memset(cap, 0, sizeof *cap); 511 memset(cap, 0, sizeof *cap);
507 strlcpy(cap->driver, "uvcvideo", sizeof cap->driver); 512 strlcpy(cap->driver, "uvcvideo", sizeof cap->driver);
508 strlcpy(cap->card, vdev->name, sizeof cap->card); 513 strlcpy(cap->card, vdev->name, sizeof cap->card);
509 usb_make_path(video->dev->udev, 514 usb_make_path(stream->dev->udev,
510 cap->bus_info, sizeof(cap->bus_info)); 515 cap->bus_info, sizeof(cap->bus_info));
511 cap->version = DRIVER_VERSION_NUMBER; 516 cap->version = DRIVER_VERSION_NUMBER;
512 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 517 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
513 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE 518 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE
514 | V4L2_CAP_STREAMING; 519 | V4L2_CAP_STREAMING;
515 else 520 else
@@ -520,7 +525,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
520 525
521 /* Get, Set & Query control */ 526 /* Get, Set & Query control */
522 case VIDIOC_QUERYCTRL: 527 case VIDIOC_QUERYCTRL:
523 return uvc_query_v4l2_ctrl(video, arg); 528 return uvc_query_v4l2_ctrl(chain, arg);
524 529
525 case VIDIOC_G_CTRL: 530 case VIDIOC_G_CTRL:
526 { 531 {
@@ -530,12 +535,12 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
530 memset(&xctrl, 0, sizeof xctrl); 535 memset(&xctrl, 0, sizeof xctrl);
531 xctrl.id = ctrl->id; 536 xctrl.id = ctrl->id;
532 537
533 ret = uvc_ctrl_begin(video); 538 ret = uvc_ctrl_begin(chain);
534 if (ret < 0) 539 if (ret < 0)
535 return ret; 540 return ret;
536 541
537 ret = uvc_ctrl_get(video, &xctrl); 542 ret = uvc_ctrl_get(chain, &xctrl);
538 uvc_ctrl_rollback(video); 543 uvc_ctrl_rollback(chain);
539 if (ret >= 0) 544 if (ret >= 0)
540 ctrl->value = xctrl.value; 545 ctrl->value = xctrl.value;
541 break; 546 break;
@@ -550,21 +555,21 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
550 xctrl.id = ctrl->id; 555 xctrl.id = ctrl->id;
551 xctrl.value = ctrl->value; 556 xctrl.value = ctrl->value;
552 557
553 ret = uvc_ctrl_begin(video); 558 uvc_ctrl_begin(chain);
554 if (ret < 0) 559 if (ret < 0)
555 return ret; 560 return ret;
556 561
557 ret = uvc_ctrl_set(video, &xctrl); 562 ret = uvc_ctrl_set(chain, &xctrl);
558 if (ret < 0) { 563 if (ret < 0) {
559 uvc_ctrl_rollback(video); 564 uvc_ctrl_rollback(chain);
560 return ret; 565 return ret;
561 } 566 }
562 ret = uvc_ctrl_commit(video); 567 ret = uvc_ctrl_commit(chain);
563 break; 568 break;
564 } 569 }
565 570
566 case VIDIOC_QUERYMENU: 571 case VIDIOC_QUERYMENU:
567 return uvc_v4l2_query_menu(video, arg); 572 return uvc_v4l2_query_menu(chain, arg);
568 573
569 case VIDIOC_G_EXT_CTRLS: 574 case VIDIOC_G_EXT_CTRLS:
570 { 575 {
@@ -572,20 +577,20 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
572 struct v4l2_ext_control *ctrl = ctrls->controls; 577 struct v4l2_ext_control *ctrl = ctrls->controls;
573 unsigned int i; 578 unsigned int i;
574 579
575 ret = uvc_ctrl_begin(video); 580 ret = uvc_ctrl_begin(chain);
576 if (ret < 0) 581 if (ret < 0)
577 return ret; 582 return ret;
578 583
579 for (i = 0; i < ctrls->count; ++ctrl, ++i) { 584 for (i = 0; i < ctrls->count; ++ctrl, ++i) {
580 ret = uvc_ctrl_get(video, ctrl); 585 ret = uvc_ctrl_get(chain, ctrl);
581 if (ret < 0) { 586 if (ret < 0) {
582 uvc_ctrl_rollback(video); 587 uvc_ctrl_rollback(chain);
583 ctrls->error_idx = i; 588 ctrls->error_idx = i;
584 return ret; 589 return ret;
585 } 590 }
586 } 591 }
587 ctrls->error_idx = 0; 592 ctrls->error_idx = 0;
588 ret = uvc_ctrl_rollback(video); 593 ret = uvc_ctrl_rollback(chain);
589 break; 594 break;
590 } 595 }
591 596
@@ -596,14 +601,14 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
596 struct v4l2_ext_control *ctrl = ctrls->controls; 601 struct v4l2_ext_control *ctrl = ctrls->controls;
597 unsigned int i; 602 unsigned int i;
598 603
599 ret = uvc_ctrl_begin(video); 604 ret = uvc_ctrl_begin(chain);
600 if (ret < 0) 605 if (ret < 0)
601 return ret; 606 return ret;
602 607
603 for (i = 0; i < ctrls->count; ++ctrl, ++i) { 608 for (i = 0; i < ctrls->count; ++ctrl, ++i) {
604 ret = uvc_ctrl_set(video, ctrl); 609 ret = uvc_ctrl_set(chain, ctrl);
605 if (ret < 0) { 610 if (ret < 0) {
606 uvc_ctrl_rollback(video); 611 uvc_ctrl_rollback(chain);
607 ctrls->error_idx = i; 612 ctrls->error_idx = i;
608 return ret; 613 return ret;
609 } 614 }
@@ -612,31 +617,31 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
612 ctrls->error_idx = 0; 617 ctrls->error_idx = 0;
613 618
614 if (cmd == VIDIOC_S_EXT_CTRLS) 619 if (cmd == VIDIOC_S_EXT_CTRLS)
615 ret = uvc_ctrl_commit(video); 620 ret = uvc_ctrl_commit(chain);
616 else 621 else
617 ret = uvc_ctrl_rollback(video); 622 ret = uvc_ctrl_rollback(chain);
618 break; 623 break;
619 } 624 }
620 625
621 /* Get, Set & Enum input */ 626 /* Get, Set & Enum input */
622 case VIDIOC_ENUMINPUT: 627 case VIDIOC_ENUMINPUT:
623 { 628 {
624 const struct uvc_entity *selector = video->selector; 629 const struct uvc_entity *selector = chain->selector;
625 struct v4l2_input *input = arg; 630 struct v4l2_input *input = arg;
626 struct uvc_entity *iterm = NULL; 631 struct uvc_entity *iterm = NULL;
627 u32 index = input->index; 632 u32 index = input->index;
628 int pin = 0; 633 int pin = 0;
629 634
630 if (selector == NULL || 635 if (selector == NULL ||
631 (video->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { 636 (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
632 if (index != 0) 637 if (index != 0)
633 return -EINVAL; 638 return -EINVAL;
634 iterm = list_first_entry(&video->iterms, 639 iterm = list_first_entry(&chain->iterms,
635 struct uvc_entity, chain); 640 struct uvc_entity, chain);
636 pin = iterm->id; 641 pin = iterm->id;
637 } else if (pin < selector->selector.bNrInPins) { 642 } else if (pin < selector->selector.bNrInPins) {
638 pin = selector->selector.baSourceID[index]; 643 pin = selector->selector.baSourceID[index];
639 list_for_each_entry(iterm, video->iterms.next, chain) { 644 list_for_each_entry(iterm, chain->iterms.next, chain) {
640 if (iterm->id == pin) 645 if (iterm->id == pin)
641 break; 646 break;
642 } 647 }
@@ -648,7 +653,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
648 memset(input, 0, sizeof *input); 653 memset(input, 0, sizeof *input);
649 input->index = index; 654 input->index = index;
650 strlcpy(input->name, iterm->name, sizeof input->name); 655 strlcpy(input->name, iterm->name, sizeof input->name);
651 if (UVC_ENTITY_TYPE(iterm) == ITT_CAMERA) 656 if (UVC_ENTITY_TYPE(iterm) == UVC_ITT_CAMERA)
652 input->type = V4L2_INPUT_TYPE_CAMERA; 657 input->type = V4L2_INPUT_TYPE_CAMERA;
653 break; 658 break;
654 } 659 }
@@ -657,15 +662,15 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
657 { 662 {
658 u8 input; 663 u8 input;
659 664
660 if (video->selector == NULL || 665 if (chain->selector == NULL ||
661 (video->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { 666 (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
662 *(int *)arg = 0; 667 *(int *)arg = 0;
663 break; 668 break;
664 } 669 }
665 670
666 ret = uvc_query_ctrl(video->dev, GET_CUR, video->selector->id, 671 ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR,
667 video->dev->intfnum, SU_INPUT_SELECT_CONTROL, 672 chain->selector->id, chain->dev->intfnum,
668 &input, 1); 673 UVC_SU_INPUT_SELECT_CONTROL, &input, 1);
669 if (ret < 0) 674 if (ret < 0)
670 return ret; 675 return ret;
671 676
@@ -680,19 +685,19 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
680 if ((ret = uvc_acquire_privileges(handle)) < 0) 685 if ((ret = uvc_acquire_privileges(handle)) < 0)
681 return ret; 686 return ret;
682 687
683 if (video->selector == NULL || 688 if (chain->selector == NULL ||
684 (video->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) { 689 (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
685 if (input != 1) 690 if (input != 1)
686 return -EINVAL; 691 return -EINVAL;
687 break; 692 break;
688 } 693 }
689 694
690 if (input == 0 || input > video->selector->selector.bNrInPins) 695 if (input == 0 || input > chain->selector->selector.bNrInPins)
691 return -EINVAL; 696 return -EINVAL;
692 697
693 return uvc_query_ctrl(video->dev, SET_CUR, video->selector->id, 698 return uvc_query_ctrl(chain->dev, UVC_SET_CUR,
694 video->dev->intfnum, SU_INPUT_SELECT_CONTROL, 699 chain->selector->id, chain->dev->intfnum,
695 &input, 1); 700 UVC_SU_INPUT_SELECT_CONTROL, &input, 1);
696 } 701 }
697 702
698 /* Try, Get, Set & Enum format */ 703 /* Try, Get, Set & Enum format */
@@ -703,15 +708,15 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
703 enum v4l2_buf_type type = fmt->type; 708 enum v4l2_buf_type type = fmt->type;
704 __u32 index = fmt->index; 709 __u32 index = fmt->index;
705 710
706 if (fmt->type != video->streaming->type || 711 if (fmt->type != stream->type ||
707 fmt->index >= video->streaming->nformats) 712 fmt->index >= stream->nformats)
708 return -EINVAL; 713 return -EINVAL;
709 714
710 memset(fmt, 0, sizeof(*fmt)); 715 memset(fmt, 0, sizeof(*fmt));
711 fmt->index = index; 716 fmt->index = index;
712 fmt->type = type; 717 fmt->type = type;
713 718
714 format = &video->streaming->format[fmt->index]; 719 format = &stream->format[fmt->index];
715 fmt->flags = 0; 720 fmt->flags = 0;
716 if (format->flags & UVC_FMT_FLAG_COMPRESSED) 721 if (format->flags & UVC_FMT_FLAG_COMPRESSED)
717 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED; 722 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
@@ -729,17 +734,17 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
729 if ((ret = uvc_acquire_privileges(handle)) < 0) 734 if ((ret = uvc_acquire_privileges(handle)) < 0)
730 return ret; 735 return ret;
731 736
732 return uvc_v4l2_try_format(video, arg, &probe, NULL, NULL); 737 return uvc_v4l2_try_format(stream, arg, &probe, NULL, NULL);
733 } 738 }
734 739
735 case VIDIOC_S_FMT: 740 case VIDIOC_S_FMT:
736 if ((ret = uvc_acquire_privileges(handle)) < 0) 741 if ((ret = uvc_acquire_privileges(handle)) < 0)
737 return ret; 742 return ret;
738 743
739 return uvc_v4l2_set_format(video, arg); 744 return uvc_v4l2_set_format(stream, arg);
740 745
741 case VIDIOC_G_FMT: 746 case VIDIOC_G_FMT:
742 return uvc_v4l2_get_format(video, arg); 747 return uvc_v4l2_get_format(stream, arg);
743 748
744 /* Frame size enumeration */ 749 /* Frame size enumeration */
745 case VIDIOC_ENUM_FRAMESIZES: 750 case VIDIOC_ENUM_FRAMESIZES:
@@ -750,10 +755,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
750 int i; 755 int i;
751 756
752 /* Look for the given pixel format */ 757 /* Look for the given pixel format */
753 for (i = 0; i < video->streaming->nformats; i++) { 758 for (i = 0; i < stream->nformats; i++) {
754 if (video->streaming->format[i].fcc == 759 if (stream->format[i].fcc ==
755 fsize->pixel_format) { 760 fsize->pixel_format) {
756 format = &video->streaming->format[i]; 761 format = &stream->format[i];
757 break; 762 break;
758 } 763 }
759 } 764 }
@@ -779,10 +784,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
779 int i; 784 int i;
780 785
781 /* Look for the given pixel format and frame size */ 786 /* Look for the given pixel format and frame size */
782 for (i = 0; i < video->streaming->nformats; i++) { 787 for (i = 0; i < stream->nformats; i++) {
783 if (video->streaming->format[i].fcc == 788 if (stream->format[i].fcc ==
784 fival->pixel_format) { 789 fival->pixel_format) {
785 format = &video->streaming->format[i]; 790 format = &stream->format[i];
786 break; 791 break;
787 } 792 }
788 } 793 }
@@ -832,21 +837,21 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
832 837
833 /* Get & Set streaming parameters */ 838 /* Get & Set streaming parameters */
834 case VIDIOC_G_PARM: 839 case VIDIOC_G_PARM:
835 return uvc_v4l2_get_streamparm(video, arg); 840 return uvc_v4l2_get_streamparm(stream, arg);
836 841
837 case VIDIOC_S_PARM: 842 case VIDIOC_S_PARM:
838 if ((ret = uvc_acquire_privileges(handle)) < 0) 843 if ((ret = uvc_acquire_privileges(handle)) < 0)
839 return ret; 844 return ret;
840 845
841 return uvc_v4l2_set_streamparm(video, arg); 846 return uvc_v4l2_set_streamparm(stream, arg);
842 847
843 /* Cropping and scaling */ 848 /* Cropping and scaling */
844 case VIDIOC_CROPCAP: 849 case VIDIOC_CROPCAP:
845 { 850 {
846 struct v4l2_cropcap *ccap = arg; 851 struct v4l2_cropcap *ccap = arg;
847 struct uvc_frame *frame = video->streaming->cur_frame; 852 struct uvc_frame *frame = stream->cur_frame;
848 853
849 if (ccap->type != video->streaming->type) 854 if (ccap->type != stream->type)
850 return -EINVAL; 855 return -EINVAL;
851 856
852 ccap->bounds.left = 0; 857 ccap->bounds.left = 0;
@@ -870,16 +875,16 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
870 { 875 {
871 struct v4l2_requestbuffers *rb = arg; 876 struct v4l2_requestbuffers *rb = arg;
872 unsigned int bufsize = 877 unsigned int bufsize =
873 video->streaming->ctrl.dwMaxVideoFrameSize; 878 stream->ctrl.dwMaxVideoFrameSize;
874 879
875 if (rb->type != video->streaming->type || 880 if (rb->type != stream->type ||
876 rb->memory != V4L2_MEMORY_MMAP) 881 rb->memory != V4L2_MEMORY_MMAP)
877 return -EINVAL; 882 return -EINVAL;
878 883
879 if ((ret = uvc_acquire_privileges(handle)) < 0) 884 if ((ret = uvc_acquire_privileges(handle)) < 0)
880 return ret; 885 return ret;
881 886
882 ret = uvc_alloc_buffers(&video->queue, rb->count, bufsize); 887 ret = uvc_alloc_buffers(&stream->queue, rb->count, bufsize);
883 if (ret < 0) 888 if (ret < 0)
884 return ret; 889 return ret;
885 890
@@ -892,39 +897,40 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
892 { 897 {
893 struct v4l2_buffer *buf = arg; 898 struct v4l2_buffer *buf = arg;
894 899
895 if (buf->type != video->streaming->type) 900 if (buf->type != stream->type)
896 return -EINVAL; 901 return -EINVAL;
897 902
898 if (!uvc_has_privileges(handle)) 903 if (!uvc_has_privileges(handle))
899 return -EBUSY; 904 return -EBUSY;
900 905
901 return uvc_query_buffer(&video->queue, buf); 906 return uvc_query_buffer(&stream->queue, buf);
902 } 907 }
903 908
904 case VIDIOC_QBUF: 909 case VIDIOC_QBUF:
905 if (!uvc_has_privileges(handle)) 910 if (!uvc_has_privileges(handle))
906 return -EBUSY; 911 return -EBUSY;
907 912
908 return uvc_queue_buffer(&video->queue, arg); 913 return uvc_queue_buffer(&stream->queue, arg);
909 914
910 case VIDIOC_DQBUF: 915 case VIDIOC_DQBUF:
911 if (!uvc_has_privileges(handle)) 916 if (!uvc_has_privileges(handle))
912 return -EBUSY; 917 return -EBUSY;
913 918
914 return uvc_dequeue_buffer(&video->queue, arg, 919 return uvc_dequeue_buffer(&stream->queue, arg,
915 file->f_flags & O_NONBLOCK); 920 file->f_flags & O_NONBLOCK);
916 921
917 case VIDIOC_STREAMON: 922 case VIDIOC_STREAMON:
918 { 923 {
919 int *type = arg; 924 int *type = arg;
920 925
921 if (*type != video->streaming->type) 926 if (*type != stream->type)
922 return -EINVAL; 927 return -EINVAL;
923 928
924 if (!uvc_has_privileges(handle)) 929 if (!uvc_has_privileges(handle))
925 return -EBUSY; 930 return -EBUSY;
926 931
927 if ((ret = uvc_video_enable(video, 1)) < 0) 932 ret = uvc_video_enable(stream, 1);
933 if (ret < 0)
928 return ret; 934 return ret;
929 break; 935 break;
930 } 936 }
@@ -933,13 +939,13 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
933 { 939 {
934 int *type = arg; 940 int *type = arg;
935 941
936 if (*type != video->streaming->type) 942 if (*type != stream->type)
937 return -EINVAL; 943 return -EINVAL;
938 944
939 if (!uvc_has_privileges(handle)) 945 if (!uvc_has_privileges(handle))
940 return -EBUSY; 946 return -EBUSY;
941 947
942 return uvc_video_enable(video, 0); 948 return uvc_video_enable(stream, 0);
943 } 949 }
944 950
945 /* Analog video standards make no sense for digital cameras. */ 951 /* Analog video standards make no sense for digital cameras. */
@@ -1013,10 +1019,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1013 } 1019 }
1014 1020
1015 case UVCIOC_CTRL_GET: 1021 case UVCIOC_CTRL_GET:
1016 return uvc_xu_ctrl_query(video, arg, 0); 1022 return uvc_xu_ctrl_query(chain, arg, 0);
1017 1023
1018 case UVCIOC_CTRL_SET: 1024 case UVCIOC_CTRL_SET:
1019 return uvc_xu_ctrl_query(video, arg, 1); 1025 return uvc_xu_ctrl_query(chain, arg, 1);
1020 1026
1021 default: 1027 default:
1022 if ((ret = v4l_compat_translate_ioctl(file, cmd, arg, 1028 if ((ret = v4l_compat_translate_ioctl(file, cmd, arg,
@@ -1070,7 +1076,9 @@ static struct vm_operations_struct uvc_vm_ops = {
1070 1076
1071static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma) 1077static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1072{ 1078{
1073 struct uvc_video_device *video = video_drvdata(file); 1079 struct uvc_fh *handle = (struct uvc_fh *)file->private_data;
1080 struct uvc_streaming *stream = handle->stream;
1081 struct uvc_video_queue *queue = &stream->queue;
1074 struct uvc_buffer *uninitialized_var(buffer); 1082 struct uvc_buffer *uninitialized_var(buffer);
1075 struct page *page; 1083 struct page *page;
1076 unsigned long addr, start, size; 1084 unsigned long addr, start, size;
@@ -1082,15 +1090,15 @@ static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1082 start = vma->vm_start; 1090 start = vma->vm_start;
1083 size = vma->vm_end - vma->vm_start; 1091 size = vma->vm_end - vma->vm_start;
1084 1092
1085 mutex_lock(&video->queue.mutex); 1093 mutex_lock(&queue->mutex);
1086 1094
1087 for (i = 0; i < video->queue.count; ++i) { 1095 for (i = 0; i < queue->count; ++i) {
1088 buffer = &video->queue.buffer[i]; 1096 buffer = &queue->buffer[i];
1089 if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff) 1097 if ((buffer->buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff)
1090 break; 1098 break;
1091 } 1099 }
1092 1100
1093 if (i == video->queue.count || size != video->queue.buf_size) { 1101 if (i == queue->count || size != queue->buf_size) {
1094 ret = -EINVAL; 1102 ret = -EINVAL;
1095 goto done; 1103 goto done;
1096 } 1104 }
@@ -1101,7 +1109,7 @@ static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1101 */ 1109 */
1102 vma->vm_flags |= VM_IO; 1110 vma->vm_flags |= VM_IO;
1103 1111
1104 addr = (unsigned long)video->queue.mem + buffer->buf.m.offset; 1112 addr = (unsigned long)queue->mem + buffer->buf.m.offset;
1105 while (size > 0) { 1113 while (size > 0) {
1106 page = vmalloc_to_page((void *)addr); 1114 page = vmalloc_to_page((void *)addr);
1107 if ((ret = vm_insert_page(vma, start, page)) < 0) 1115 if ((ret = vm_insert_page(vma, start, page)) < 0)
@@ -1117,17 +1125,18 @@ static int uvc_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
1117 uvc_vm_open(vma); 1125 uvc_vm_open(vma);
1118 1126
1119done: 1127done:
1120 mutex_unlock(&video->queue.mutex); 1128 mutex_unlock(&queue->mutex);
1121 return ret; 1129 return ret;
1122} 1130}
1123 1131
1124static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait) 1132static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait)
1125{ 1133{
1126 struct uvc_video_device *video = video_drvdata(file); 1134 struct uvc_fh *handle = (struct uvc_fh *)file->private_data;
1135 struct uvc_streaming *stream = handle->stream;
1127 1136
1128 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_poll\n"); 1137 uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_poll\n");
1129 1138
1130 return uvc_queue_poll(&video->queue, file, wait); 1139 return uvc_queue_poll(&stream->queue, file, wait);
1131} 1140}
1132 1141
1133const struct v4l2_file_operations uvc_fops = { 1142const struct v4l2_file_operations uvc_fops = {
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 01b633c73480..5b757f32d997 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -61,7 +61,7 @@ int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
61 return 0; 61 return 0;
62} 62}
63 63
64static void uvc_fixup_video_ctrl(struct uvc_video_device *video, 64static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
65 struct uvc_streaming_control *ctrl) 65 struct uvc_streaming_control *ctrl)
66{ 66{
67 struct uvc_format *format; 67 struct uvc_format *format;
@@ -69,10 +69,10 @@ static void uvc_fixup_video_ctrl(struct uvc_video_device *video,
69 unsigned int i; 69 unsigned int i;
70 70
71 if (ctrl->bFormatIndex <= 0 || 71 if (ctrl->bFormatIndex <= 0 ||
72 ctrl->bFormatIndex > video->streaming->nformats) 72 ctrl->bFormatIndex > stream->nformats)
73 return; 73 return;
74 74
75 format = &video->streaming->format[ctrl->bFormatIndex - 1]; 75 format = &stream->format[ctrl->bFormatIndex - 1];
76 76
77 for (i = 0; i < format->nframes; ++i) { 77 for (i = 0; i < format->nframes; ++i) {
78 if (format->frame[i].bFrameIndex == ctrl->bFrameIndex) { 78 if (format->frame[i].bFrameIndex == ctrl->bFrameIndex) {
@@ -86,12 +86,12 @@ static void uvc_fixup_video_ctrl(struct uvc_video_device *video,
86 86
87 if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) || 87 if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) ||
88 (ctrl->dwMaxVideoFrameSize == 0 && 88 (ctrl->dwMaxVideoFrameSize == 0 &&
89 video->dev->uvc_version < 0x0110)) 89 stream->dev->uvc_version < 0x0110))
90 ctrl->dwMaxVideoFrameSize = 90 ctrl->dwMaxVideoFrameSize =
91 frame->dwMaxVideoFrameBufferSize; 91 frame->dwMaxVideoFrameBufferSize;
92 92
93 if (video->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH && 93 if (stream->dev->quirks & UVC_QUIRK_FIX_BANDWIDTH &&
94 video->streaming->intf->num_altsetting > 1) { 94 stream->intf->num_altsetting > 1) {
95 u32 interval; 95 u32 interval;
96 u32 bandwidth; 96 u32 bandwidth;
97 97
@@ -108,7 +108,7 @@ static void uvc_fixup_video_ctrl(struct uvc_video_device *video,
108 bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp; 108 bandwidth = frame->wWidth * frame->wHeight / 8 * format->bpp;
109 bandwidth *= 10000000 / interval + 1; 109 bandwidth *= 10000000 / interval + 1;
110 bandwidth /= 1000; 110 bandwidth /= 1000;
111 if (video->dev->udev->speed == USB_SPEED_HIGH) 111 if (stream->dev->udev->speed == USB_SPEED_HIGH)
112 bandwidth /= 8; 112 bandwidth /= 8;
113 bandwidth += 12; 113 bandwidth += 12;
114 114
@@ -116,40 +116,43 @@ static void uvc_fixup_video_ctrl(struct uvc_video_device *video,
116 } 116 }
117} 117}
118 118
119static int uvc_get_video_ctrl(struct uvc_video_device *video, 119static int uvc_get_video_ctrl(struct uvc_streaming *stream,
120 struct uvc_streaming_control *ctrl, int probe, __u8 query) 120 struct uvc_streaming_control *ctrl, int probe, __u8 query)
121{ 121{
122 __u8 *data; 122 __u8 *data;
123 __u16 size; 123 __u16 size;
124 int ret; 124 int ret;
125 125
126 size = video->dev->uvc_version >= 0x0110 ? 34 : 26; 126 size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
127 data = kmalloc(size, GFP_KERNEL); 127 data = kmalloc(size, GFP_KERNEL);
128 if (data == NULL) 128 if (data == NULL)
129 return -ENOMEM; 129 return -ENOMEM;
130 130
131 ret = __uvc_query_ctrl(video->dev, query, 0, video->streaming->intfnum, 131 if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) && query == UVC_GET_DEF)
132 probe ? VS_PROBE_CONTROL : VS_COMMIT_CONTROL, data, size, 132 return -EIO;
133 UVC_CTRL_STREAMING_TIMEOUT); 133
134 ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum,
135 probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
136 size, UVC_CTRL_STREAMING_TIMEOUT);
134 137
135 if ((query == GET_MIN || query == GET_MAX) && ret == 2) { 138 if ((query == UVC_GET_MIN || query == UVC_GET_MAX) && ret == 2) {
136 /* Some cameras, mostly based on Bison Electronics chipsets, 139 /* Some cameras, mostly based on Bison Electronics chipsets,
137 * answer a GET_MIN or GET_MAX request with the wCompQuality 140 * answer a GET_MIN or GET_MAX request with the wCompQuality
138 * field only. 141 * field only.
139 */ 142 */
140 uvc_warn_once(video->dev, UVC_WARN_MINMAX, "UVC non " 143 uvc_warn_once(stream->dev, UVC_WARN_MINMAX, "UVC non "
141 "compliance - GET_MIN/MAX(PROBE) incorrectly " 144 "compliance - GET_MIN/MAX(PROBE) incorrectly "
142 "supported. Enabling workaround.\n"); 145 "supported. Enabling workaround.\n");
143 memset(ctrl, 0, sizeof ctrl); 146 memset(ctrl, 0, sizeof ctrl);
144 ctrl->wCompQuality = le16_to_cpup((__le16 *)data); 147 ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
145 ret = 0; 148 ret = 0;
146 goto out; 149 goto out;
147 } else if (query == GET_DEF && probe == 1 && ret != size) { 150 } else if (query == UVC_GET_DEF && probe == 1 && ret != size) {
148 /* Many cameras don't support the GET_DEF request on their 151 /* Many cameras don't support the GET_DEF request on their
149 * video probe control. Warn once and return, the caller will 152 * video probe control. Warn once and return, the caller will
150 * fall back to GET_CUR. 153 * fall back to GET_CUR.
151 */ 154 */
152 uvc_warn_once(video->dev, UVC_WARN_PROBE_DEF, "UVC non " 155 uvc_warn_once(stream->dev, UVC_WARN_PROBE_DEF, "UVC non "
153 "compliance - GET_DEF(PROBE) not supported. " 156 "compliance - GET_DEF(PROBE) not supported. "
154 "Enabling workaround.\n"); 157 "Enabling workaround.\n");
155 ret = -EIO; 158 ret = -EIO;
@@ -181,7 +184,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video,
181 ctrl->bMinVersion = data[32]; 184 ctrl->bMinVersion = data[32];
182 ctrl->bMaxVersion = data[33]; 185 ctrl->bMaxVersion = data[33];
183 } else { 186 } else {
184 ctrl->dwClockFrequency = video->dev->clock_frequency; 187 ctrl->dwClockFrequency = stream->dev->clock_frequency;
185 ctrl->bmFramingInfo = 0; 188 ctrl->bmFramingInfo = 0;
186 ctrl->bPreferedVersion = 0; 189 ctrl->bPreferedVersion = 0;
187 ctrl->bMinVersion = 0; 190 ctrl->bMinVersion = 0;
@@ -192,7 +195,7 @@ static int uvc_get_video_ctrl(struct uvc_video_device *video,
192 * dwMaxPayloadTransferSize fields. Try to get the value from the 195 * dwMaxPayloadTransferSize fields. Try to get the value from the
193 * format and frame descriptors. 196 * format and frame descriptors.
194 */ 197 */
195 uvc_fixup_video_ctrl(video, ctrl); 198 uvc_fixup_video_ctrl(stream, ctrl);
196 ret = 0; 199 ret = 0;
197 200
198out: 201out:
@@ -200,14 +203,14 @@ out:
200 return ret; 203 return ret;
201} 204}
202 205
203static int uvc_set_video_ctrl(struct uvc_video_device *video, 206static int uvc_set_video_ctrl(struct uvc_streaming *stream,
204 struct uvc_streaming_control *ctrl, int probe) 207 struct uvc_streaming_control *ctrl, int probe)
205{ 208{
206 __u8 *data; 209 __u8 *data;
207 __u16 size; 210 __u16 size;
208 int ret; 211 int ret;
209 212
210 size = video->dev->uvc_version >= 0x0110 ? 34 : 26; 213 size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
211 data = kzalloc(size, GFP_KERNEL); 214 data = kzalloc(size, GFP_KERNEL);
212 if (data == NULL) 215 if (data == NULL)
213 return -ENOMEM; 216 return -ENOMEM;
@@ -232,10 +235,9 @@ static int uvc_set_video_ctrl(struct uvc_video_device *video,
232 data[33] = ctrl->bMaxVersion; 235 data[33] = ctrl->bMaxVersion;
233 } 236 }
234 237
235 ret = __uvc_query_ctrl(video->dev, SET_CUR, 0, 238 ret = __uvc_query_ctrl(stream->dev, UVC_SET_CUR, 0, stream->intfnum,
236 video->streaming->intfnum, 239 probe ? UVC_VS_PROBE_CONTROL : UVC_VS_COMMIT_CONTROL, data,
237 probe ? VS_PROBE_CONTROL : VS_COMMIT_CONTROL, data, size, 240 size, UVC_CTRL_STREAMING_TIMEOUT);
238 UVC_CTRL_STREAMING_TIMEOUT);
239 if (ret != size) { 241 if (ret != size) {
240 uvc_printk(KERN_ERR, "Failed to set UVC %s control : " 242 uvc_printk(KERN_ERR, "Failed to set UVC %s control : "
241 "%d (exp. %u).\n", probe ? "probe" : "commit", 243 "%d (exp. %u).\n", probe ? "probe" : "commit",
@@ -247,7 +249,7 @@ static int uvc_set_video_ctrl(struct uvc_video_device *video,
247 return ret; 249 return ret;
248} 250}
249 251
250int uvc_probe_video(struct uvc_video_device *video, 252int uvc_probe_video(struct uvc_streaming *stream,
251 struct uvc_streaming_control *probe) 253 struct uvc_streaming_control *probe)
252{ 254{
253 struct uvc_streaming_control probe_min, probe_max; 255 struct uvc_streaming_control probe_min, probe_max;
@@ -255,7 +257,7 @@ int uvc_probe_video(struct uvc_video_device *video,
255 unsigned int i; 257 unsigned int i;
256 int ret; 258 int ret;
257 259
258 mutex_lock(&video->streaming->mutex); 260 mutex_lock(&stream->mutex);
259 261
260 /* Perform probing. The device should adjust the requested values 262 /* Perform probing. The device should adjust the requested values
261 * according to its capabilities. However, some devices, namely the 263 * according to its capabilities. However, some devices, namely the
@@ -264,15 +266,16 @@ int uvc_probe_video(struct uvc_video_device *video,
264 * that reason, if the needed bandwidth exceeds the maximum available 266 * that reason, if the needed bandwidth exceeds the maximum available
265 * bandwidth, try to lower the quality. 267 * bandwidth, try to lower the quality.
266 */ 268 */
267 if ((ret = uvc_set_video_ctrl(video, probe, 1)) < 0) 269 ret = uvc_set_video_ctrl(stream, probe, 1);
270 if (ret < 0)
268 goto done; 271 goto done;
269 272
270 /* Get the minimum and maximum values for compression settings. */ 273 /* Get the minimum and maximum values for compression settings. */
271 if (!(video->dev->quirks & UVC_QUIRK_PROBE_MINMAX)) { 274 if (!(stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX)) {
272 ret = uvc_get_video_ctrl(video, &probe_min, 1, GET_MIN); 275 ret = uvc_get_video_ctrl(stream, &probe_min, 1, UVC_GET_MIN);
273 if (ret < 0) 276 if (ret < 0)
274 goto done; 277 goto done;
275 ret = uvc_get_video_ctrl(video, &probe_max, 1, GET_MAX); 278 ret = uvc_get_video_ctrl(stream, &probe_max, 1, UVC_GET_MAX);
276 if (ret < 0) 279 if (ret < 0)
277 goto done; 280 goto done;
278 281
@@ -280,18 +283,21 @@ int uvc_probe_video(struct uvc_video_device *video,
280 } 283 }
281 284
282 for (i = 0; i < 2; ++i) { 285 for (i = 0; i < 2; ++i) {
283 if ((ret = uvc_set_video_ctrl(video, probe, 1)) < 0 || 286 ret = uvc_set_video_ctrl(stream, probe, 1);
284 (ret = uvc_get_video_ctrl(video, probe, 1, GET_CUR)) < 0) 287 if (ret < 0)
288 goto done;
289 ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR);
290 if (ret < 0)
285 goto done; 291 goto done;
286 292
287 if (video->streaming->intf->num_altsetting == 1) 293 if (stream->intf->num_altsetting == 1)
288 break; 294 break;
289 295
290 bandwidth = probe->dwMaxPayloadTransferSize; 296 bandwidth = probe->dwMaxPayloadTransferSize;
291 if (bandwidth <= video->streaming->maxpsize) 297 if (bandwidth <= stream->maxpsize)
292 break; 298 break;
293 299
294 if (video->dev->quirks & UVC_QUIRK_PROBE_MINMAX) { 300 if (stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX) {
295 ret = -ENOSPC; 301 ret = -ENOSPC;
296 goto done; 302 goto done;
297 } 303 }
@@ -304,14 +310,14 @@ int uvc_probe_video(struct uvc_video_device *video,
304 } 310 }
305 311
306done: 312done:
307 mutex_unlock(&video->streaming->mutex); 313 mutex_unlock(&stream->mutex);
308 return ret; 314 return ret;
309} 315}
310 316
311int uvc_commit_video(struct uvc_video_device *video, 317int uvc_commit_video(struct uvc_streaming *stream,
312 struct uvc_streaming_control *probe) 318 struct uvc_streaming_control *probe)
313{ 319{
314 return uvc_set_video_ctrl(video, probe, 0); 320 return uvc_set_video_ctrl(stream, probe, 0);
315} 321}
316 322
317/* ------------------------------------------------------------------------ 323/* ------------------------------------------------------------------------
@@ -363,7 +369,7 @@ int uvc_commit_video(struct uvc_video_device *video,
363 * to be called with a NULL buf parameter. uvc_video_decode_data and 369 * to be called with a NULL buf parameter. uvc_video_decode_data and
364 * uvc_video_decode_end will never be called with a NULL buffer. 370 * uvc_video_decode_end will never be called with a NULL buffer.
365 */ 371 */
366static int uvc_video_decode_start(struct uvc_video_device *video, 372static int uvc_video_decode_start(struct uvc_streaming *stream,
367 struct uvc_buffer *buf, const __u8 *data, int len) 373 struct uvc_buffer *buf, const __u8 *data, int len)
368{ 374{
369 __u8 fid; 375 __u8 fid;
@@ -389,25 +395,25 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
389 * NULL. 395 * NULL.
390 */ 396 */
391 if (buf == NULL) { 397 if (buf == NULL) {
392 video->last_fid = fid; 398 stream->last_fid = fid;
393 return -ENODATA; 399 return -ENODATA;
394 } 400 }
395 401
396 /* Synchronize to the input stream by waiting for the FID bit to be 402 /* Synchronize to the input stream by waiting for the FID bit to be
397 * toggled when the the buffer state is not UVC_BUF_STATE_ACTIVE. 403 * toggled when the the buffer state is not UVC_BUF_STATE_ACTIVE.
398 * video->last_fid is initialized to -1, so the first isochronous 404 * stream->last_fid is initialized to -1, so the first isochronous
399 * frame will always be in sync. 405 * frame will always be in sync.
400 * 406 *
401 * If the device doesn't toggle the FID bit, invert video->last_fid 407 * If the device doesn't toggle the FID bit, invert stream->last_fid
402 * when the EOF bit is set to force synchronisation on the next packet. 408 * when the EOF bit is set to force synchronisation on the next packet.
403 */ 409 */
404 if (buf->state != UVC_BUF_STATE_ACTIVE) { 410 if (buf->state != UVC_BUF_STATE_ACTIVE) {
405 if (fid == video->last_fid) { 411 if (fid == stream->last_fid) {
406 uvc_trace(UVC_TRACE_FRAME, "Dropping payload (out of " 412 uvc_trace(UVC_TRACE_FRAME, "Dropping payload (out of "
407 "sync).\n"); 413 "sync).\n");
408 if ((video->dev->quirks & UVC_QUIRK_STREAM_NO_FID) && 414 if ((stream->dev->quirks & UVC_QUIRK_STREAM_NO_FID) &&
409 (data[1] & UVC_STREAM_EOF)) 415 (data[1] & UVC_STREAM_EOF))
410 video->last_fid ^= UVC_STREAM_FID; 416 stream->last_fid ^= UVC_STREAM_FID;
411 return -ENODATA; 417 return -ENODATA;
412 } 418 }
413 419
@@ -422,7 +428,7 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
422 * last payload can be lost anyway). We thus must check if the FID has 428 * last payload can be lost anyway). We thus must check if the FID has
423 * been toggled. 429 * been toggled.
424 * 430 *
425 * video->last_fid is initialized to -1, so the first isochronous 431 * stream->last_fid is initialized to -1, so the first isochronous
426 * frame will never trigger an end of frame detection. 432 * frame will never trigger an end of frame detection.
427 * 433 *
428 * Empty buffers (bytesused == 0) don't trigger end of frame detection 434 * Empty buffers (bytesused == 0) don't trigger end of frame detection
@@ -430,22 +436,22 @@ static int uvc_video_decode_start(struct uvc_video_device *video,
430 * avoids detecting end of frame conditions at FID toggling if the 436 * avoids detecting end of frame conditions at FID toggling if the
431 * previous payload had the EOF bit set. 437 * previous payload had the EOF bit set.
432 */ 438 */
433 if (fid != video->last_fid && buf->buf.bytesused != 0) { 439 if (fid != stream->last_fid && buf->buf.bytesused != 0) {
434 uvc_trace(UVC_TRACE_FRAME, "Frame complete (FID bit " 440 uvc_trace(UVC_TRACE_FRAME, "Frame complete (FID bit "
435 "toggled).\n"); 441 "toggled).\n");
436 buf->state = UVC_BUF_STATE_DONE; 442 buf->state = UVC_BUF_STATE_DONE;
437 return -EAGAIN; 443 return -EAGAIN;
438 } 444 }
439 445
440 video->last_fid = fid; 446 stream->last_fid = fid;
441 447
442 return data[0]; 448 return data[0];
443} 449}
444 450
445static void uvc_video_decode_data(struct uvc_video_device *video, 451static void uvc_video_decode_data(struct uvc_streaming *stream,
446 struct uvc_buffer *buf, const __u8 *data, int len) 452 struct uvc_buffer *buf, const __u8 *data, int len)
447{ 453{
448 struct uvc_video_queue *queue = &video->queue; 454 struct uvc_video_queue *queue = &stream->queue;
449 unsigned int maxlen, nbytes; 455 unsigned int maxlen, nbytes;
450 void *mem; 456 void *mem;
451 457
@@ -466,7 +472,7 @@ static void uvc_video_decode_data(struct uvc_video_device *video,
466 } 472 }
467} 473}
468 474
469static void uvc_video_decode_end(struct uvc_video_device *video, 475static void uvc_video_decode_end(struct uvc_streaming *stream,
470 struct uvc_buffer *buf, const __u8 *data, int len) 476 struct uvc_buffer *buf, const __u8 *data, int len)
471{ 477{
472 /* Mark the buffer as done if the EOF marker is set. */ 478 /* Mark the buffer as done if the EOF marker is set. */
@@ -475,8 +481,8 @@ static void uvc_video_decode_end(struct uvc_video_device *video,
475 if (data[0] == len) 481 if (data[0] == len)
476 uvc_trace(UVC_TRACE_FRAME, "EOF in empty payload.\n"); 482 uvc_trace(UVC_TRACE_FRAME, "EOF in empty payload.\n");
477 buf->state = UVC_BUF_STATE_DONE; 483 buf->state = UVC_BUF_STATE_DONE;
478 if (video->dev->quirks & UVC_QUIRK_STREAM_NO_FID) 484 if (stream->dev->quirks & UVC_QUIRK_STREAM_NO_FID)
479 video->last_fid ^= UVC_STREAM_FID; 485 stream->last_fid ^= UVC_STREAM_FID;
480 } 486 }
481} 487}
482 488
@@ -491,26 +497,26 @@ static void uvc_video_decode_end(struct uvc_video_device *video,
491 * uvc_video_encode_data is called for every URB and copies the data from the 497 * uvc_video_encode_data is called for every URB and copies the data from the
492 * video buffer to the transfer buffer. 498 * video buffer to the transfer buffer.
493 */ 499 */
494static int uvc_video_encode_header(struct uvc_video_device *video, 500static int uvc_video_encode_header(struct uvc_streaming *stream,
495 struct uvc_buffer *buf, __u8 *data, int len) 501 struct uvc_buffer *buf, __u8 *data, int len)
496{ 502{
497 data[0] = 2; /* Header length */ 503 data[0] = 2; /* Header length */
498 data[1] = UVC_STREAM_EOH | UVC_STREAM_EOF 504 data[1] = UVC_STREAM_EOH | UVC_STREAM_EOF
499 | (video->last_fid & UVC_STREAM_FID); 505 | (stream->last_fid & UVC_STREAM_FID);
500 return 2; 506 return 2;
501} 507}
502 508
503static int uvc_video_encode_data(struct uvc_video_device *video, 509static int uvc_video_encode_data(struct uvc_streaming *stream,
504 struct uvc_buffer *buf, __u8 *data, int len) 510 struct uvc_buffer *buf, __u8 *data, int len)
505{ 511{
506 struct uvc_video_queue *queue = &video->queue; 512 struct uvc_video_queue *queue = &stream->queue;
507 unsigned int nbytes; 513 unsigned int nbytes;
508 void *mem; 514 void *mem;
509 515
510 /* Copy video data to the URB buffer. */ 516 /* Copy video data to the URB buffer. */
511 mem = queue->mem + buf->buf.m.offset + queue->buf_used; 517 mem = queue->mem + buf->buf.m.offset + queue->buf_used;
512 nbytes = min((unsigned int)len, buf->buf.bytesused - queue->buf_used); 518 nbytes = min((unsigned int)len, buf->buf.bytesused - queue->buf_used);
513 nbytes = min(video->bulk.max_payload_size - video->bulk.payload_size, 519 nbytes = min(stream->bulk.max_payload_size - stream->bulk.payload_size,
514 nbytes); 520 nbytes);
515 memcpy(data, mem, nbytes); 521 memcpy(data, mem, nbytes);
516 522
@@ -526,8 +532,8 @@ static int uvc_video_encode_data(struct uvc_video_device *video,
526/* 532/*
527 * Completion handler for video URBs. 533 * Completion handler for video URBs.
528 */ 534 */
529static void uvc_video_decode_isoc(struct urb *urb, 535static void uvc_video_decode_isoc(struct urb *urb, struct uvc_streaming *stream,
530 struct uvc_video_device *video, struct uvc_buffer *buf) 536 struct uvc_buffer *buf)
531{ 537{
532 u8 *mem; 538 u8 *mem;
533 int ret, i; 539 int ret, i;
@@ -542,31 +548,32 @@ static void uvc_video_decode_isoc(struct urb *urb,
542 /* Decode the payload header. */ 548 /* Decode the payload header. */
543 mem = urb->transfer_buffer + urb->iso_frame_desc[i].offset; 549 mem = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
544 do { 550 do {
545 ret = uvc_video_decode_start(video, buf, mem, 551 ret = uvc_video_decode_start(stream, buf, mem,
546 urb->iso_frame_desc[i].actual_length); 552 urb->iso_frame_desc[i].actual_length);
547 if (ret == -EAGAIN) 553 if (ret == -EAGAIN)
548 buf = uvc_queue_next_buffer(&video->queue, buf); 554 buf = uvc_queue_next_buffer(&stream->queue,
555 buf);
549 } while (ret == -EAGAIN); 556 } while (ret == -EAGAIN);
550 557
551 if (ret < 0) 558 if (ret < 0)
552 continue; 559 continue;
553 560
554 /* Decode the payload data. */ 561 /* Decode the payload data. */
555 uvc_video_decode_data(video, buf, mem + ret, 562 uvc_video_decode_data(stream, buf, mem + ret,
556 urb->iso_frame_desc[i].actual_length - ret); 563 urb->iso_frame_desc[i].actual_length - ret);
557 564
558 /* Process the header again. */ 565 /* Process the header again. */
559 uvc_video_decode_end(video, buf, mem, 566 uvc_video_decode_end(stream, buf, mem,
560 urb->iso_frame_desc[i].actual_length); 567 urb->iso_frame_desc[i].actual_length);
561 568
562 if (buf->state == UVC_BUF_STATE_DONE || 569 if (buf->state == UVC_BUF_STATE_DONE ||
563 buf->state == UVC_BUF_STATE_ERROR) 570 buf->state == UVC_BUF_STATE_ERROR)
564 buf = uvc_queue_next_buffer(&video->queue, buf); 571 buf = uvc_queue_next_buffer(&stream->queue, buf);
565 } 572 }
566} 573}
567 574
568static void uvc_video_decode_bulk(struct urb *urb, 575static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream,
569 struct uvc_video_device *video, struct uvc_buffer *buf) 576 struct uvc_buffer *buf)
570{ 577{
571 u8 *mem; 578 u8 *mem;
572 int len, ret; 579 int len, ret;
@@ -576,24 +583,25 @@ static void uvc_video_decode_bulk(struct urb *urb,
576 583
577 mem = urb->transfer_buffer; 584 mem = urb->transfer_buffer;
578 len = urb->actual_length; 585 len = urb->actual_length;
579 video->bulk.payload_size += len; 586 stream->bulk.payload_size += len;
580 587
581 /* If the URB is the first of its payload, decode and save the 588 /* If the URB is the first of its payload, decode and save the
582 * header. 589 * header.
583 */ 590 */
584 if (video->bulk.header_size == 0 && !video->bulk.skip_payload) { 591 if (stream->bulk.header_size == 0 && !stream->bulk.skip_payload) {
585 do { 592 do {
586 ret = uvc_video_decode_start(video, buf, mem, len); 593 ret = uvc_video_decode_start(stream, buf, mem, len);
587 if (ret == -EAGAIN) 594 if (ret == -EAGAIN)
588 buf = uvc_queue_next_buffer(&video->queue, buf); 595 buf = uvc_queue_next_buffer(&stream->queue,
596 buf);
589 } while (ret == -EAGAIN); 597 } while (ret == -EAGAIN);
590 598
591 /* If an error occured skip the rest of the payload. */ 599 /* If an error occured skip the rest of the payload. */
592 if (ret < 0 || buf == NULL) { 600 if (ret < 0 || buf == NULL) {
593 video->bulk.skip_payload = 1; 601 stream->bulk.skip_payload = 1;
594 } else { 602 } else {
595 memcpy(video->bulk.header, mem, ret); 603 memcpy(stream->bulk.header, mem, ret);
596 video->bulk.header_size = ret; 604 stream->bulk.header_size = ret;
597 605
598 mem += ret; 606 mem += ret;
599 len -= ret; 607 len -= ret;
@@ -606,33 +614,34 @@ static void uvc_video_decode_bulk(struct urb *urb,
606 */ 614 */
607 615
608 /* Process video data. */ 616 /* Process video data. */
609 if (!video->bulk.skip_payload && buf != NULL) 617 if (!stream->bulk.skip_payload && buf != NULL)
610 uvc_video_decode_data(video, buf, mem, len); 618 uvc_video_decode_data(stream, buf, mem, len);
611 619
612 /* Detect the payload end by a URB smaller than the maximum size (or 620 /* Detect the payload end by a URB smaller than the maximum size (or
613 * a payload size equal to the maximum) and process the header again. 621 * a payload size equal to the maximum) and process the header again.
614 */ 622 */
615 if (urb->actual_length < urb->transfer_buffer_length || 623 if (urb->actual_length < urb->transfer_buffer_length ||
616 video->bulk.payload_size >= video->bulk.max_payload_size) { 624 stream->bulk.payload_size >= stream->bulk.max_payload_size) {
617 if (!video->bulk.skip_payload && buf != NULL) { 625 if (!stream->bulk.skip_payload && buf != NULL) {
618 uvc_video_decode_end(video, buf, video->bulk.header, 626 uvc_video_decode_end(stream, buf, stream->bulk.header,
619 video->bulk.payload_size); 627 stream->bulk.payload_size);
620 if (buf->state == UVC_BUF_STATE_DONE || 628 if (buf->state == UVC_BUF_STATE_DONE ||
621 buf->state == UVC_BUF_STATE_ERROR) 629 buf->state == UVC_BUF_STATE_ERROR)
622 buf = uvc_queue_next_buffer(&video->queue, buf); 630 buf = uvc_queue_next_buffer(&stream->queue,
631 buf);
623 } 632 }
624 633
625 video->bulk.header_size = 0; 634 stream->bulk.header_size = 0;
626 video->bulk.skip_payload = 0; 635 stream->bulk.skip_payload = 0;
627 video->bulk.payload_size = 0; 636 stream->bulk.payload_size = 0;
628 } 637 }
629} 638}
630 639
631static void uvc_video_encode_bulk(struct urb *urb, 640static void uvc_video_encode_bulk(struct urb *urb, struct uvc_streaming *stream,
632 struct uvc_video_device *video, struct uvc_buffer *buf) 641 struct uvc_buffer *buf)
633{ 642{
634 u8 *mem = urb->transfer_buffer; 643 u8 *mem = urb->transfer_buffer;
635 int len = video->urb_size, ret; 644 int len = stream->urb_size, ret;
636 645
637 if (buf == NULL) { 646 if (buf == NULL) {
638 urb->transfer_buffer_length = 0; 647 urb->transfer_buffer_length = 0;
@@ -640,40 +649,40 @@ static void uvc_video_encode_bulk(struct urb *urb,
640 } 649 }
641 650
642 /* If the URB is the first of its payload, add the header. */ 651 /* If the URB is the first of its payload, add the header. */
643 if (video->bulk.header_size == 0) { 652 if (stream->bulk.header_size == 0) {
644 ret = uvc_video_encode_header(video, buf, mem, len); 653 ret = uvc_video_encode_header(stream, buf, mem, len);
645 video->bulk.header_size = ret; 654 stream->bulk.header_size = ret;
646 video->bulk.payload_size += ret; 655 stream->bulk.payload_size += ret;
647 mem += ret; 656 mem += ret;
648 len -= ret; 657 len -= ret;
649 } 658 }
650 659
651 /* Process video data. */ 660 /* Process video data. */
652 ret = uvc_video_encode_data(video, buf, mem, len); 661 ret = uvc_video_encode_data(stream, buf, mem, len);
653 662
654 video->bulk.payload_size += ret; 663 stream->bulk.payload_size += ret;
655 len -= ret; 664 len -= ret;
656 665
657 if (buf->buf.bytesused == video->queue.buf_used || 666 if (buf->buf.bytesused == stream->queue.buf_used ||
658 video->bulk.payload_size == video->bulk.max_payload_size) { 667 stream->bulk.payload_size == stream->bulk.max_payload_size) {
659 if (buf->buf.bytesused == video->queue.buf_used) { 668 if (buf->buf.bytesused == stream->queue.buf_used) {
660 video->queue.buf_used = 0; 669 stream->queue.buf_used = 0;
661 buf->state = UVC_BUF_STATE_DONE; 670 buf->state = UVC_BUF_STATE_DONE;
662 uvc_queue_next_buffer(&video->queue, buf); 671 uvc_queue_next_buffer(&stream->queue, buf);
663 video->last_fid ^= UVC_STREAM_FID; 672 stream->last_fid ^= UVC_STREAM_FID;
664 } 673 }
665 674
666 video->bulk.header_size = 0; 675 stream->bulk.header_size = 0;
667 video->bulk.payload_size = 0; 676 stream->bulk.payload_size = 0;
668 } 677 }
669 678
670 urb->transfer_buffer_length = video->urb_size - len; 679 urb->transfer_buffer_length = stream->urb_size - len;
671} 680}
672 681
673static void uvc_video_complete(struct urb *urb) 682static void uvc_video_complete(struct urb *urb)
674{ 683{
675 struct uvc_video_device *video = urb->context; 684 struct uvc_streaming *stream = urb->context;
676 struct uvc_video_queue *queue = &video->queue; 685 struct uvc_video_queue *queue = &stream->queue;
677 struct uvc_buffer *buf = NULL; 686 struct uvc_buffer *buf = NULL;
678 unsigned long flags; 687 unsigned long flags;
679 int ret; 688 int ret;
@@ -687,7 +696,7 @@ static void uvc_video_complete(struct urb *urb)
687 "completion handler.\n", urb->status); 696 "completion handler.\n", urb->status);
688 697
689 case -ENOENT: /* usb_kill_urb() called. */ 698 case -ENOENT: /* usb_kill_urb() called. */
690 if (video->frozen) 699 if (stream->frozen)
691 return; 700 return;
692 701
693 case -ECONNRESET: /* usb_unlink_urb() called. */ 702 case -ECONNRESET: /* usb_unlink_urb() called. */
@@ -702,7 +711,7 @@ static void uvc_video_complete(struct urb *urb)
702 queue); 711 queue);
703 spin_unlock_irqrestore(&queue->irqlock, flags); 712 spin_unlock_irqrestore(&queue->irqlock, flags);
704 713
705 video->decode(urb, video, buf); 714 stream->decode(urb, stream, buf);
706 715
707 if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 716 if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
708 uvc_printk(KERN_ERR, "Failed to resubmit video URB (%d).\n", 717 uvc_printk(KERN_ERR, "Failed to resubmit video URB (%d).\n",
@@ -713,19 +722,19 @@ static void uvc_video_complete(struct urb *urb)
713/* 722/*
714 * Free transfer buffers. 723 * Free transfer buffers.
715 */ 724 */
716static void uvc_free_urb_buffers(struct uvc_video_device *video) 725static void uvc_free_urb_buffers(struct uvc_streaming *stream)
717{ 726{
718 unsigned int i; 727 unsigned int i;
719 728
720 for (i = 0; i < UVC_URBS; ++i) { 729 for (i = 0; i < UVC_URBS; ++i) {
721 if (video->urb_buffer[i]) { 730 if (stream->urb_buffer[i]) {
722 usb_buffer_free(video->dev->udev, video->urb_size, 731 usb_buffer_free(stream->dev->udev, stream->urb_size,
723 video->urb_buffer[i], video->urb_dma[i]); 732 stream->urb_buffer[i], stream->urb_dma[i]);
724 video->urb_buffer[i] = NULL; 733 stream->urb_buffer[i] = NULL;
725 } 734 }
726 } 735 }
727 736
728 video->urb_size = 0; 737 stream->urb_size = 0;
729} 738}
730 739
731/* 740/*
@@ -739,15 +748,15 @@ static void uvc_free_urb_buffers(struct uvc_video_device *video)
739 * 748 *
740 * Return the number of allocated packets on success or 0 when out of memory. 749 * Return the number of allocated packets on success or 0 when out of memory.
741 */ 750 */
742static int uvc_alloc_urb_buffers(struct uvc_video_device *video, 751static int uvc_alloc_urb_buffers(struct uvc_streaming *stream,
743 unsigned int size, unsigned int psize, gfp_t gfp_flags) 752 unsigned int size, unsigned int psize, gfp_t gfp_flags)
744{ 753{
745 unsigned int npackets; 754 unsigned int npackets;
746 unsigned int i; 755 unsigned int i;
747 756
748 /* Buffers are already allocated, bail out. */ 757 /* Buffers are already allocated, bail out. */
749 if (video->urb_size) 758 if (stream->urb_size)
750 return video->urb_size / psize; 759 return stream->urb_size / psize;
751 760
752 /* Compute the number of packets. Bulk endpoints might transfer UVC 761 /* Compute the number of packets. Bulk endpoints might transfer UVC
753 * payloads accross multiple URBs. 762 * payloads accross multiple URBs.
@@ -759,17 +768,17 @@ static int uvc_alloc_urb_buffers(struct uvc_video_device *video,
759 /* Retry allocations until one succeed. */ 768 /* Retry allocations until one succeed. */
760 for (; npackets > 1; npackets /= 2) { 769 for (; npackets > 1; npackets /= 2) {
761 for (i = 0; i < UVC_URBS; ++i) { 770 for (i = 0; i < UVC_URBS; ++i) {
762 video->urb_buffer[i] = usb_buffer_alloc( 771 stream->urb_buffer[i] = usb_buffer_alloc(
763 video->dev->udev, psize * npackets, 772 stream->dev->udev, psize * npackets,
764 gfp_flags | __GFP_NOWARN, &video->urb_dma[i]); 773 gfp_flags | __GFP_NOWARN, &stream->urb_dma[i]);
765 if (!video->urb_buffer[i]) { 774 if (!stream->urb_buffer[i]) {
766 uvc_free_urb_buffers(video); 775 uvc_free_urb_buffers(stream);
767 break; 776 break;
768 } 777 }
769 } 778 }
770 779
771 if (i == UVC_URBS) { 780 if (i == UVC_URBS) {
772 video->urb_size = psize * npackets; 781 stream->urb_size = psize * npackets;
773 return npackets; 782 return npackets;
774 } 783 }
775 } 784 }
@@ -780,29 +789,30 @@ static int uvc_alloc_urb_buffers(struct uvc_video_device *video,
780/* 789/*
781 * Uninitialize isochronous/bulk URBs and free transfer buffers. 790 * Uninitialize isochronous/bulk URBs and free transfer buffers.
782 */ 791 */
783static void uvc_uninit_video(struct uvc_video_device *video, int free_buffers) 792static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers)
784{ 793{
785 struct urb *urb; 794 struct urb *urb;
786 unsigned int i; 795 unsigned int i;
787 796
788 for (i = 0; i < UVC_URBS; ++i) { 797 for (i = 0; i < UVC_URBS; ++i) {
789 if ((urb = video->urb[i]) == NULL) 798 urb = stream->urb[i];
799 if (urb == NULL)
790 continue; 800 continue;
791 801
792 usb_kill_urb(urb); 802 usb_kill_urb(urb);
793 usb_free_urb(urb); 803 usb_free_urb(urb);
794 video->urb[i] = NULL; 804 stream->urb[i] = NULL;
795 } 805 }
796 806
797 if (free_buffers) 807 if (free_buffers)
798 uvc_free_urb_buffers(video); 808 uvc_free_urb_buffers(stream);
799} 809}
800 810
801/* 811/*
802 * Initialize isochronous URBs and allocate transfer buffers. The packet size 812 * Initialize isochronous URBs and allocate transfer buffers. The packet size
803 * is given by the endpoint. 813 * is given by the endpoint.
804 */ 814 */
805static int uvc_init_video_isoc(struct uvc_video_device *video, 815static int uvc_init_video_isoc(struct uvc_streaming *stream,
806 struct usb_host_endpoint *ep, gfp_t gfp_flags) 816 struct usb_host_endpoint *ep, gfp_t gfp_flags)
807{ 817{
808 struct urb *urb; 818 struct urb *urb;
@@ -812,9 +822,9 @@ static int uvc_init_video_isoc(struct uvc_video_device *video,
812 822
813 psize = le16_to_cpu(ep->desc.wMaxPacketSize); 823 psize = le16_to_cpu(ep->desc.wMaxPacketSize);
814 psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); 824 psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3));
815 size = video->streaming->ctrl.dwMaxVideoFrameSize; 825 size = stream->ctrl.dwMaxVideoFrameSize;
816 826
817 npackets = uvc_alloc_urb_buffers(video, size, psize, gfp_flags); 827 npackets = uvc_alloc_urb_buffers(stream, size, psize, gfp_flags);
818 if (npackets == 0) 828 if (npackets == 0)
819 return -ENOMEM; 829 return -ENOMEM;
820 830
@@ -823,18 +833,18 @@ static int uvc_init_video_isoc(struct uvc_video_device *video,
823 for (i = 0; i < UVC_URBS; ++i) { 833 for (i = 0; i < UVC_URBS; ++i) {
824 urb = usb_alloc_urb(npackets, gfp_flags); 834 urb = usb_alloc_urb(npackets, gfp_flags);
825 if (urb == NULL) { 835 if (urb == NULL) {
826 uvc_uninit_video(video, 1); 836 uvc_uninit_video(stream, 1);
827 return -ENOMEM; 837 return -ENOMEM;
828 } 838 }
829 839
830 urb->dev = video->dev->udev; 840 urb->dev = stream->dev->udev;
831 urb->context = video; 841 urb->context = stream;
832 urb->pipe = usb_rcvisocpipe(video->dev->udev, 842 urb->pipe = usb_rcvisocpipe(stream->dev->udev,
833 ep->desc.bEndpointAddress); 843 ep->desc.bEndpointAddress);
834 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; 844 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
835 urb->interval = ep->desc.bInterval; 845 urb->interval = ep->desc.bInterval;
836 urb->transfer_buffer = video->urb_buffer[i]; 846 urb->transfer_buffer = stream->urb_buffer[i];
837 urb->transfer_dma = video->urb_dma[i]; 847 urb->transfer_dma = stream->urb_dma[i];
838 urb->complete = uvc_video_complete; 848 urb->complete = uvc_video_complete;
839 urb->number_of_packets = npackets; 849 urb->number_of_packets = npackets;
840 urb->transfer_buffer_length = size; 850 urb->transfer_buffer_length = size;
@@ -844,7 +854,7 @@ static int uvc_init_video_isoc(struct uvc_video_device *video,
844 urb->iso_frame_desc[j].length = psize; 854 urb->iso_frame_desc[j].length = psize;
845 } 855 }
846 856
847 video->urb[i] = urb; 857 stream->urb[i] = urb;
848 } 858 }
849 859
850 return 0; 860 return 0;
@@ -854,7 +864,7 @@ static int uvc_init_video_isoc(struct uvc_video_device *video,
854 * Initialize bulk URBs and allocate transfer buffers. The packet size is 864 * Initialize bulk URBs and allocate transfer buffers. The packet size is
855 * given by the endpoint. 865 * given by the endpoint.
856 */ 866 */
857static int uvc_init_video_bulk(struct uvc_video_device *video, 867static int uvc_init_video_bulk(struct uvc_streaming *stream,
858 struct usb_host_endpoint *ep, gfp_t gfp_flags) 868 struct usb_host_endpoint *ep, gfp_t gfp_flags)
859{ 869{
860 struct urb *urb; 870 struct urb *urb;
@@ -863,39 +873,39 @@ static int uvc_init_video_bulk(struct uvc_video_device *video,
863 u32 size; 873 u32 size;
864 874
865 psize = le16_to_cpu(ep->desc.wMaxPacketSize) & 0x07ff; 875 psize = le16_to_cpu(ep->desc.wMaxPacketSize) & 0x07ff;
866 size = video->streaming->ctrl.dwMaxPayloadTransferSize; 876 size = stream->ctrl.dwMaxPayloadTransferSize;
867 video->bulk.max_payload_size = size; 877 stream->bulk.max_payload_size = size;
868 878
869 npackets = uvc_alloc_urb_buffers(video, size, psize, gfp_flags); 879 npackets = uvc_alloc_urb_buffers(stream, size, psize, gfp_flags);
870 if (npackets == 0) 880 if (npackets == 0)
871 return -ENOMEM; 881 return -ENOMEM;
872 882
873 size = npackets * psize; 883 size = npackets * psize;
874 884
875 if (usb_endpoint_dir_in(&ep->desc)) 885 if (usb_endpoint_dir_in(&ep->desc))
876 pipe = usb_rcvbulkpipe(video->dev->udev, 886 pipe = usb_rcvbulkpipe(stream->dev->udev,
877 ep->desc.bEndpointAddress); 887 ep->desc.bEndpointAddress);
878 else 888 else
879 pipe = usb_sndbulkpipe(video->dev->udev, 889 pipe = usb_sndbulkpipe(stream->dev->udev,
880 ep->desc.bEndpointAddress); 890 ep->desc.bEndpointAddress);
881 891
882 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) 892 if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
883 size = 0; 893 size = 0;
884 894
885 for (i = 0; i < UVC_URBS; ++i) { 895 for (i = 0; i < UVC_URBS; ++i) {
886 urb = usb_alloc_urb(0, gfp_flags); 896 urb = usb_alloc_urb(0, gfp_flags);
887 if (urb == NULL) { 897 if (urb == NULL) {
888 uvc_uninit_video(video, 1); 898 uvc_uninit_video(stream, 1);
889 return -ENOMEM; 899 return -ENOMEM;
890 } 900 }
891 901
892 usb_fill_bulk_urb(urb, video->dev->udev, pipe, 902 usb_fill_bulk_urb(urb, stream->dev->udev, pipe,
893 video->urb_buffer[i], size, uvc_video_complete, 903 stream->urb_buffer[i], size, uvc_video_complete,
894 video); 904 stream);
895 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 905 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
896 urb->transfer_dma = video->urb_dma[i]; 906 urb->transfer_dma = stream->urb_dma[i];
897 907
898 video->urb[i] = urb; 908 stream->urb[i] = urb;
899 } 909 }
900 910
901 return 0; 911 return 0;
@@ -904,35 +914,35 @@ static int uvc_init_video_bulk(struct uvc_video_device *video,
904/* 914/*
905 * Initialize isochronous/bulk URBs and allocate transfer buffers. 915 * Initialize isochronous/bulk URBs and allocate transfer buffers.
906 */ 916 */
907static int uvc_init_video(struct uvc_video_device *video, gfp_t gfp_flags) 917static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags)
908{ 918{
909 struct usb_interface *intf = video->streaming->intf; 919 struct usb_interface *intf = stream->intf;
910 struct usb_host_interface *alts; 920 struct usb_host_interface *alts;
911 struct usb_host_endpoint *ep = NULL; 921 struct usb_host_endpoint *ep = NULL;
912 int intfnum = video->streaming->intfnum; 922 int intfnum = stream->intfnum;
913 unsigned int bandwidth, psize, i; 923 unsigned int bandwidth, psize, i;
914 int ret; 924 int ret;
915 925
916 video->last_fid = -1; 926 stream->last_fid = -1;
917 video->bulk.header_size = 0; 927 stream->bulk.header_size = 0;
918 video->bulk.skip_payload = 0; 928 stream->bulk.skip_payload = 0;
919 video->bulk.payload_size = 0; 929 stream->bulk.payload_size = 0;
920 930
921 if (intf->num_altsetting > 1) { 931 if (intf->num_altsetting > 1) {
922 /* Isochronous endpoint, select the alternate setting. */ 932 /* Isochronous endpoint, select the alternate setting. */
923 bandwidth = video->streaming->ctrl.dwMaxPayloadTransferSize; 933 bandwidth = stream->ctrl.dwMaxPayloadTransferSize;
924 934
925 if (bandwidth == 0) { 935 if (bandwidth == 0) {
926 uvc_printk(KERN_WARNING, "device %s requested null " 936 uvc_printk(KERN_WARNING, "device %s requested null "
927 "bandwidth, defaulting to lowest.\n", 937 "bandwidth, defaulting to lowest.\n",
928 video->vdev->name); 938 stream->dev->name);
929 bandwidth = 1; 939 bandwidth = 1;
930 } 940 }
931 941
932 for (i = 0; i < intf->num_altsetting; ++i) { 942 for (i = 0; i < intf->num_altsetting; ++i) {
933 alts = &intf->altsetting[i]; 943 alts = &intf->altsetting[i];
934 ep = uvc_find_endpoint(alts, 944 ep = uvc_find_endpoint(alts,
935 video->streaming->header.bEndpointAddress); 945 stream->header.bEndpointAddress);
936 if (ep == NULL) 946 if (ep == NULL)
937 continue; 947 continue;
938 948
@@ -946,18 +956,19 @@ static int uvc_init_video(struct uvc_video_device *video, gfp_t gfp_flags)
946 if (i >= intf->num_altsetting) 956 if (i >= intf->num_altsetting)
947 return -EIO; 957 return -EIO;
948 958
949 if ((ret = usb_set_interface(video->dev->udev, intfnum, i)) < 0) 959 ret = usb_set_interface(stream->dev->udev, intfnum, i);
960 if (ret < 0)
950 return ret; 961 return ret;
951 962
952 ret = uvc_init_video_isoc(video, ep, gfp_flags); 963 ret = uvc_init_video_isoc(stream, ep, gfp_flags);
953 } else { 964 } else {
954 /* Bulk endpoint, proceed to URB initialization. */ 965 /* Bulk endpoint, proceed to URB initialization. */
955 ep = uvc_find_endpoint(&intf->altsetting[0], 966 ep = uvc_find_endpoint(&intf->altsetting[0],
956 video->streaming->header.bEndpointAddress); 967 stream->header.bEndpointAddress);
957 if (ep == NULL) 968 if (ep == NULL)
958 return -EIO; 969 return -EIO;
959 970
960 ret = uvc_init_video_bulk(video, ep, gfp_flags); 971 ret = uvc_init_video_bulk(stream, ep, gfp_flags);
961 } 972 }
962 973
963 if (ret < 0) 974 if (ret < 0)
@@ -965,10 +976,11 @@ static int uvc_init_video(struct uvc_video_device *video, gfp_t gfp_flags)
965 976
966 /* Submit the URBs. */ 977 /* Submit the URBs. */
967 for (i = 0; i < UVC_URBS; ++i) { 978 for (i = 0; i < UVC_URBS; ++i) {
968 if ((ret = usb_submit_urb(video->urb[i], gfp_flags)) < 0) { 979 ret = usb_submit_urb(stream->urb[i], gfp_flags);
980 if (ret < 0) {
969 uvc_printk(KERN_ERR, "Failed to submit URB %u " 981 uvc_printk(KERN_ERR, "Failed to submit URB %u "
970 "(%d).\n", i, ret); 982 "(%d).\n", i, ret);
971 uvc_uninit_video(video, 1); 983 uvc_uninit_video(stream, 1);
972 return ret; 984 return ret;
973 } 985 }
974 } 986 }
@@ -987,14 +999,14 @@ static int uvc_init_video(struct uvc_video_device *video, gfp_t gfp_flags)
987 * video buffers in any way. We mark the device as frozen to make sure the URB 999 * video buffers in any way. We mark the device as frozen to make sure the URB
988 * completion handler won't try to cancel the queue when we kill the URBs. 1000 * completion handler won't try to cancel the queue when we kill the URBs.
989 */ 1001 */
990int uvc_video_suspend(struct uvc_video_device *video) 1002int uvc_video_suspend(struct uvc_streaming *stream)
991{ 1003{
992 if (!uvc_queue_streaming(&video->queue)) 1004 if (!uvc_queue_streaming(&stream->queue))
993 return 0; 1005 return 0;
994 1006
995 video->frozen = 1; 1007 stream->frozen = 1;
996 uvc_uninit_video(video, 0); 1008 uvc_uninit_video(stream, 0);
997 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); 1009 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
998 return 0; 1010 return 0;
999} 1011}
1000 1012
@@ -1006,22 +1018,24 @@ int uvc_video_suspend(struct uvc_video_device *video)
1006 * buffers, making sure userspace applications are notified of the problem 1018 * buffers, making sure userspace applications are notified of the problem
1007 * instead of waiting forever. 1019 * instead of waiting forever.
1008 */ 1020 */
1009int uvc_video_resume(struct uvc_video_device *video) 1021int uvc_video_resume(struct uvc_streaming *stream)
1010{ 1022{
1011 int ret; 1023 int ret;
1012 1024
1013 video->frozen = 0; 1025 stream->frozen = 0;
1014 1026
1015 if ((ret = uvc_commit_video(video, &video->streaming->ctrl)) < 0) { 1027 ret = uvc_commit_video(stream, &stream->ctrl);
1016 uvc_queue_enable(&video->queue, 0); 1028 if (ret < 0) {
1029 uvc_queue_enable(&stream->queue, 0);
1017 return ret; 1030 return ret;
1018 } 1031 }
1019 1032
1020 if (!uvc_queue_streaming(&video->queue)) 1033 if (!uvc_queue_streaming(&stream->queue))
1021 return 0; 1034 return 0;
1022 1035
1023 if ((ret = uvc_init_video(video, GFP_NOIO)) < 0) 1036 ret = uvc_init_video(stream, GFP_NOIO);
1024 uvc_queue_enable(&video->queue, 0); 1037 if (ret < 0)
1038 uvc_queue_enable(&stream->queue, 0);
1025 1039
1026 return ret; 1040 return ret;
1027} 1041}
@@ -1040,47 +1054,53 @@ int uvc_video_resume(struct uvc_video_device *video)
1040 * 1054 *
1041 * This function is called before registering the device with V4L. 1055 * This function is called before registering the device with V4L.
1042 */ 1056 */
1043int uvc_video_init(struct uvc_video_device *video) 1057int uvc_video_init(struct uvc_streaming *stream)
1044{ 1058{
1045 struct uvc_streaming_control *probe = &video->streaming->ctrl; 1059 struct uvc_streaming_control *probe = &stream->ctrl;
1046 struct uvc_format *format = NULL; 1060 struct uvc_format *format = NULL;
1047 struct uvc_frame *frame = NULL; 1061 struct uvc_frame *frame = NULL;
1048 unsigned int i; 1062 unsigned int i;
1049 int ret; 1063 int ret;
1050 1064
1051 if (video->streaming->nformats == 0) { 1065 if (stream->nformats == 0) {
1052 uvc_printk(KERN_INFO, "No supported video formats found.\n"); 1066 uvc_printk(KERN_INFO, "No supported video formats found.\n");
1053 return -EINVAL; 1067 return -EINVAL;
1054 } 1068 }
1055 1069
1070 atomic_set(&stream->active, 0);
1071
1072 /* Initialize the video buffers queue. */
1073 uvc_queue_init(&stream->queue, stream->type);
1074
1056 /* Alternate setting 0 should be the default, yet the XBox Live Vision 1075 /* Alternate setting 0 should be the default, yet the XBox Live Vision
1057 * Cam (and possibly other devices) crash or otherwise misbehave if 1076 * Cam (and possibly other devices) crash or otherwise misbehave if
1058 * they don't receive a SET_INTERFACE request before any other video 1077 * they don't receive a SET_INTERFACE request before any other video
1059 * control request. 1078 * control request.
1060 */ 1079 */
1061 usb_set_interface(video->dev->udev, video->streaming->intfnum, 0); 1080 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1062 1081
1063 /* Set the streaming probe control with default streaming parameters 1082 /* Set the streaming probe control with default streaming parameters
1064 * retrieved from the device. Webcams that don't suport GET_DEF 1083 * retrieved from the device. Webcams that don't suport GET_DEF
1065 * requests on the probe control will just keep their current streaming 1084 * requests on the probe control will just keep their current streaming
1066 * parameters. 1085 * parameters.
1067 */ 1086 */
1068 if (uvc_get_video_ctrl(video, probe, 1, GET_DEF) == 0) 1087 if (uvc_get_video_ctrl(stream, probe, 1, UVC_GET_DEF) == 0)
1069 uvc_set_video_ctrl(video, probe, 1); 1088 uvc_set_video_ctrl(stream, probe, 1);
1070 1089
1071 /* Initialize the streaming parameters with the probe control current 1090 /* Initialize the streaming parameters with the probe control current
1072 * value. This makes sure SET_CUR requests on the streaming commit 1091 * value. This makes sure SET_CUR requests on the streaming commit
1073 * control will always use values retrieved from a successful GET_CUR 1092 * control will always use values retrieved from a successful GET_CUR
1074 * request on the probe control, as required by the UVC specification. 1093 * request on the probe control, as required by the UVC specification.
1075 */ 1094 */
1076 if ((ret = uvc_get_video_ctrl(video, probe, 1, GET_CUR)) < 0) 1095 ret = uvc_get_video_ctrl(stream, probe, 1, UVC_GET_CUR);
1096 if (ret < 0)
1077 return ret; 1097 return ret;
1078 1098
1079 /* Check if the default format descriptor exists. Use the first 1099 /* Check if the default format descriptor exists. Use the first
1080 * available format otherwise. 1100 * available format otherwise.
1081 */ 1101 */
1082 for (i = video->streaming->nformats; i > 0; --i) { 1102 for (i = stream->nformats; i > 0; --i) {
1083 format = &video->streaming->format[i-1]; 1103 format = &stream->format[i-1];
1084 if (format->index == probe->bFormatIndex) 1104 if (format->index == probe->bFormatIndex)
1085 break; 1105 break;
1086 } 1106 }
@@ -1105,21 +1125,20 @@ int uvc_video_init(struct uvc_video_device *video)
1105 probe->bFormatIndex = format->index; 1125 probe->bFormatIndex = format->index;
1106 probe->bFrameIndex = frame->bFrameIndex; 1126 probe->bFrameIndex = frame->bFrameIndex;
1107 1127
1108 video->streaming->cur_format = format; 1128 stream->cur_format = format;
1109 video->streaming->cur_frame = frame; 1129 stream->cur_frame = frame;
1110 atomic_set(&video->active, 0);
1111 1130
1112 /* Select the video decoding function */ 1131 /* Select the video decoding function */
1113 if (video->streaming->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1132 if (stream->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1114 if (video->dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT) 1133 if (stream->dev->quirks & UVC_QUIRK_BUILTIN_ISIGHT)
1115 video->decode = uvc_video_decode_isight; 1134 stream->decode = uvc_video_decode_isight;
1116 else if (video->streaming->intf->num_altsetting > 1) 1135 else if (stream->intf->num_altsetting > 1)
1117 video->decode = uvc_video_decode_isoc; 1136 stream->decode = uvc_video_decode_isoc;
1118 else 1137 else
1119 video->decode = uvc_video_decode_bulk; 1138 stream->decode = uvc_video_decode_bulk;
1120 } else { 1139 } else {
1121 if (video->streaming->intf->num_altsetting == 1) 1140 if (stream->intf->num_altsetting == 1)
1122 video->decode = uvc_video_encode_bulk; 1141 stream->decode = uvc_video_encode_bulk;
1123 else { 1142 else {
1124 uvc_printk(KERN_INFO, "Isochronous endpoints are not " 1143 uvc_printk(KERN_INFO, "Isochronous endpoints are not "
1125 "supported for video output devices.\n"); 1144 "supported for video output devices.\n");
@@ -1133,31 +1152,32 @@ int uvc_video_init(struct uvc_video_device *video)
1133/* 1152/*
1134 * Enable or disable the video stream. 1153 * Enable or disable the video stream.
1135 */ 1154 */
1136int uvc_video_enable(struct uvc_video_device *video, int enable) 1155int uvc_video_enable(struct uvc_streaming *stream, int enable)
1137{ 1156{
1138 int ret; 1157 int ret;
1139 1158
1140 if (!enable) { 1159 if (!enable) {
1141 uvc_uninit_video(video, 1); 1160 uvc_uninit_video(stream, 1);
1142 usb_set_interface(video->dev->udev, 1161 usb_set_interface(stream->dev->udev, stream->intfnum, 0);
1143 video->streaming->intfnum, 0); 1162 uvc_queue_enable(&stream->queue, 0);
1144 uvc_queue_enable(&video->queue, 0);
1145 return 0; 1163 return 0;
1146 } 1164 }
1147 1165
1148 if ((video->streaming->cur_format->flags & UVC_FMT_FLAG_COMPRESSED) || 1166 if ((stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED) ||
1149 uvc_no_drop_param) 1167 uvc_no_drop_param)
1150 video->queue.flags &= ~UVC_QUEUE_DROP_INCOMPLETE; 1168 stream->queue.flags &= ~UVC_QUEUE_DROP_INCOMPLETE;
1151 else 1169 else
1152 video->queue.flags |= UVC_QUEUE_DROP_INCOMPLETE; 1170 stream->queue.flags |= UVC_QUEUE_DROP_INCOMPLETE;
1153 1171
1154 if ((ret = uvc_queue_enable(&video->queue, 1)) < 0) 1172 ret = uvc_queue_enable(&stream->queue, 1);
1173 if (ret < 0)
1155 return ret; 1174 return ret;
1156 1175
1157 /* Commit the streaming parameters. */ 1176 /* Commit the streaming parameters. */
1158 if ((ret = uvc_commit_video(video, &video->streaming->ctrl)) < 0) 1177 ret = uvc_commit_video(stream, &stream->ctrl);
1178 if (ret < 0)
1159 return ret; 1179 return ret;
1160 1180
1161 return uvc_init_video(video, GFP_KERNEL); 1181 return uvc_init_video(stream, GFP_KERNEL);
1162} 1182}
1163 1183
diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
index 3c78d3c1e4c0..e7958aa454ce 100644
--- a/drivers/media/video/uvc/uvcvideo.h
+++ b/drivers/media/video/uvc/uvcvideo.h
@@ -67,155 +67,12 @@ struct uvc_xu_control {
67#ifdef __KERNEL__ 67#ifdef __KERNEL__
68 68
69#include <linux/poll.h> 69#include <linux/poll.h>
70#include <linux/usb/video.h>
70 71
71/* -------------------------------------------------------------------------- 72/* --------------------------------------------------------------------------
72 * UVC constants 73 * UVC constants
73 */ 74 */
74 75
75#define SC_UNDEFINED 0x00
76#define SC_VIDEOCONTROL 0x01
77#define SC_VIDEOSTREAMING 0x02
78#define SC_VIDEO_INTERFACE_COLLECTION 0x03
79
80#define PC_PROTOCOL_UNDEFINED 0x00
81
82#define CS_UNDEFINED 0x20
83#define CS_DEVICE 0x21
84#define CS_CONFIGURATION 0x22
85#define CS_STRING 0x23
86#define CS_INTERFACE 0x24
87#define CS_ENDPOINT 0x25
88
89/* VideoControl class specific interface descriptor */
90#define VC_DESCRIPTOR_UNDEFINED 0x00
91#define VC_HEADER 0x01
92#define VC_INPUT_TERMINAL 0x02
93#define VC_OUTPUT_TERMINAL 0x03
94#define VC_SELECTOR_UNIT 0x04
95#define VC_PROCESSING_UNIT 0x05
96#define VC_EXTENSION_UNIT 0x06
97
98/* VideoStreaming class specific interface descriptor */
99#define VS_UNDEFINED 0x00
100#define VS_INPUT_HEADER 0x01
101#define VS_OUTPUT_HEADER 0x02
102#define VS_STILL_IMAGE_FRAME 0x03
103#define VS_FORMAT_UNCOMPRESSED 0x04
104#define VS_FRAME_UNCOMPRESSED 0x05
105#define VS_FORMAT_MJPEG 0x06
106#define VS_FRAME_MJPEG 0x07
107#define VS_FORMAT_MPEG2TS 0x0a
108#define VS_FORMAT_DV 0x0c
109#define VS_COLORFORMAT 0x0d
110#define VS_FORMAT_FRAME_BASED 0x10
111#define VS_FRAME_FRAME_BASED 0x11
112#define VS_FORMAT_STREAM_BASED 0x12
113
114/* Endpoint type */
115#define EP_UNDEFINED 0x00
116#define EP_GENERAL 0x01
117#define EP_ENDPOINT 0x02
118#define EP_INTERRUPT 0x03
119
120/* Request codes */
121#define RC_UNDEFINED 0x00
122#define SET_CUR 0x01
123#define GET_CUR 0x81
124#define GET_MIN 0x82
125#define GET_MAX 0x83
126#define GET_RES 0x84
127#define GET_LEN 0x85
128#define GET_INFO 0x86
129#define GET_DEF 0x87
130
131/* VideoControl interface controls */
132#define VC_CONTROL_UNDEFINED 0x00
133#define VC_VIDEO_POWER_MODE_CONTROL 0x01
134#define VC_REQUEST_ERROR_CODE_CONTROL 0x02
135
136/* Terminal controls */
137#define TE_CONTROL_UNDEFINED 0x00
138
139/* Selector Unit controls */
140#define SU_CONTROL_UNDEFINED 0x00
141#define SU_INPUT_SELECT_CONTROL 0x01
142
143/* Camera Terminal controls */
144#define CT_CONTROL_UNDEFINED 0x00
145#define CT_SCANNING_MODE_CONTROL 0x01
146#define CT_AE_MODE_CONTROL 0x02
147#define CT_AE_PRIORITY_CONTROL 0x03
148#define CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
149#define CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
150#define CT_FOCUS_ABSOLUTE_CONTROL 0x06
151#define CT_FOCUS_RELATIVE_CONTROL 0x07
152#define CT_FOCUS_AUTO_CONTROL 0x08
153#define CT_IRIS_ABSOLUTE_CONTROL 0x09
154#define CT_IRIS_RELATIVE_CONTROL 0x0a
155#define CT_ZOOM_ABSOLUTE_CONTROL 0x0b
156#define CT_ZOOM_RELATIVE_CONTROL 0x0c
157#define CT_PANTILT_ABSOLUTE_CONTROL 0x0d
158#define CT_PANTILT_RELATIVE_CONTROL 0x0e
159#define CT_ROLL_ABSOLUTE_CONTROL 0x0f
160#define CT_ROLL_RELATIVE_CONTROL 0x10
161#define CT_PRIVACY_CONTROL 0x11
162
163/* Processing Unit controls */
164#define PU_CONTROL_UNDEFINED 0x00
165#define PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
166#define PU_BRIGHTNESS_CONTROL 0x02
167#define PU_CONTRAST_CONTROL 0x03
168#define PU_GAIN_CONTROL 0x04
169#define PU_POWER_LINE_FREQUENCY_CONTROL 0x05
170#define PU_HUE_CONTROL 0x06
171#define PU_SATURATION_CONTROL 0x07
172#define PU_SHARPNESS_CONTROL 0x08
173#define PU_GAMMA_CONTROL 0x09
174#define PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
175#define PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
176#define PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
177#define PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
178#define PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
179#define PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
180#define PU_HUE_AUTO_CONTROL 0x10
181#define PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
182#define PU_ANALOG_LOCK_STATUS_CONTROL 0x12
183
184#define LXU_MOTOR_PANTILT_RELATIVE_CONTROL 0x01
185#define LXU_MOTOR_PANTILT_RESET_CONTROL 0x02
186#define LXU_MOTOR_FOCUS_MOTOR_CONTROL 0x03
187
188/* VideoStreaming interface controls */
189#define VS_CONTROL_UNDEFINED 0x00
190#define VS_PROBE_CONTROL 0x01
191#define VS_COMMIT_CONTROL 0x02
192#define VS_STILL_PROBE_CONTROL 0x03
193#define VS_STILL_COMMIT_CONTROL 0x04
194#define VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
195#define VS_STREAM_ERROR_CODE_CONTROL 0x06
196#define VS_GENERATE_KEY_FRAME_CONTROL 0x07
197#define VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
198#define VS_SYNC_DELAY_CONTROL 0x09
199
200#define TT_VENDOR_SPECIFIC 0x0100
201#define TT_STREAMING 0x0101
202
203/* Input Terminal types */
204#define ITT_VENDOR_SPECIFIC 0x0200
205#define ITT_CAMERA 0x0201
206#define ITT_MEDIA_TRANSPORT_INPUT 0x0202
207
208/* Output Terminal types */
209#define OTT_VENDOR_SPECIFIC 0x0300
210#define OTT_DISPLAY 0x0301
211#define OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
212
213/* External Terminal types */
214#define EXTERNAL_VENDOR_SPECIFIC 0x0400
215#define COMPOSITE_CONNECTOR 0x0401
216#define SVIDEO_CONNECTOR 0x0402
217#define COMPONENT_CONNECTOR 0x0403
218
219#define UVC_TERM_INPUT 0x0000 76#define UVC_TERM_INPUT 0x0000
220#define UVC_TERM_OUTPUT 0x8000 77#define UVC_TERM_OUTPUT 0x8000
221 78
@@ -223,12 +80,12 @@ struct uvc_xu_control {
223#define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0) 80#define UVC_ENTITY_IS_UNIT(entity) (((entity)->type & 0xff00) == 0)
224#define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0) 81#define UVC_ENTITY_IS_TERM(entity) (((entity)->type & 0xff00) != 0)
225#define UVC_ENTITY_IS_ITERM(entity) \ 82#define UVC_ENTITY_IS_ITERM(entity) \
226 (((entity)->type & 0x8000) == UVC_TERM_INPUT) 83 (UVC_ENTITY_IS_TERM(entity) && \
84 ((entity)->type & 0x8000) == UVC_TERM_INPUT)
227#define UVC_ENTITY_IS_OTERM(entity) \ 85#define UVC_ENTITY_IS_OTERM(entity) \
228 (((entity)->type & 0x8000) == UVC_TERM_OUTPUT) 86 (UVC_ENTITY_IS_TERM(entity) && \
87 ((entity)->type & 0x8000) == UVC_TERM_OUTPUT)
229 88
230#define UVC_STATUS_TYPE_CONTROL 1
231#define UVC_STATUS_TYPE_STREAMING 2
232 89
233/* ------------------------------------------------------------------------ 90/* ------------------------------------------------------------------------
234 * GUIDs 91 * GUIDs
@@ -249,19 +106,6 @@ struct uvc_xu_control {
249 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 106 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02} 107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02}
251 108
252#define UVC_GUID_LOGITECH_DEV_INFO \
253 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
254 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1e}
255#define UVC_GUID_LOGITECH_USER_HW \
256 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
257 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x1f}
258#define UVC_GUID_LOGITECH_VIDEO \
259 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
260 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x50}
261#define UVC_GUID_LOGITECH_MOTOR \
262 {0x82, 0x06, 0x61, 0x63, 0x70, 0x50, 0xab, 0x49, \
263 0xb8, 0xcc, 0xb3, 0x85, 0x5e, 0x8d, 0x22, 0x56}
264
265#define UVC_GUID_FORMAT_MJPEG \ 109#define UVC_GUID_FORMAT_MJPEG \
266 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \ 110 { 'M', 'J', 'P', 'G', 0x00, 0x00, 0x10, 0x00, \
267 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 111 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}
@@ -314,6 +158,7 @@ struct uvc_xu_control {
314#define UVC_QUIRK_STREAM_NO_FID 0x00000010 158#define UVC_QUIRK_STREAM_NO_FID 0x00000010
315#define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020 159#define UVC_QUIRK_IGNORE_SELECTOR_UNIT 0x00000020
316#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 160#define UVC_QUIRK_FIX_BANDWIDTH 0x00000080
161#define UVC_QUIRK_PROBE_DEF 0x00000100
317 162
318/* Format flags */ 163/* Format flags */
319#define UVC_FMT_FLAG_COMPRESSED 0x00000001 164#define UVC_FMT_FLAG_COMPRESSED 0x00000001
@@ -518,26 +363,6 @@ struct uvc_streaming_header {
518 __u8 bTriggerUsage; 363 __u8 bTriggerUsage;
519}; 364};
520 365
521struct uvc_streaming {
522 struct list_head list;
523
524 struct usb_interface *intf;
525 int intfnum;
526 __u16 maxpsize;
527
528 struct uvc_streaming_header header;
529 enum v4l2_buf_type type;
530
531 unsigned int nformats;
532 struct uvc_format *format;
533
534 struct uvc_streaming_control ctrl;
535 struct uvc_format *cur_format;
536 struct uvc_frame *cur_frame;
537
538 struct mutex mutex;
539};
540
541enum uvc_buffer_state { 366enum uvc_buffer_state {
542 UVC_BUF_STATE_IDLE = 0, 367 UVC_BUF_STATE_IDLE = 0,
543 UVC_BUF_STATE_QUEUED = 1, 368 UVC_BUF_STATE_QUEUED = 1,
@@ -579,26 +404,45 @@ struct uvc_video_queue {
579 struct list_head irqqueue; 404 struct list_head irqqueue;
580}; 405};
581 406
582struct uvc_video_device { 407struct uvc_video_chain {
583 struct uvc_device *dev; 408 struct uvc_device *dev;
584 struct video_device *vdev; 409 struct list_head list;
585 atomic_t active;
586 unsigned int frozen : 1;
587 410
588 struct list_head iterms; /* Input terminals */ 411 struct list_head iterms; /* Input terminals */
589 struct uvc_entity *oterm; /* Output terminal */ 412 struct list_head oterms; /* Output terminals */
590 struct uvc_entity *sterm; /* USB streaming terminal */ 413 struct uvc_entity *processing; /* Processing unit */
591 struct uvc_entity *processing; 414 struct uvc_entity *selector; /* Selector unit */
592 struct uvc_entity *selector; 415 struct list_head extensions; /* Extension units */
593 struct list_head extensions; 416
594 struct mutex ctrl_mutex; 417 struct mutex ctrl_mutex;
418};
595 419
596 struct uvc_video_queue queue; 420struct uvc_streaming {
421 struct list_head list;
422 struct uvc_device *dev;
423 struct video_device *vdev;
424 struct uvc_video_chain *chain;
425 atomic_t active;
597 426
598 /* Video streaming object, must always be non-NULL. */ 427 struct usb_interface *intf;
599 struct uvc_streaming *streaming; 428 int intfnum;
429 __u16 maxpsize;
600 430
601 void (*decode) (struct urb *urb, struct uvc_video_device *video, 431 struct uvc_streaming_header header;
432 enum v4l2_buf_type type;
433
434 unsigned int nformats;
435 struct uvc_format *format;
436
437 struct uvc_streaming_control ctrl;
438 struct uvc_format *cur_format;
439 struct uvc_frame *cur_frame;
440
441 struct mutex mutex;
442
443 unsigned int frozen : 1;
444 struct uvc_video_queue queue;
445 void (*decode) (struct urb *urb, struct uvc_streaming *video,
602 struct uvc_buffer *buf); 446 struct uvc_buffer *buf);
603 447
604 /* Context data used by the bulk completion handler. */ 448 /* Context data used by the bulk completion handler. */
@@ -640,8 +484,10 @@ struct uvc_device {
640 __u32 clock_frequency; 484 __u32 clock_frequency;
641 485
642 struct list_head entities; 486 struct list_head entities;
487 struct list_head chains;
643 488
644 struct uvc_video_device video; 489 /* Video Streaming interfaces */
490 struct list_head streams;
645 491
646 /* Status Interrupt Endpoint */ 492 /* Status Interrupt Endpoint */
647 struct usb_host_endpoint *int_ep; 493 struct usb_host_endpoint *int_ep;
@@ -649,9 +495,6 @@ struct uvc_device {
649 __u8 *status; 495 __u8 *status;
650 struct input_dev *input; 496 struct input_dev *input;
651 char input_phys[64]; 497 char input_phys[64];
652
653 /* Video Streaming interfaces */
654 struct list_head streaming;
655}; 498};
656 499
657enum uvc_handle_state { 500enum uvc_handle_state {
@@ -660,7 +503,8 @@ enum uvc_handle_state {
660}; 503};
661 504
662struct uvc_fh { 505struct uvc_fh {
663 struct uvc_video_device *device; 506 struct uvc_video_chain *chain;
507 struct uvc_streaming *stream;
664 enum uvc_handle_state state; 508 enum uvc_handle_state state;
665}; 509};
666 510
@@ -757,13 +601,13 @@ static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
757extern const struct v4l2_file_operations uvc_fops; 601extern const struct v4l2_file_operations uvc_fops;
758 602
759/* Video */ 603/* Video */
760extern int uvc_video_init(struct uvc_video_device *video); 604extern int uvc_video_init(struct uvc_streaming *stream);
761extern int uvc_video_suspend(struct uvc_video_device *video); 605extern int uvc_video_suspend(struct uvc_streaming *stream);
762extern int uvc_video_resume(struct uvc_video_device *video); 606extern int uvc_video_resume(struct uvc_streaming *stream);
763extern int uvc_video_enable(struct uvc_video_device *video, int enable); 607extern int uvc_video_enable(struct uvc_streaming *stream, int enable);
764extern int uvc_probe_video(struct uvc_video_device *video, 608extern int uvc_probe_video(struct uvc_streaming *stream,
765 struct uvc_streaming_control *probe); 609 struct uvc_streaming_control *probe);
766extern int uvc_commit_video(struct uvc_video_device *video, 610extern int uvc_commit_video(struct uvc_streaming *stream,
767 struct uvc_streaming_control *ctrl); 611 struct uvc_streaming_control *ctrl);
768extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit, 612extern int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
769 __u8 intfnum, __u8 cs, void *data, __u16 size); 613 __u8 intfnum, __u8 cs, void *data, __u16 size);
@@ -777,9 +621,9 @@ extern int uvc_status_suspend(struct uvc_device *dev);
777extern int uvc_status_resume(struct uvc_device *dev); 621extern int uvc_status_resume(struct uvc_device *dev);
778 622
779/* Controls */ 623/* Controls */
780extern struct uvc_control *uvc_find_control(struct uvc_video_device *video, 624extern struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
781 __u32 v4l2_id, struct uvc_control_mapping **mapping); 625 __u32 v4l2_id, struct uvc_control_mapping **mapping);
782extern int uvc_query_v4l2_ctrl(struct uvc_video_device *video, 626extern int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
783 struct v4l2_queryctrl *v4l2_ctrl); 627 struct v4l2_queryctrl *v4l2_ctrl);
784 628
785extern int uvc_ctrl_add_info(struct uvc_control_info *info); 629extern int uvc_ctrl_add_info(struct uvc_control_info *info);
@@ -789,23 +633,23 @@ extern void uvc_ctrl_cleanup_device(struct uvc_device *dev);
789extern int uvc_ctrl_resume_device(struct uvc_device *dev); 633extern int uvc_ctrl_resume_device(struct uvc_device *dev);
790extern void uvc_ctrl_init(void); 634extern void uvc_ctrl_init(void);
791 635
792extern int uvc_ctrl_begin(struct uvc_video_device *video); 636extern int uvc_ctrl_begin(struct uvc_video_chain *chain);
793extern int __uvc_ctrl_commit(struct uvc_video_device *video, int rollback); 637extern int __uvc_ctrl_commit(struct uvc_video_chain *chain, int rollback);
794static inline int uvc_ctrl_commit(struct uvc_video_device *video) 638static inline int uvc_ctrl_commit(struct uvc_video_chain *chain)
795{ 639{
796 return __uvc_ctrl_commit(video, 0); 640 return __uvc_ctrl_commit(chain, 0);
797} 641}
798static inline int uvc_ctrl_rollback(struct uvc_video_device *video) 642static inline int uvc_ctrl_rollback(struct uvc_video_chain *chain)
799{ 643{
800 return __uvc_ctrl_commit(video, 1); 644 return __uvc_ctrl_commit(chain, 1);
801} 645}
802 646
803extern int uvc_ctrl_get(struct uvc_video_device *video, 647extern int uvc_ctrl_get(struct uvc_video_chain *chain,
804 struct v4l2_ext_control *xctrl); 648 struct v4l2_ext_control *xctrl);
805extern int uvc_ctrl_set(struct uvc_video_device *video, 649extern int uvc_ctrl_set(struct uvc_video_chain *chain,
806 struct v4l2_ext_control *xctrl); 650 struct v4l2_ext_control *xctrl);
807 651
808extern int uvc_xu_ctrl_query(struct uvc_video_device *video, 652extern int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
809 struct uvc_xu_control *ctrl, int set); 653 struct uvc_xu_control *ctrl, int set);
810 654
811/* Utility functions */ 655/* Utility functions */
@@ -817,7 +661,7 @@ extern struct usb_host_endpoint *uvc_find_endpoint(
817 struct usb_host_interface *alts, __u8 epaddr); 661 struct usb_host_interface *alts, __u8 epaddr);
818 662
819/* Quirks support */ 663/* Quirks support */
820void uvc_video_decode_isight(struct urb *urb, struct uvc_video_device *video, 664void uvc_video_decode_isight(struct urb *urb, struct uvc_streaming *stream,
821 struct uvc_buffer *buf); 665 struct uvc_buffer *buf);
822 666
823#endif /* __KERNEL__ */ 667#endif /* __KERNEL__ */
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index 02f2a6d18b45..761fbd64db58 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -76,9 +76,8 @@ get_v4l_control(struct file *file,
76 dprintk("VIDIOC_G_CTRL: %d\n", err); 76 dprintk("VIDIOC_G_CTRL: %d\n", err);
77 return 0; 77 return 0;
78 } 78 }
79 return ((ctrl2.value - qctrl2.minimum) * 65535 79 return DIV_ROUND_CLOSEST((ctrl2.value-qctrl2.minimum) * 65535,
80 + (qctrl2.maximum - qctrl2.minimum) / 2) 80 qctrl2.maximum - qctrl2.minimum);
81 / (qctrl2.maximum - qctrl2.minimum);
82 } 81 }
83 return 0; 82 return 0;
84} 83}
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index b91d66a767d7..3a0c64935b0e 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -156,6 +156,8 @@ int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl,
156 return -EINVAL; 156 return -EINVAL;
157 if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED) 157 if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED)
158 return -EBUSY; 158 return -EBUSY;
159 if (qctrl->type == V4L2_CTRL_TYPE_STRING)
160 return 0;
159 if (qctrl->type == V4L2_CTRL_TYPE_BUTTON || 161 if (qctrl->type == V4L2_CTRL_TYPE_BUTTON ||
160 qctrl->type == V4L2_CTRL_TYPE_INTEGER64 || 162 qctrl->type == V4L2_CTRL_TYPE_INTEGER64 ||
161 qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) 163 qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS)
@@ -340,6 +342,12 @@ const char **v4l2_ctrl_get_menu(u32 id)
340 "Sepia", 342 "Sepia",
341 NULL 343 NULL
342 }; 344 };
345 static const char *tune_preemphasis[] = {
346 "No preemphasis",
347 "50 useconds",
348 "75 useconds",
349 NULL,
350 };
343 351
344 switch (id) { 352 switch (id) {
345 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: 353 case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -378,6 +386,8 @@ const char **v4l2_ctrl_get_menu(u32 id)
378 return camera_exposure_auto; 386 return camera_exposure_auto;
379 case V4L2_CID_COLORFX: 387 case V4L2_CID_COLORFX:
380 return colorfx; 388 return colorfx;
389 case V4L2_CID_TUNE_PREEMPHASIS:
390 return tune_preemphasis;
381 default: 391 default:
382 return NULL; 392 return NULL;
383 } 393 }
@@ -476,6 +486,28 @@ const char *v4l2_ctrl_get_name(u32 id)
476 case V4L2_CID_ZOOM_CONTINUOUS: return "Zoom, Continuous"; 486 case V4L2_CID_ZOOM_CONTINUOUS: return "Zoom, Continuous";
477 case V4L2_CID_PRIVACY: return "Privacy"; 487 case V4L2_CID_PRIVACY: return "Privacy";
478 488
489 /* FM Radio Modulator control */
490 case V4L2_CID_FM_TX_CLASS: return "FM Radio Modulator Controls";
491 case V4L2_CID_RDS_TX_DEVIATION: return "RDS Signal Deviation";
492 case V4L2_CID_RDS_TX_PI: return "RDS Program ID";
493 case V4L2_CID_RDS_TX_PTY: return "RDS Program Type";
494 case V4L2_CID_RDS_TX_PS_NAME: return "RDS PS Name";
495 case V4L2_CID_RDS_TX_RADIO_TEXT: return "RDS Radio Text";
496 case V4L2_CID_AUDIO_LIMITER_ENABLED: return "Audio Limiter Feature Enabled";
497 case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME: return "Audio Limiter Release Time";
498 case V4L2_CID_AUDIO_LIMITER_DEVIATION: return "Audio Limiter Deviation";
499 case V4L2_CID_AUDIO_COMPRESSION_ENABLED: return "Audio Compression Feature Enabled";
500 case V4L2_CID_AUDIO_COMPRESSION_GAIN: return "Audio Compression Gain";
501 case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD: return "Audio Compression Threshold";
502 case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME: return "Audio Compression Attack Time";
503 case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME: return "Audio Compression Release Time";
504 case V4L2_CID_PILOT_TONE_ENABLED: return "Pilot Tone Feature Enabled";
505 case V4L2_CID_PILOT_TONE_DEVIATION: return "Pilot Tone Deviation";
506 case V4L2_CID_PILOT_TONE_FREQUENCY: return "Pilot Tone Frequency";
507 case V4L2_CID_TUNE_PREEMPHASIS: return "Pre-emphasis settings";
508 case V4L2_CID_TUNE_POWER_LEVEL: return "Tune Power Level";
509 case V4L2_CID_TUNE_ANTENNA_CAPACITOR: return "Tune Antenna Capacitor";
510
479 default: 511 default:
480 return NULL; 512 return NULL;
481 } 513 }
@@ -508,6 +540,9 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
508 case V4L2_CID_EXPOSURE_AUTO_PRIORITY: 540 case V4L2_CID_EXPOSURE_AUTO_PRIORITY:
509 case V4L2_CID_FOCUS_AUTO: 541 case V4L2_CID_FOCUS_AUTO:
510 case V4L2_CID_PRIVACY: 542 case V4L2_CID_PRIVACY:
543 case V4L2_CID_AUDIO_LIMITER_ENABLED:
544 case V4L2_CID_AUDIO_COMPRESSION_ENABLED:
545 case V4L2_CID_PILOT_TONE_ENABLED:
511 qctrl->type = V4L2_CTRL_TYPE_BOOLEAN; 546 qctrl->type = V4L2_CTRL_TYPE_BOOLEAN;
512 min = 0; 547 min = 0;
513 max = step = 1; 548 max = step = 1;
@@ -536,12 +571,18 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
536 case V4L2_CID_MPEG_STREAM_VBI_FMT: 571 case V4L2_CID_MPEG_STREAM_VBI_FMT:
537 case V4L2_CID_EXPOSURE_AUTO: 572 case V4L2_CID_EXPOSURE_AUTO:
538 case V4L2_CID_COLORFX: 573 case V4L2_CID_COLORFX:
574 case V4L2_CID_TUNE_PREEMPHASIS:
539 qctrl->type = V4L2_CTRL_TYPE_MENU; 575 qctrl->type = V4L2_CTRL_TYPE_MENU;
540 step = 1; 576 step = 1;
541 break; 577 break;
578 case V4L2_CID_RDS_TX_PS_NAME:
579 case V4L2_CID_RDS_TX_RADIO_TEXT:
580 qctrl->type = V4L2_CTRL_TYPE_STRING;
581 break;
542 case V4L2_CID_USER_CLASS: 582 case V4L2_CID_USER_CLASS:
543 case V4L2_CID_CAMERA_CLASS: 583 case V4L2_CID_CAMERA_CLASS:
544 case V4L2_CID_MPEG_CLASS: 584 case V4L2_CID_MPEG_CLASS:
585 case V4L2_CID_FM_TX_CLASS:
545 qctrl->type = V4L2_CTRL_TYPE_CTRL_CLASS; 586 qctrl->type = V4L2_CTRL_TYPE_CTRL_CLASS;
546 qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; 587 qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
547 min = max = step = def = 0; 588 min = max = step = def = 0;
@@ -570,6 +611,17 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 ste
570 case V4L2_CID_BLUE_BALANCE: 611 case V4L2_CID_BLUE_BALANCE:
571 case V4L2_CID_GAMMA: 612 case V4L2_CID_GAMMA:
572 case V4L2_CID_SHARPNESS: 613 case V4L2_CID_SHARPNESS:
614 case V4L2_CID_RDS_TX_DEVIATION:
615 case V4L2_CID_AUDIO_LIMITER_RELEASE_TIME:
616 case V4L2_CID_AUDIO_LIMITER_DEVIATION:
617 case V4L2_CID_AUDIO_COMPRESSION_GAIN:
618 case V4L2_CID_AUDIO_COMPRESSION_THRESHOLD:
619 case V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME:
620 case V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME:
621 case V4L2_CID_PILOT_TONE_DEVIATION:
622 case V4L2_CID_PILOT_TONE_FREQUENCY:
623 case V4L2_CID_TUNE_POWER_LEVEL:
624 case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
573 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 625 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
574 break; 626 break;
575 case V4L2_CID_PAN_RELATIVE: 627 case V4L2_CID_PAN_RELATIVE:
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c
index 0056b115b42e..997975d5e024 100644
--- a/drivers/media/video/v4l2-compat-ioctl32.c
+++ b/drivers/media/video/v4l2-compat-ioctl32.c
@@ -600,9 +600,37 @@ struct v4l2_ext_controls32 {
600 compat_caddr_t controls; /* actually struct v4l2_ext_control32 * */ 600 compat_caddr_t controls; /* actually struct v4l2_ext_control32 * */
601}; 601};
602 602
603struct v4l2_ext_control32 {
604 __u32 id;
605 __u32 size;
606 __u32 reserved2[1];
607 union {
608 __s32 value;
609 __s64 value64;
610 compat_caddr_t string; /* actually char * */
611 };
612} __attribute__ ((packed));
613
614/* The following function really belong in v4l2-common, but that causes
615 a circular dependency between modules. We need to think about this, but
616 for now this will do. */
617
618/* Return non-zero if this control is a pointer type. Currently only
619 type STRING is a pointer type. */
620static inline int ctrl_is_pointer(u32 id)
621{
622 switch (id) {
623 case V4L2_CID_RDS_TX_PS_NAME:
624 case V4L2_CID_RDS_TX_RADIO_TEXT:
625 return 1;
626 default:
627 return 0;
628 }
629}
630
603static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up) 631static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up)
604{ 632{
605 struct v4l2_ext_control __user *ucontrols; 633 struct v4l2_ext_control32 __user *ucontrols;
606 struct v4l2_ext_control __user *kcontrols; 634 struct v4l2_ext_control __user *kcontrols;
607 int n; 635 int n;
608 compat_caddr_t p; 636 compat_caddr_t p;
@@ -626,15 +654,17 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
626 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control)); 654 kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
627 kp->controls = kcontrols; 655 kp->controls = kcontrols;
628 while (--n >= 0) { 656 while (--n >= 0) {
629 if (copy_in_user(&kcontrols->id, &ucontrols->id, sizeof(__u32))) 657 if (copy_in_user(kcontrols, ucontrols, sizeof(*kcontrols)))
630 return -EFAULT;
631 if (copy_in_user(&kcontrols->reserved2, &ucontrols->reserved2, sizeof(ucontrols->reserved2)))
632 return -EFAULT;
633 /* Note: if the void * part of the union ever becomes relevant
634 then we need to know the type of the control in order to do
635 the right thing here. Luckily, that is not yet an issue. */
636 if (copy_in_user(&kcontrols->value, &ucontrols->value, sizeof(ucontrols->value)))
637 return -EFAULT; 658 return -EFAULT;
659 if (ctrl_is_pointer(kcontrols->id)) {
660 void __user *s;
661
662 if (get_user(p, &ucontrols->string))
663 return -EFAULT;
664 s = compat_ptr(p);
665 if (put_user(s, &kcontrols->string))
666 return -EFAULT;
667 }
638 ucontrols++; 668 ucontrols++;
639 kcontrols++; 669 kcontrols++;
640 } 670 }
@@ -643,7 +673,7 @@ static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
643 673
644static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up) 674static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up)
645{ 675{
646 struct v4l2_ext_control __user *ucontrols; 676 struct v4l2_ext_control32 __user *ucontrols;
647 struct v4l2_ext_control __user *kcontrols = kp->controls; 677 struct v4l2_ext_control __user *kcontrols = kp->controls;
648 int n = kp->count; 678 int n = kp->count;
649 compat_caddr_t p; 679 compat_caddr_t p;
@@ -664,15 +694,14 @@ static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext
664 return -EFAULT; 694 return -EFAULT;
665 695
666 while (--n >= 0) { 696 while (--n >= 0) {
667 if (copy_in_user(&ucontrols->id, &kcontrols->id, sizeof(__u32))) 697 unsigned size = sizeof(*ucontrols);
668 return -EFAULT; 698
669 if (copy_in_user(&ucontrols->reserved2, &kcontrols->reserved2, 699 /* Do not modify the pointer when copying a pointer control.
670 sizeof(ucontrols->reserved2))) 700 The contents of the pointer was changed, not the pointer
671 return -EFAULT; 701 itself. */
672 /* Note: if the void * part of the union ever becomes relevant 702 if (ctrl_is_pointer(kcontrols->id))
673 then we need to know the type of the control in order to do 703 size -= sizeof(ucontrols->value64);
674 the right thing here. Luckily, that is not yet an issue. */ 704 if (copy_in_user(ucontrols, kcontrols, size))
675 if (copy_in_user(&ucontrols->value, &kcontrols->value, sizeof(ucontrols->value)))
676 return -EFAULT; 705 return -EFAULT;
677 ucontrols++; 706 ucontrols++;
678 kcontrols++; 707 kcontrols++;
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index f2afc4e08379..30cc3347ae52 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -42,6 +42,12 @@
42 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\ 42 printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\
43 } while (0) 43 } while (0)
44 44
45#define dbgarg3(fmt, arg...) \
46 do { \
47 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
48 printk(KERN_CONT "%s: " fmt, vfd->name, ## arg);\
49 } while (0)
50
45/* Zero out the end of the struct pointed to by p. Everthing after, but 51/* Zero out the end of the struct pointed to by p. Everthing after, but
46 * not including, the specified field is cleared. */ 52 * not including, the specified field is cleared. */
47#define CLEAR_AFTER_FIELD(p, field) \ 53#define CLEAR_AFTER_FIELD(p, field) \
@@ -507,11 +513,12 @@ static inline void v4l_print_ext_ctrls(unsigned int cmd,
507 dbgarg(cmd, ""); 513 dbgarg(cmd, "");
508 printk(KERN_CONT "class=0x%x", c->ctrl_class); 514 printk(KERN_CONT "class=0x%x", c->ctrl_class);
509 for (i = 0; i < c->count; i++) { 515 for (i = 0; i < c->count; i++) {
510 if (show_vals) 516 if (show_vals && !c->controls[i].size)
511 printk(KERN_CONT " id/val=0x%x/0x%x", 517 printk(KERN_CONT " id/val=0x%x/0x%x",
512 c->controls[i].id, c->controls[i].value); 518 c->controls[i].id, c->controls[i].value);
513 else 519 else
514 printk(KERN_CONT " id=0x%x", c->controls[i].id); 520 printk(KERN_CONT " id=0x%x,size=%u",
521 c->controls[i].id, c->controls[i].size);
515 } 522 }
516 printk(KERN_CONT "\n"); 523 printk(KERN_CONT "\n");
517}; 524};
@@ -522,10 +529,9 @@ static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv)
522 529
523 /* zero the reserved fields */ 530 /* zero the reserved fields */
524 c->reserved[0] = c->reserved[1] = 0; 531 c->reserved[0] = c->reserved[1] = 0;
525 for (i = 0; i < c->count; i++) { 532 for (i = 0; i < c->count; i++)
526 c->controls[i].reserved2[0] = 0; 533 c->controls[i].reserved2[0] = 0;
527 c->controls[i].reserved2[1] = 0; 534
528 }
529 /* V4L2_CID_PRIVATE_BASE cannot be used as control class 535 /* V4L2_CID_PRIVATE_BASE cannot be used as control class
530 when using extended controls. 536 when using extended controls.
531 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL 537 Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL
@@ -1726,24 +1732,29 @@ static long __video_do_ioctl(struct file *file,
1726 1732
1727 ret = ops->vidioc_enum_framesizes(file, fh, p); 1733 ret = ops->vidioc_enum_framesizes(file, fh, p);
1728 dbgarg(cmd, 1734 dbgarg(cmd,
1729 "index=%d, pixelformat=%d, type=%d ", 1735 "index=%d, pixelformat=%c%c%c%c, type=%d ",
1730 p->index, p->pixel_format, p->type); 1736 p->index,
1737 (p->pixel_format & 0xff),
1738 (p->pixel_format >> 8) & 0xff,
1739 (p->pixel_format >> 16) & 0xff,
1740 (p->pixel_format >> 24) & 0xff,
1741 p->type);
1731 switch (p->type) { 1742 switch (p->type) {
1732 case V4L2_FRMSIZE_TYPE_DISCRETE: 1743 case V4L2_FRMSIZE_TYPE_DISCRETE:
1733 dbgarg2("width = %d, height=%d\n", 1744 dbgarg3("width = %d, height=%d\n",
1734 p->discrete.width, p->discrete.height); 1745 p->discrete.width, p->discrete.height);
1735 break; 1746 break;
1736 case V4L2_FRMSIZE_TYPE_STEPWISE: 1747 case V4L2_FRMSIZE_TYPE_STEPWISE:
1737 dbgarg2("min %dx%d, max %dx%d, step %dx%d\n", 1748 dbgarg3("min %dx%d, max %dx%d, step %dx%d\n",
1738 p->stepwise.min_width, p->stepwise.min_height, 1749 p->stepwise.min_width, p->stepwise.min_height,
1739 p->stepwise.step_width, p->stepwise.step_height, 1750 p->stepwise.step_width, p->stepwise.step_height,
1740 p->stepwise.max_width, p->stepwise.max_height); 1751 p->stepwise.max_width, p->stepwise.max_height);
1741 break; 1752 break;
1742 case V4L2_FRMSIZE_TYPE_CONTINUOUS: 1753 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
1743 dbgarg2("continuous\n"); 1754 dbgarg3("continuous\n");
1744 break; 1755 break;
1745 default: 1756 default:
1746 dbgarg2("- Unknown type!\n"); 1757 dbgarg3("- Unknown type!\n");
1747 } 1758 }
1748 1759
1749 break; 1760 break;
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 97b082fe4473..f3b6e15d91f2 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -1776,7 +1776,6 @@ static struct i2c_algo_sgi_data i2c_sgi_vino_data = {
1776 1776
1777static struct i2c_adapter vino_i2c_adapter = { 1777static struct i2c_adapter vino_i2c_adapter = {
1778 .name = "VINO I2C bus", 1778 .name = "VINO I2C bus",
1779 .id = I2C_HW_SGI_VINO,
1780 .algo = &sgi_algo, 1779 .algo = &sgi_algo,
1781 .algo_data = &i2c_sgi_vino_data, 1780 .algo_data = &i2c_sgi_vino_data,
1782 .owner = THIS_MODULE, 1781 .owner = THIS_MODULE,
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 6c3f23e31b5c..602484dd3da9 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -1497,7 +1497,6 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam)
1497 }; 1497 };
1498 1498
1499 static struct i2c_adapter adap = { 1499 static struct i2c_adapter adap = {
1500 .id = I2C_HW_SMBUS_W9968CF,
1501 .owner = THIS_MODULE, 1500 .owner = THIS_MODULE,
1502 .algo = &algo, 1501 .algo = &algo,
1503 }; 1502 };
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index 03dc2f3cf84a..0c4d9b1f8e6f 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -732,7 +732,6 @@ zoran_register_i2c (struct zoran *zr)
732 memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template, 732 memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template,
733 sizeof(struct i2c_algo_bit_data)); 733 sizeof(struct i2c_algo_bit_data));
734 zr->i2c_algo.data = zr; 734 zr->i2c_algo.data = zr;
735 zr->i2c_adapter.id = I2C_HW_B_ZR36067;
736 strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr), 735 strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr),
737 sizeof(zr->i2c_adapter.name)); 736 sizeof(zr->i2c_adapter.name));
738 i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev); 737 i2c_set_adapdata(&zr->i2c_adapter, &zr->v4l2_dev);
@@ -1169,7 +1168,7 @@ zoran_setup_videocodec (struct zoran *zr,
1169 m->type = 0; 1168 m->type = 0;
1170 1169
1171 m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER; 1170 m->flags = CODEC_FLAG_ENCODER | CODEC_FLAG_DECODER;
1172 strncpy(m->name, ZR_DEVNAME(zr), sizeof(m->name)); 1171 strlcpy(m->name, ZR_DEVNAME(zr), sizeof(m->name));
1173 m->data = zr; 1172 m->data = zr;
1174 1173
1175 switch (type) 1174 switch (type)
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index 2622a6e63da1..9aae011d92ab 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Zoran 364xx based USB webcam module version 0.72 2 * Zoran 364xx based USB webcam module version 0.73
3 * 3 *
4 * Allows you to use your USB webcam with V4L2 applications 4 * Allows you to use your USB webcam with V4L2 applications
5 * This is still in heavy developpement ! 5 * This is still in heavy developpement !
@@ -10,6 +10,8 @@
10 * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c drivers 10 * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c drivers
11 * V4L2 version inspired by meye.c driver 11 * V4L2 version inspired by meye.c driver
12 * 12 *
13 * Some video buffer code by Lamarque based on s2255drv.c and vivi.c drivers.
14 *
13 * This program is free software; you can redistribute it and/or modify 15 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 16 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or 17 * the Free Software Foundation; either version 2 of the License, or
@@ -27,6 +29,7 @@
27 29
28 30
29#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/version.h>
30#include <linux/init.h> 33#include <linux/init.h>
31#include <linux/usb.h> 34#include <linux/usb.h>
32#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
@@ -35,24 +38,40 @@
35#include <linux/highmem.h> 38#include <linux/highmem.h>
36#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h> 40#include <media/v4l2-ioctl.h>
41#include <media/videobuf-vmalloc.h>
38 42
39 43
40/* Version Information */ 44/* Version Information */
41#define DRIVER_VERSION "v0.72" 45#define DRIVER_VERSION "v0.73"
46#define ZR364XX_VERSION_CODE KERNEL_VERSION(0, 7, 3)
42#define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/" 47#define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/"
43#define DRIVER_DESC "Zoran 364xx" 48#define DRIVER_DESC "Zoran 364xx"
44 49
45 50
46/* Camera */ 51/* Camera */
47#define FRAMES 2 52#define FRAMES 1
48#define MAX_FRAME_SIZE 100000 53#define MAX_FRAME_SIZE 200000
49#define BUFFER_SIZE 0x1000 54#define BUFFER_SIZE 0x1000
50#define CTRL_TIMEOUT 500 55#define CTRL_TIMEOUT 500
51 56
57#define ZR364XX_DEF_BUFS 4
58#define ZR364XX_READ_IDLE 0
59#define ZR364XX_READ_FRAME 1
52 60
53/* Debug macro */ 61/* Debug macro */
54#define DBG(x...) if (debug) printk(KERN_INFO KBUILD_MODNAME x) 62#define DBG(fmt, args...) \
55 63 do { \
64 if (debug) { \
65 printk(KERN_INFO KBUILD_MODNAME " " fmt, ##args); \
66 } \
67 } while (0)
68
69/*#define FULL_DEBUG 1*/
70#ifdef FULL_DEBUG
71#define _DBG DBG
72#else
73#define _DBG(fmt, args...)
74#endif
56 75
57/* Init methods, need to find nicer names for these 76/* Init methods, need to find nicer names for these
58 * the exact names of the chipsets would be the best if someone finds it */ 77 * the exact names of the chipsets would be the best if someone finds it */
@@ -101,24 +120,93 @@ static struct usb_device_id device_table[] = {
101 120
102MODULE_DEVICE_TABLE(usb, device_table); 121MODULE_DEVICE_TABLE(usb, device_table);
103 122
123struct zr364xx_mode {
124 u32 color; /* output video color format */
125 u32 brightness; /* brightness */
126};
127
128/* frame structure */
129struct zr364xx_framei {
130 unsigned long ulState; /* ulState:ZR364XX_READ_IDLE,
131 ZR364XX_READ_FRAME */
132 void *lpvbits; /* image data */
133 unsigned long cur_size; /* current data copied to it */
134};
135
136/* image buffer structure */
137struct zr364xx_bufferi {
138 unsigned long dwFrames; /* number of frames in buffer */
139 struct zr364xx_framei frame[FRAMES]; /* array of FRAME structures */
140};
141
142struct zr364xx_dmaqueue {
143 struct list_head active;
144 struct zr364xx_camera *cam;
145};
146
147struct zr364xx_pipeinfo {
148 u32 transfer_size;
149 u8 *transfer_buffer;
150 u32 state;
151 void *stream_urb;
152 void *cam; /* back pointer to zr364xx_camera struct */
153 u32 err_count;
154 u32 idx;
155};
156
157struct zr364xx_fmt {
158 char *name;
159 u32 fourcc;
160 int depth;
161};
162
163/* image formats. */
164static const struct zr364xx_fmt formats[] = {
165 {
166 .name = "JPG",
167 .fourcc = V4L2_PIX_FMT_JPEG,
168 .depth = 24
169 }
170};
104 171
105/* Camera stuff */ 172/* Camera stuff */
106struct zr364xx_camera { 173struct zr364xx_camera {
107 struct usb_device *udev; /* save off the usb device pointer */ 174 struct usb_device *udev; /* save off the usb device pointer */
108 struct usb_interface *interface;/* the interface for this device */ 175 struct usb_interface *interface;/* the interface for this device */
109 struct video_device *vdev; /* v4l video device */ 176 struct video_device *vdev; /* v4l video device */
110 u8 *framebuf;
111 int nb; 177 int nb;
112 unsigned char *buffer; 178 struct zr364xx_bufferi buffer;
113 int skip; 179 int skip;
114 int brightness;
115 int width; 180 int width;
116 int height; 181 int height;
117 int method; 182 int method;
118 struct mutex lock; 183 struct mutex lock;
184 struct mutex open_lock;
119 int users; 185 int users;
186
187 spinlock_t slock;
188 struct zr364xx_dmaqueue vidq;
189 int resources;
190 int last_frame;
191 int cur_frame;
192 unsigned long frame_count;
193 int b_acquire;
194 struct zr364xx_pipeinfo pipe[1];
195
196 u8 read_endpoint;
197
198 const struct zr364xx_fmt *fmt;
199 struct videobuf_queue vb_vidq;
200 enum v4l2_buf_type type;
201 struct zr364xx_mode mode;
120}; 202};
121 203
204/* buffer for one video frame */
205struct zr364xx_buffer {
206 /* common v4l buffer stuff -- must be first */
207 struct videobuf_buffer vb;
208 const struct zr364xx_fmt *fmt;
209};
122 210
123/* function used to send initialisation commands to the camera */ 211/* function used to send initialisation commands to the camera */
124static int send_control_msg(struct usb_device *udev, u8 request, u16 value, 212static int send_control_msg(struct usb_device *udev, u8 request, u16 value,
@@ -272,139 +360,116 @@ static unsigned char header2[] = {
272}; 360};
273static unsigned char header3; 361static unsigned char header3;
274 362
363/* ------------------------------------------------------------------
364 Videobuf operations
365 ------------------------------------------------------------------*/
275 366
367static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
368 unsigned int *size)
369{
370 struct zr364xx_camera *cam = vq->priv_data;
276 371
277/********************/ 372 *size = cam->width * cam->height * (cam->fmt->depth >> 3);
278/* V4L2 integration */
279/********************/
280 373
281/* this function reads a full JPEG picture synchronously 374 if (*count == 0)
282 * TODO: do it asynchronously... */ 375 *count = ZR364XX_DEF_BUFS;
283static int read_frame(struct zr364xx_camera *cam, int framenum)
284{
285 int i, n, temp, head, size, actual_length;
286 unsigned char *ptr = NULL, *jpeg;
287
288 redo:
289 /* hardware brightness */
290 n = send_control_msg(cam->udev, 1, 0x2001, 0, NULL, 0);
291 temp = (0x60 << 8) + 127 - cam->brightness;
292 n = send_control_msg(cam->udev, 1, temp, 0, NULL, 0);
293
294 /* during the first loop we are going to insert JPEG header */
295 head = 0;
296 /* this is the place in memory where we are going to build
297 * the JPEG image */
298 jpeg = cam->framebuf + framenum * MAX_FRAME_SIZE;
299 /* read data... */
300 do {
301 n = usb_bulk_msg(cam->udev,
302 usb_rcvbulkpipe(cam->udev, 0x81),
303 cam->buffer, BUFFER_SIZE, &actual_length,
304 CTRL_TIMEOUT);
305 DBG("buffer : %d %d", cam->buffer[0], cam->buffer[1]);
306 DBG("bulk : n=%d size=%d", n, actual_length);
307 if (n < 0) {
308 dev_err(&cam->udev->dev, "error reading bulk msg\n");
309 return 0;
310 }
311 if (actual_length < 0 || actual_length > BUFFER_SIZE) {
312 dev_err(&cam->udev->dev, "wrong number of bytes\n");
313 return 0;
314 }
315 376
316 /* swap bytes if camera needs it */ 377 while (*size * (*count) > ZR364XX_DEF_BUFS * 1024 * 1024)
317 if (cam->method == METHOD0) { 378 (*count)--;
318 u16 *buf = (u16*)cam->buffer;
319 for (i = 0; i < BUFFER_SIZE/2; i++)
320 swab16s(buf + i);
321 }
322 379
323 /* write the JPEG header */ 380 return 0;
324 if (!head) { 381}
325 DBG("jpeg header");
326 ptr = jpeg;
327 memcpy(ptr, header1, sizeof(header1));
328 ptr += sizeof(header1);
329 header3 = 0;
330 memcpy(ptr, &header3, 1);
331 ptr++;
332 memcpy(ptr, cam->buffer, 64);
333 ptr += 64;
334 header3 = 1;
335 memcpy(ptr, &header3, 1);
336 ptr++;
337 memcpy(ptr, cam->buffer + 64, 64);
338 ptr += 64;
339 memcpy(ptr, header2, sizeof(header2));
340 ptr += sizeof(header2);
341 memcpy(ptr, cam->buffer + 128,
342 actual_length - 128);
343 ptr += actual_length - 128;
344 head = 1;
345 DBG("header : %d %d %d %d %d %d %d %d %d",
346 cam->buffer[0], cam->buffer[1], cam->buffer[2],
347 cam->buffer[3], cam->buffer[4], cam->buffer[5],
348 cam->buffer[6], cam->buffer[7], cam->buffer[8]);
349 } else {
350 memcpy(ptr, cam->buffer, actual_length);
351 ptr += actual_length;
352 }
353 }
354 /* ... until there is no more */
355 while (actual_length == BUFFER_SIZE);
356 382
357 /* we skip the 2 first frames which are usually buggy */ 383static void free_buffer(struct videobuf_queue *vq, struct zr364xx_buffer *buf)
358 if (cam->skip) { 384{
359 cam->skip--; 385 _DBG("%s\n", __func__);
360 goto redo;
361 }
362 386
363 /* go back to find the JPEG EOI marker */ 387 if (in_interrupt())
364 size = ptr - jpeg; 388 BUG();
365 ptr -= 2;
366 while (ptr > jpeg) {
367 if (*ptr == 0xFF && *(ptr + 1) == 0xD9
368 && *(ptr + 2) == 0xFF)
369 break;
370 ptr--;
371 }
372 if (ptr == jpeg)
373 DBG("No EOI marker");
374 389
375 /* Sometimes there is junk data in the middle of the picture, 390 videobuf_vmalloc_free(&buf->vb);
376 * we want to skip this bogus frames */ 391 buf->vb.state = VIDEOBUF_NEEDS_INIT;
377 while (ptr > jpeg) { 392}
378 if (*ptr == 0xFF && *(ptr + 1) == 0xFF 393
379 && *(ptr + 2) == 0xFF) 394static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
380 break; 395 enum v4l2_field field)
381 ptr--; 396{
397 struct zr364xx_camera *cam = vq->priv_data;
398 struct zr364xx_buffer *buf = container_of(vb, struct zr364xx_buffer,
399 vb);
400 int rc;
401
402 DBG("%s, field=%d, fmt name = %s\n", __func__, field, cam->fmt != NULL ?
403 cam->fmt->name : "");
404 if (cam->fmt == NULL)
405 return -EINVAL;
406
407 buf->vb.size = cam->width * cam->height * (cam->fmt->depth >> 3);
408
409 if (buf->vb.baddr != 0 && buf->vb.bsize < buf->vb.size) {
410 DBG("invalid buffer prepare\n");
411 return -EINVAL;
382 } 412 }
383 if (ptr != jpeg) { 413
384 DBG("Bogus frame ? %d", cam->nb); 414 buf->fmt = cam->fmt;
385 goto redo; 415 buf->vb.width = cam->width;
416 buf->vb.height = cam->height;
417 buf->vb.field = field;
418
419 if (buf->vb.state == VIDEOBUF_NEEDS_INIT) {
420 rc = videobuf_iolock(vq, &buf->vb, NULL);
421 if (rc < 0)
422 goto fail;
386 } 423 }
387 424
388 DBG("jpeg : %d %d %d %d %d %d %d %d", 425 buf->vb.state = VIDEOBUF_PREPARED;
389 jpeg[0], jpeg[1], jpeg[2], jpeg[3], 426 return 0;
390 jpeg[4], jpeg[5], jpeg[6], jpeg[7]); 427fail:
428 free_buffer(vq, buf);
429 return rc;
430}
431
432static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
433{
434 struct zr364xx_buffer *buf = container_of(vb, struct zr364xx_buffer,
435 vb);
436 struct zr364xx_camera *cam = vq->priv_data;
437
438 _DBG("%s\n", __func__);
439
440 buf->vb.state = VIDEOBUF_QUEUED;
441 list_add_tail(&buf->vb.queue, &cam->vidq.active);
442}
443
444static void buffer_release(struct videobuf_queue *vq,
445 struct videobuf_buffer *vb)
446{
447 struct zr364xx_buffer *buf = container_of(vb, struct zr364xx_buffer,
448 vb);
391 449
392 return size; 450 _DBG("%s\n", __func__);
451 free_buffer(vq, buf);
393} 452}
394 453
454static struct videobuf_queue_ops zr364xx_video_qops = {
455 .buf_setup = buffer_setup,
456 .buf_prepare = buffer_prepare,
457 .buf_queue = buffer_queue,
458 .buf_release = buffer_release,
459};
460
461/********************/
462/* V4L2 integration */
463/********************/
464static int zr364xx_vidioc_streamon(struct file *file, void *priv,
465 enum v4l2_buf_type type);
395 466
396static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t cnt, 467static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t count,
397 loff_t * ppos) 468 loff_t * ppos)
398{ 469{
399 unsigned long count = cnt; 470 struct zr364xx_camera *cam = video_drvdata(file);
400 struct video_device *vdev = video_devdata(file);
401 struct zr364xx_camera *cam;
402 471
403 DBG("zr364xx_read: read %d bytes.", (int) count); 472 _DBG("%s\n", __func__);
404
405 if (vdev == NULL)
406 return -ENODEV;
407 cam = video_get_drvdata(vdev);
408 473
409 if (!buf) 474 if (!buf)
410 return -EINVAL; 475 return -EINVAL;
@@ -412,21 +477,276 @@ static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t cnt,
412 if (!count) 477 if (!count)
413 return -EINVAL; 478 return -EINVAL;
414 479
415 /* NoMan Sux ! */ 480 if (cam->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
416 count = read_frame(cam, 0); 481 zr364xx_vidioc_streamon(file, cam, cam->type) == 0) {
482 DBG("%s: reading %d bytes at pos %d.\n", __func__, (int) count,
483 (int) *ppos);
484
485 /* NoMan Sux ! */
486 return videobuf_read_one(&cam->vb_vidq, buf, count, ppos,
487 file->f_flags & O_NONBLOCK);
488 }
489
490 return 0;
491}
492
493/* video buffer vmalloc implementation based partly on VIVI driver which is
494 * Copyright (c) 2006 by
495 * Mauro Carvalho Chehab <mchehab--a.t--infradead.org>
496 * Ted Walther <ted--a.t--enumera.com>
497 * John Sokol <sokol--a.t--videotechnology.com>
498 * http://v4l.videotechnology.com/
499 *
500 */
501static void zr364xx_fillbuff(struct zr364xx_camera *cam,
502 struct zr364xx_buffer *buf,
503 int jpgsize)
504{
505 int pos = 0;
506 struct timeval ts;
507 const char *tmpbuf;
508 char *vbuf = videobuf_to_vmalloc(&buf->vb);
509 unsigned long last_frame;
510 struct zr364xx_framei *frm;
511
512 if (!vbuf)
513 return;
514
515 last_frame = cam->last_frame;
516 if (last_frame != -1) {
517 frm = &cam->buffer.frame[last_frame];
518 tmpbuf = (const char *)cam->buffer.frame[last_frame].lpvbits;
519 switch (buf->fmt->fourcc) {
520 case V4L2_PIX_FMT_JPEG:
521 buf->vb.size = jpgsize;
522 memcpy(vbuf, tmpbuf, buf->vb.size);
523 break;
524 default:
525 printk(KERN_DEBUG KBUILD_MODNAME ": unknown format?\n");
526 }
527 cam->last_frame = -1;
528 } else {
529 printk(KERN_ERR KBUILD_MODNAME ": =======no frame\n");
530 return;
531 }
532 DBG("%s: Buffer 0x%08lx size= %d\n", __func__,
533 (unsigned long)vbuf, pos);
534 /* tell v4l buffer was filled */
535
536 buf->vb.field_count = cam->frame_count * 2;
537 do_gettimeofday(&ts);
538 buf->vb.ts = ts;
539 buf->vb.state = VIDEOBUF_DONE;
540}
541
542static int zr364xx_got_frame(struct zr364xx_camera *cam, int jpgsize)
543{
544 struct zr364xx_dmaqueue *dma_q = &cam->vidq;
545 struct zr364xx_buffer *buf;
546 unsigned long flags = 0;
547 int rc = 0;
548
549 DBG("wakeup: %p\n", &dma_q);
550 spin_lock_irqsave(&cam->slock, flags);
551
552 if (list_empty(&dma_q->active)) {
553 DBG("No active queue to serve\n");
554 rc = -1;
555 goto unlock;
556 }
557 buf = list_entry(dma_q->active.next,
558 struct zr364xx_buffer, vb.queue);
559
560 if (!waitqueue_active(&buf->vb.done)) {
561 /* no one active */
562 rc = -1;
563 goto unlock;
564 }
565 list_del(&buf->vb.queue);
566 do_gettimeofday(&buf->vb.ts);
567 DBG("[%p/%d] wakeup\n", buf, buf->vb.i);
568 zr364xx_fillbuff(cam, buf, jpgsize);
569 wake_up(&buf->vb.done);
570 DBG("wakeup [buf/i] [%p/%d]\n", buf, buf->vb.i);
571unlock:
572 spin_unlock_irqrestore(&cam->slock, flags);
573 return 0;
574}
575
576/* this function moves the usb stream read pipe data
577 * into the system buffers.
578 * returns 0 on success, EAGAIN if more data to process (call this
579 * function again).
580 */
581static int zr364xx_read_video_callback(struct zr364xx_camera *cam,
582 struct zr364xx_pipeinfo *pipe_info,
583 struct urb *purb)
584{
585 unsigned char *pdest;
586 unsigned char *psrc;
587 s32 idx = -1;
588 struct zr364xx_framei *frm;
589 int i = 0;
590 unsigned char *ptr = NULL;
591
592 _DBG("buffer to user\n");
593 idx = cam->cur_frame;
594 frm = &cam->buffer.frame[idx];
595
596 /* swap bytes if camera needs it */
597 if (cam->method == METHOD0) {
598 u16 *buf = (u16 *)pipe_info->transfer_buffer;
599 for (i = 0; i < purb->actual_length/2; i++)
600 swab16s(buf + i);
601 }
602
603 /* search done. now find out if should be acquiring */
604 if (!cam->b_acquire) {
605 /* we found a frame, but this channel is turned off */
606 frm->ulState = ZR364XX_READ_IDLE;
607 return -EINVAL;
608 }
609
610 psrc = (u8 *)pipe_info->transfer_buffer;
611 ptr = pdest = frm->lpvbits;
612
613 if (frm->ulState == ZR364XX_READ_IDLE) {
614 frm->ulState = ZR364XX_READ_FRAME;
615 frm->cur_size = 0;
616
617 _DBG("jpeg header, ");
618 memcpy(ptr, header1, sizeof(header1));
619 ptr += sizeof(header1);
620 header3 = 0;
621 memcpy(ptr, &header3, 1);
622 ptr++;
623 memcpy(ptr, psrc, 64);
624 ptr += 64;
625 header3 = 1;
626 memcpy(ptr, &header3, 1);
627 ptr++;
628 memcpy(ptr, psrc + 64, 64);
629 ptr += 64;
630 memcpy(ptr, header2, sizeof(header2));
631 ptr += sizeof(header2);
632 memcpy(ptr, psrc + 128,
633 purb->actual_length - 128);
634 ptr += purb->actual_length - 128;
635 _DBG("header : %d %d %d %d %d %d %d %d %d\n",
636 psrc[0], psrc[1], psrc[2],
637 psrc[3], psrc[4], psrc[5],
638 psrc[6], psrc[7], psrc[8]);
639 frm->cur_size = ptr - pdest;
640 } else {
641 if (frm->cur_size + purb->actual_length > MAX_FRAME_SIZE) {
642 dev_info(&cam->udev->dev,
643 "%s: buffer (%d bytes) too small to hold "
644 "frame data. Discarding frame data.\n",
645 __func__, MAX_FRAME_SIZE);
646 } else {
647 pdest += frm->cur_size;
648 memcpy(pdest, psrc, purb->actual_length);
649 frm->cur_size += purb->actual_length;
650 }
651 }
652 /*_DBG("cur_size %lu urb size %d\n", frm->cur_size,
653 purb->actual_length);*/
654
655 if (purb->actual_length < pipe_info->transfer_size) {
656 _DBG("****************Buffer[%d]full*************\n", idx);
657 cam->last_frame = cam->cur_frame;
658 cam->cur_frame++;
659 /* end of system frame ring buffer, start at zero */
660 if (cam->cur_frame == cam->buffer.dwFrames)
661 cam->cur_frame = 0;
662
663 /* frame ready */
664 /* go back to find the JPEG EOI marker */
665 ptr = pdest = frm->lpvbits;
666 ptr += frm->cur_size - 2;
667 while (ptr > pdest) {
668 if (*ptr == 0xFF && *(ptr + 1) == 0xD9
669 && *(ptr + 2) == 0xFF)
670 break;
671 ptr--;
672 }
673 if (ptr == pdest)
674 DBG("No EOI marker\n");
675
676 /* Sometimes there is junk data in the middle of the picture,
677 * we want to skip this bogus frames */
678 while (ptr > pdest) {
679 if (*ptr == 0xFF && *(ptr + 1) == 0xFF
680 && *(ptr + 2) == 0xFF)
681 break;
682 ptr--;
683 }
684 if (ptr != pdest) {
685 DBG("Bogus frame ? %d\n", ++(cam->nb));
686 } else if (cam->b_acquire) {
687 /* we skip the 2 first frames which are usually buggy */
688 if (cam->skip)
689 cam->skip--;
690 else {
691 _DBG("jpeg(%lu): %d %d %d %d %d %d %d %d\n",
692 frm->cur_size,
693 pdest[0], pdest[1], pdest[2], pdest[3],
694 pdest[4], pdest[5], pdest[6], pdest[7]);
695
696 zr364xx_got_frame(cam, frm->cur_size);
697 }
698 }
699 cam->frame_count++;
700 frm->ulState = ZR364XX_READ_IDLE;
701 frm->cur_size = 0;
702 }
703 /* done successfully */
704 return 0;
705}
417 706
418 if (copy_to_user(buf, cam->framebuf, count)) 707static int res_get(struct zr364xx_camera *cam)
419 return -EFAULT; 708{
709 /* is it free? */
710 mutex_lock(&cam->lock);
711 if (cam->resources) {
712 /* no, someone else uses it */
713 mutex_unlock(&cam->lock);
714 return 0;
715 }
716 /* it's free, grab it */
717 cam->resources = 1;
718 _DBG("res: get\n");
719 mutex_unlock(&cam->lock);
720 return 1;
721}
420 722
421 return count; 723static inline int res_check(struct zr364xx_camera *cam)
724{
725 return cam->resources;
422} 726}
423 727
728static void res_free(struct zr364xx_camera *cam)
729{
730 mutex_lock(&cam->lock);
731 cam->resources = 0;
732 mutex_unlock(&cam->lock);
733 _DBG("res: put\n");
734}
424 735
425static int zr364xx_vidioc_querycap(struct file *file, void *priv, 736static int zr364xx_vidioc_querycap(struct file *file, void *priv,
426 struct v4l2_capability *cap) 737 struct v4l2_capability *cap)
427{ 738{
428 strcpy(cap->driver, DRIVER_DESC); 739 struct zr364xx_camera *cam = video_drvdata(file);
429 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE; 740
741 strlcpy(cap->driver, DRIVER_DESC, sizeof(cap->driver));
742 strlcpy(cap->card, cam->udev->product, sizeof(cap->card));
743 strlcpy(cap->bus_info, dev_name(&cam->udev->dev),
744 sizeof(cap->bus_info));
745 cap->version = ZR364XX_VERSION_CODE;
746 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
747 V4L2_CAP_READWRITE |
748 V4L2_CAP_STREAMING;
749
430 return 0; 750 return 0;
431} 751}
432 752
@@ -458,12 +778,11 @@ static int zr364xx_vidioc_s_input(struct file *file, void *priv,
458static int zr364xx_vidioc_queryctrl(struct file *file, void *priv, 778static int zr364xx_vidioc_queryctrl(struct file *file, void *priv,
459 struct v4l2_queryctrl *c) 779 struct v4l2_queryctrl *c)
460{ 780{
461 struct video_device *vdev = video_devdata(file);
462 struct zr364xx_camera *cam; 781 struct zr364xx_camera *cam;
463 782
464 if (vdev == NULL) 783 if (file == NULL)
465 return -ENODEV; 784 return -ENODEV;
466 cam = video_get_drvdata(vdev); 785 cam = video_drvdata(file);
467 786
468 switch (c->id) { 787 switch (c->id) {
469 case V4L2_CID_BRIGHTNESS: 788 case V4L2_CID_BRIGHTNESS:
@@ -472,7 +791,7 @@ static int zr364xx_vidioc_queryctrl(struct file *file, void *priv,
472 c->minimum = 0; 791 c->minimum = 0;
473 c->maximum = 127; 792 c->maximum = 127;
474 c->step = 1; 793 c->step = 1;
475 c->default_value = cam->brightness; 794 c->default_value = cam->mode.brightness;
476 c->flags = 0; 795 c->flags = 0;
477 break; 796 break;
478 default: 797 default:
@@ -484,36 +803,42 @@ static int zr364xx_vidioc_queryctrl(struct file *file, void *priv,
484static int zr364xx_vidioc_s_ctrl(struct file *file, void *priv, 803static int zr364xx_vidioc_s_ctrl(struct file *file, void *priv,
485 struct v4l2_control *c) 804 struct v4l2_control *c)
486{ 805{
487 struct video_device *vdev = video_devdata(file);
488 struct zr364xx_camera *cam; 806 struct zr364xx_camera *cam;
807 int temp;
489 808
490 if (vdev == NULL) 809 if (file == NULL)
491 return -ENODEV; 810 return -ENODEV;
492 cam = video_get_drvdata(vdev); 811 cam = video_drvdata(file);
493 812
494 switch (c->id) { 813 switch (c->id) {
495 case V4L2_CID_BRIGHTNESS: 814 case V4L2_CID_BRIGHTNESS:
496 cam->brightness = c->value; 815 cam->mode.brightness = c->value;
816 /* hardware brightness */
817 mutex_lock(&cam->lock);
818 send_control_msg(cam->udev, 1, 0x2001, 0, NULL, 0);
819 temp = (0x60 << 8) + 127 - cam->mode.brightness;
820 send_control_msg(cam->udev, 1, temp, 0, NULL, 0);
821 mutex_unlock(&cam->lock);
497 break; 822 break;
498 default: 823 default:
499 return -EINVAL; 824 return -EINVAL;
500 } 825 }
826
501 return 0; 827 return 0;
502} 828}
503 829
504static int zr364xx_vidioc_g_ctrl(struct file *file, void *priv, 830static int zr364xx_vidioc_g_ctrl(struct file *file, void *priv,
505 struct v4l2_control *c) 831 struct v4l2_control *c)
506{ 832{
507 struct video_device *vdev = video_devdata(file);
508 struct zr364xx_camera *cam; 833 struct zr364xx_camera *cam;
509 834
510 if (vdev == NULL) 835 if (file == NULL)
511 return -ENODEV; 836 return -ENODEV;
512 cam = video_get_drvdata(vdev); 837 cam = video_drvdata(file);
513 838
514 switch (c->id) { 839 switch (c->id) {
515 case V4L2_CID_BRIGHTNESS: 840 case V4L2_CID_BRIGHTNESS:
516 c->value = cam->brightness; 841 c->value = cam->mode.brightness;
517 break; 842 break;
518 default: 843 default:
519 return -EINVAL; 844 return -EINVAL;
@@ -527,47 +852,63 @@ static int zr364xx_vidioc_enum_fmt_vid_cap(struct file *file,
527 if (f->index > 0) 852 if (f->index > 0)
528 return -EINVAL; 853 return -EINVAL;
529 f->flags = V4L2_FMT_FLAG_COMPRESSED; 854 f->flags = V4L2_FMT_FLAG_COMPRESSED;
530 strcpy(f->description, "JPEG"); 855 strcpy(f->description, formats[0].name);
531 f->pixelformat = V4L2_PIX_FMT_JPEG; 856 f->pixelformat = formats[0].fourcc;
532 return 0; 857 return 0;
533} 858}
534 859
860static char *decode_fourcc(__u32 pixelformat, char *buf)
861{
862 buf[0] = pixelformat & 0xff;
863 buf[1] = (pixelformat >> 8) & 0xff;
864 buf[2] = (pixelformat >> 16) & 0xff;
865 buf[3] = (pixelformat >> 24) & 0xff;
866 buf[4] = '\0';
867 return buf;
868}
869
535static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv, 870static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
536 struct v4l2_format *f) 871 struct v4l2_format *f)
537{ 872{
538 struct video_device *vdev = video_devdata(file); 873 struct zr364xx_camera *cam = video_drvdata(file);
539 struct zr364xx_camera *cam; 874 char pixelformat_name[5];
540 875
541 if (vdev == NULL) 876 if (cam == NULL)
542 return -ENODEV; 877 return -ENODEV;
543 cam = video_get_drvdata(vdev);
544 878
545 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) 879 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) {
546 return -EINVAL; 880 DBG("%s: unsupported pixelformat V4L2_PIX_FMT_%s\n", __func__,
547 if (f->fmt.pix.field != V4L2_FIELD_ANY && 881 decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name));
548 f->fmt.pix.field != V4L2_FIELD_NONE)
549 return -EINVAL; 882 return -EINVAL;
883 }
884
885 if (!(f->fmt.pix.width == 160 && f->fmt.pix.height == 120) &&
886 !(f->fmt.pix.width == 640 && f->fmt.pix.height == 480)) {
887 f->fmt.pix.width = 320;
888 f->fmt.pix.height = 240;
889 }
890
550 f->fmt.pix.field = V4L2_FIELD_NONE; 891 f->fmt.pix.field = V4L2_FIELD_NONE;
551 f->fmt.pix.width = cam->width;
552 f->fmt.pix.height = cam->height;
553 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 892 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
554 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 893 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
555 f->fmt.pix.colorspace = 0; 894 f->fmt.pix.colorspace = 0;
556 f->fmt.pix.priv = 0; 895 f->fmt.pix.priv = 0;
896 DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__,
897 decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name),
898 f->fmt.pix.field);
557 return 0; 899 return 0;
558} 900}
559 901
560static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv, 902static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
561 struct v4l2_format *f) 903 struct v4l2_format *f)
562{ 904{
563 struct video_device *vdev = video_devdata(file);
564 struct zr364xx_camera *cam; 905 struct zr364xx_camera *cam;
565 906
566 if (vdev == NULL) 907 if (file == NULL)
567 return -ENODEV; 908 return -ENODEV;
568 cam = video_get_drvdata(vdev); 909 cam = video_drvdata(file);
569 910
570 f->fmt.pix.pixelformat = V4L2_PIX_FMT_JPEG; 911 f->fmt.pix.pixelformat = formats[0].fourcc;
571 f->fmt.pix.field = V4L2_FIELD_NONE; 912 f->fmt.pix.field = V4L2_FIELD_NONE;
572 f->fmt.pix.width = cam->width; 913 f->fmt.pix.width = cam->width;
573 f->fmt.pix.height = cam->height; 914 f->fmt.pix.height = cam->height;
@@ -581,38 +922,327 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
581static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv, 922static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv,
582 struct v4l2_format *f) 923 struct v4l2_format *f)
583{ 924{
584 struct video_device *vdev = video_devdata(file); 925 struct zr364xx_camera *cam = video_drvdata(file);
585 struct zr364xx_camera *cam; 926 struct videobuf_queue *q = &cam->vb_vidq;
927 char pixelformat_name[5];
928 int ret = zr364xx_vidioc_try_fmt_vid_cap(file, cam, f);
929 int i;
586 930
587 if (vdev == NULL) 931 if (ret < 0)
588 return -ENODEV; 932 return ret;
589 cam = video_get_drvdata(vdev);
590 933
591 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) 934 mutex_lock(&q->vb_lock);
592 return -EINVAL; 935
593 if (f->fmt.pix.field != V4L2_FIELD_ANY && 936 if (videobuf_queue_is_busy(&cam->vb_vidq)) {
594 f->fmt.pix.field != V4L2_FIELD_NONE) 937 DBG("%s queue busy\n", __func__);
595 return -EINVAL; 938 ret = -EBUSY;
596 f->fmt.pix.field = V4L2_FIELD_NONE; 939 goto out;
597 f->fmt.pix.width = cam->width; 940 }
598 f->fmt.pix.height = cam->height; 941
942 if (res_check(cam)) {
943 DBG("%s can't change format after started\n", __func__);
944 ret = -EBUSY;
945 goto out;
946 }
947
948 cam->width = f->fmt.pix.width;
949 cam->height = f->fmt.pix.height;
950 dev_info(&cam->udev->dev, "%s: %dx%d mode selected\n", __func__,
951 cam->width, cam->height);
599 f->fmt.pix.bytesperline = f->fmt.pix.width * 2; 952 f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
600 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; 953 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
601 f->fmt.pix.colorspace = 0; 954 f->fmt.pix.colorspace = 0;
602 f->fmt.pix.priv = 0; 955 f->fmt.pix.priv = 0;
603 DBG("ok!"); 956 cam->vb_vidq.field = f->fmt.pix.field;
957 cam->mode.color = V4L2_PIX_FMT_JPEG;
958
959 if (f->fmt.pix.width == 160 && f->fmt.pix.height == 120)
960 mode = 1;
961 else if (f->fmt.pix.width == 640 && f->fmt.pix.height == 480)
962 mode = 2;
963 else
964 mode = 0;
965
966 m0d1[0] = mode;
967 m1[2].value = 0xf000 + mode;
968 m2[1].value = 0xf000 + mode;
969 header2[437] = cam->height / 256;
970 header2[438] = cam->height % 256;
971 header2[439] = cam->width / 256;
972 header2[440] = cam->width % 256;
973
974 for (i = 0; init[cam->method][i].size != -1; i++) {
975 ret =
976 send_control_msg(cam->udev, 1, init[cam->method][i].value,
977 0, init[cam->method][i].bytes,
978 init[cam->method][i].size);
979 if (ret < 0) {
980 dev_err(&cam->udev->dev,
981 "error during resolution change sequence: %d\n", i);
982 goto out;
983 }
984 }
985
986 /* Added some delay here, since opening/closing the camera quickly,
987 * like Ekiga does during its startup, can crash the webcam
988 */
989 mdelay(100);
990 cam->skip = 2;
991 ret = 0;
992
993out:
994 mutex_unlock(&q->vb_lock);
995
996 DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__,
997 decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name),
998 f->fmt.pix.field);
999 return ret;
1000}
1001
1002static int zr364xx_vidioc_reqbufs(struct file *file, void *priv,
1003 struct v4l2_requestbuffers *p)
1004{
1005 int rc;
1006 struct zr364xx_camera *cam = video_drvdata(file);
1007 rc = videobuf_reqbufs(&cam->vb_vidq, p);
1008 return rc;
1009}
1010
1011static int zr364xx_vidioc_querybuf(struct file *file,
1012 void *priv,
1013 struct v4l2_buffer *p)
1014{
1015 int rc;
1016 struct zr364xx_camera *cam = video_drvdata(file);
1017 rc = videobuf_querybuf(&cam->vb_vidq, p);
1018 return rc;
1019}
1020
1021static int zr364xx_vidioc_qbuf(struct file *file,
1022 void *priv,
1023 struct v4l2_buffer *p)
1024{
1025 int rc;
1026 struct zr364xx_camera *cam = video_drvdata(file);
1027 _DBG("%s\n", __func__);
1028 rc = videobuf_qbuf(&cam->vb_vidq, p);
1029 return rc;
1030}
1031
1032static int zr364xx_vidioc_dqbuf(struct file *file,
1033 void *priv,
1034 struct v4l2_buffer *p)
1035{
1036 int rc;
1037 struct zr364xx_camera *cam = video_drvdata(file);
1038 _DBG("%s\n", __func__);
1039 rc = videobuf_dqbuf(&cam->vb_vidq, p, file->f_flags & O_NONBLOCK);
1040 return rc;
1041}
1042
1043static void read_pipe_completion(struct urb *purb)
1044{
1045 struct zr364xx_pipeinfo *pipe_info;
1046 struct zr364xx_camera *cam;
1047 int pipe;
1048
1049 pipe_info = purb->context;
1050 _DBG("%s %p, status %d\n", __func__, purb, purb->status);
1051 if (pipe_info == NULL) {
1052 printk(KERN_ERR KBUILD_MODNAME ": no context!\n");
1053 return;
1054 }
1055
1056 cam = pipe_info->cam;
1057 if (cam == NULL) {
1058 printk(KERN_ERR KBUILD_MODNAME ": no context!\n");
1059 return;
1060 }
1061
1062 /* if shutting down, do not resubmit, exit immediately */
1063 if (purb->status == -ESHUTDOWN) {
1064 DBG("%s, err shutdown\n", __func__);
1065 pipe_info->err_count++;
1066 return;
1067 }
1068
1069 if (pipe_info->state == 0) {
1070 DBG("exiting USB pipe\n");
1071 return;
1072 }
1073
1074 if (purb->actual_length < 0 ||
1075 purb->actual_length > pipe_info->transfer_size) {
1076 dev_err(&cam->udev->dev, "wrong number of bytes\n");
1077 return;
1078 }
1079
1080 if (purb->status == 0)
1081 zr364xx_read_video_callback(cam, pipe_info, purb);
1082 else {
1083 pipe_info->err_count++;
1084 DBG("%s: failed URB %d\n", __func__, purb->status);
1085 }
1086
1087 pipe = usb_rcvbulkpipe(cam->udev, cam->read_endpoint);
1088
1089 /* reuse urb */
1090 usb_fill_bulk_urb(pipe_info->stream_urb, cam->udev,
1091 pipe,
1092 pipe_info->transfer_buffer,
1093 pipe_info->transfer_size,
1094 read_pipe_completion, pipe_info);
1095
1096 if (pipe_info->state != 0) {
1097 purb->status = usb_submit_urb(pipe_info->stream_urb,
1098 GFP_ATOMIC);
1099
1100 if (purb->status)
1101 dev_err(&cam->udev->dev,
1102 "error submitting urb (error=%i)\n",
1103 purb->status);
1104 } else
1105 DBG("read pipe complete state 0\n");
1106}
1107
1108static int zr364xx_start_readpipe(struct zr364xx_camera *cam)
1109{
1110 int pipe;
1111 int retval;
1112 struct zr364xx_pipeinfo *pipe_info = cam->pipe;
1113 pipe = usb_rcvbulkpipe(cam->udev, cam->read_endpoint);
1114 DBG("%s: start pipe IN x%x\n", __func__, cam->read_endpoint);
1115
1116 pipe_info->state = 1;
1117 pipe_info->err_count = 0;
1118 pipe_info->stream_urb = usb_alloc_urb(0, GFP_KERNEL);
1119 if (!pipe_info->stream_urb) {
1120 dev_err(&cam->udev->dev, "ReadStream: Unable to alloc URB\n");
1121 return -ENOMEM;
1122 }
1123 /* transfer buffer allocated in board_init */
1124 usb_fill_bulk_urb(pipe_info->stream_urb, cam->udev,
1125 pipe,
1126 pipe_info->transfer_buffer,
1127 pipe_info->transfer_size,
1128 read_pipe_completion, pipe_info);
1129
1130 DBG("submitting URB %p\n", pipe_info->stream_urb);
1131 retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL);
1132 if (retval) {
1133 printk(KERN_ERR KBUILD_MODNAME ": start read pipe failed\n");
1134 return retval;
1135 }
1136
1137 return 0;
1138}
1139
1140static void zr364xx_stop_readpipe(struct zr364xx_camera *cam)
1141{
1142 struct zr364xx_pipeinfo *pipe_info;
1143
1144 if (cam == NULL) {
1145 printk(KERN_ERR KBUILD_MODNAME ": invalid device\n");
1146 return;
1147 }
1148 DBG("stop read pipe\n");
1149 pipe_info = cam->pipe;
1150 if (pipe_info) {
1151 if (pipe_info->state != 0)
1152 pipe_info->state = 0;
1153
1154 if (pipe_info->stream_urb) {
1155 /* cancel urb */
1156 usb_kill_urb(pipe_info->stream_urb);
1157 usb_free_urb(pipe_info->stream_urb);
1158 pipe_info->stream_urb = NULL;
1159 }
1160 }
1161 return;
1162}
1163
1164/* starts acquisition process */
1165static int zr364xx_start_acquire(struct zr364xx_camera *cam)
1166{
1167 int j;
1168
1169 DBG("start acquire\n");
1170
1171 cam->last_frame = -1;
1172 cam->cur_frame = 0;
1173 for (j = 0; j < FRAMES; j++) {
1174 cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE;
1175 cam->buffer.frame[j].cur_size = 0;
1176 }
1177 cam->b_acquire = 1;
1178 return 0;
1179}
1180
1181static inline int zr364xx_stop_acquire(struct zr364xx_camera *cam)
1182{
1183 cam->b_acquire = 0;
604 return 0; 1184 return 0;
605} 1185}
606 1186
607static int zr364xx_vidioc_streamon(struct file *file, void *priv, 1187static int zr364xx_vidioc_streamon(struct file *file, void *priv,
608 enum v4l2_buf_type type) 1188 enum v4l2_buf_type type)
609{ 1189{
610 return 0; 1190 struct zr364xx_camera *cam = video_drvdata(file);
1191 int j;
1192 int res;
1193
1194 DBG("%s\n", __func__);
1195
1196 if (cam->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1197 dev_err(&cam->udev->dev, "invalid fh type0\n");
1198 return -EINVAL;
1199 }
1200 if (cam->type != type) {
1201 dev_err(&cam->udev->dev, "invalid fh type1\n");
1202 return -EINVAL;
1203 }
1204
1205 if (!res_get(cam)) {
1206 dev_err(&cam->udev->dev, "stream busy\n");
1207 return -EBUSY;
1208 }
1209
1210 cam->last_frame = -1;
1211 cam->cur_frame = 0;
1212 cam->frame_count = 0;
1213 for (j = 0; j < FRAMES; j++) {
1214 cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE;
1215 cam->buffer.frame[j].cur_size = 0;
1216 }
1217 res = videobuf_streamon(&cam->vb_vidq);
1218 if (res == 0) {
1219 zr364xx_start_acquire(cam);
1220 } else {
1221 res_free(cam);
1222 }
1223 return res;
611} 1224}
612 1225
613static int zr364xx_vidioc_streamoff(struct file *file, void *priv, 1226static int zr364xx_vidioc_streamoff(struct file *file, void *priv,
614 enum v4l2_buf_type type) 1227 enum v4l2_buf_type type)
615{ 1228{
1229 int res;
1230 struct zr364xx_camera *cam = video_drvdata(file);
1231
1232 DBG("%s\n", __func__);
1233 if (cam->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1234 dev_err(&cam->udev->dev, "invalid fh type0\n");
1235 return -EINVAL;
1236 }
1237 if (cam->type != type) {
1238 dev_err(&cam->udev->dev, "invalid fh type1\n");
1239 return -EINVAL;
1240 }
1241 zr364xx_stop_acquire(cam);
1242 res = videobuf_streamoff(&cam->vb_vidq);
1243 if (res < 0)
1244 return res;
1245 res_free(cam);
616 return 0; 1246 return 0;
617} 1247}
618 1248
@@ -621,28 +1251,19 @@ static int zr364xx_vidioc_streamoff(struct file *file, void *priv,
621static int zr364xx_open(struct file *file) 1251static int zr364xx_open(struct file *file)
622{ 1252{
623 struct video_device *vdev = video_devdata(file); 1253 struct video_device *vdev = video_devdata(file);
624 struct zr364xx_camera *cam = video_get_drvdata(vdev); 1254 struct zr364xx_camera *cam = video_drvdata(file);
625 struct usb_device *udev = cam->udev; 1255 struct usb_device *udev = cam->udev;
626 int i, err; 1256 int i, err;
627 1257
628 DBG("zr364xx_open"); 1258 DBG("%s\n", __func__);
629 1259
630 mutex_lock(&cam->lock); 1260 mutex_lock(&cam->open_lock);
631 1261
632 if (cam->users) { 1262 if (cam->users) {
633 err = -EBUSY; 1263 err = -EBUSY;
634 goto out; 1264 goto out;
635 } 1265 }
636 1266
637 if (!cam->framebuf) {
638 cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES);
639 if (!cam->framebuf) {
640 dev_err(&cam->udev->dev, "vmalloc_32 failed!\n");
641 err = -ENOMEM;
642 goto out;
643 }
644 }
645
646 for (i = 0; init[cam->method][i].size != -1; i++) { 1267 for (i = 0; init[cam->method][i].size != -1; i++) {
647 err = 1268 err =
648 send_control_msg(udev, 1, init[cam->method][i].value, 1269 send_control_msg(udev, 1, init[cam->method][i].value,
@@ -658,6 +1279,14 @@ static int zr364xx_open(struct file *file)
658 cam->skip = 2; 1279 cam->skip = 2;
659 cam->users++; 1280 cam->users++;
660 file->private_data = vdev; 1281 file->private_data = vdev;
1282 cam->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1283 cam->fmt = formats;
1284
1285 videobuf_queue_vmalloc_init(&cam->vb_vidq, &zr364xx_video_qops,
1286 NULL, &cam->slock,
1287 cam->type,
1288 V4L2_FIELD_NONE,
1289 sizeof(struct zr364xx_buffer), cam);
661 1290
662 /* Added some delay here, since opening/closing the camera quickly, 1291 /* Added some delay here, since opening/closing the camera quickly,
663 * like Ekiga does during its startup, can crash the webcam 1292 * like Ekiga does during its startup, can crash the webcam
@@ -666,28 +1295,70 @@ static int zr364xx_open(struct file *file)
666 err = 0; 1295 err = 0;
667 1296
668out: 1297out:
669 mutex_unlock(&cam->lock); 1298 mutex_unlock(&cam->open_lock);
1299 DBG("%s: %d\n", __func__, err);
670 return err; 1300 return err;
671} 1301}
672 1302
1303static void zr364xx_destroy(struct zr364xx_camera *cam)
1304{
1305 unsigned long i;
1306
1307 if (!cam) {
1308 printk(KERN_ERR KBUILD_MODNAME ", %s: no device\n", __func__);
1309 return;
1310 }
1311 mutex_lock(&cam->open_lock);
1312 if (cam->vdev)
1313 video_unregister_device(cam->vdev);
1314 cam->vdev = NULL;
1315
1316 /* stops the read pipe if it is running */
1317 if (cam->b_acquire)
1318 zr364xx_stop_acquire(cam);
1319
1320 zr364xx_stop_readpipe(cam);
1321
1322 /* release sys buffers */
1323 for (i = 0; i < FRAMES; i++) {
1324 if (cam->buffer.frame[i].lpvbits) {
1325 DBG("vfree %p\n", cam->buffer.frame[i].lpvbits);
1326 vfree(cam->buffer.frame[i].lpvbits);
1327 }
1328 cam->buffer.frame[i].lpvbits = NULL;
1329 }
1330
1331 /* release transfer buffer */
1332 kfree(cam->pipe->transfer_buffer);
1333 cam->pipe->transfer_buffer = NULL;
1334 mutex_unlock(&cam->open_lock);
1335 kfree(cam);
1336 cam = NULL;
1337}
673 1338
674/* release the camera */ 1339/* release the camera */
675static int zr364xx_release(struct file *file) 1340static int zr364xx_release(struct file *file)
676{ 1341{
677 struct video_device *vdev = video_devdata(file);
678 struct zr364xx_camera *cam; 1342 struct zr364xx_camera *cam;
679 struct usb_device *udev; 1343 struct usb_device *udev;
680 int i, err; 1344 int i, err;
681 1345
682 DBG("zr364xx_release"); 1346 DBG("%s\n", __func__);
1347 cam = video_drvdata(file);
683 1348
684 if (vdev == NULL) 1349 if (!cam)
685 return -ENODEV; 1350 return -ENODEV;
686 cam = video_get_drvdata(vdev);
687 1351
1352 mutex_lock(&cam->open_lock);
688 udev = cam->udev; 1353 udev = cam->udev;
689 1354
690 mutex_lock(&cam->lock); 1355 /* turn off stream */
1356 if (res_check(cam)) {
1357 if (cam->b_acquire)
1358 zr364xx_stop_acquire(cam);
1359 videobuf_streamoff(&cam->vb_vidq);
1360 res_free(cam);
1361 }
691 1362
692 cam->users--; 1363 cam->users--;
693 file->private_data = NULL; 1364 file->private_data = NULL;
@@ -710,40 +1381,43 @@ static int zr364xx_release(struct file *file)
710 err = 0; 1381 err = 0;
711 1382
712out: 1383out:
713 mutex_unlock(&cam->lock); 1384 mutex_unlock(&cam->open_lock);
1385
714 return err; 1386 return err;
715} 1387}
716 1388
717 1389
718static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma) 1390static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma)
719{ 1391{
720 void *pos; 1392 struct zr364xx_camera *cam = video_drvdata(file);
721 unsigned long start = vma->vm_start; 1393 int ret;
722 unsigned long size = vma->vm_end - vma->vm_start;
723 struct video_device *vdev = video_devdata(file);
724 struct zr364xx_camera *cam;
725
726 DBG("zr364xx_mmap: %ld\n", size);
727 1394
728 if (vdev == NULL) 1395 if (cam == NULL) {
1396 DBG("%s: cam == NULL\n", __func__);
729 return -ENODEV; 1397 return -ENODEV;
730 cam = video_get_drvdata(vdev);
731
732 pos = cam->framebuf;
733 while (size > 0) {
734 if (vm_insert_page(vma, start, vmalloc_to_page(pos)))
735 return -EAGAIN;
736 start += PAGE_SIZE;
737 pos += PAGE_SIZE;
738 if (size > PAGE_SIZE)
739 size -= PAGE_SIZE;
740 else
741 size = 0;
742 } 1398 }
1399 DBG("mmap called, vma=0x%08lx\n", (unsigned long)vma);
743 1400
744 return 0; 1401 ret = videobuf_mmap_mapper(&cam->vb_vidq, vma);
1402
1403 DBG("vma start=0x%08lx, size=%ld, ret=%d\n",
1404 (unsigned long)vma->vm_start,
1405 (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, ret);
1406 return ret;
745} 1407}
746 1408
1409static unsigned int zr364xx_poll(struct file *file,
1410 struct poll_table_struct *wait)
1411{
1412 struct zr364xx_camera *cam = video_drvdata(file);
1413 struct videobuf_queue *q = &cam->vb_vidq;
1414 _DBG("%s\n", __func__);
1415
1416 if (cam->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1417 return POLLERR;
1418
1419 return videobuf_poll_stream(file, q, wait);
1420}
747 1421
748static const struct v4l2_file_operations zr364xx_fops = { 1422static const struct v4l2_file_operations zr364xx_fops = {
749 .owner = THIS_MODULE, 1423 .owner = THIS_MODULE,
@@ -752,6 +1426,7 @@ static const struct v4l2_file_operations zr364xx_fops = {
752 .read = zr364xx_read, 1426 .read = zr364xx_read,
753 .mmap = zr364xx_mmap, 1427 .mmap = zr364xx_mmap,
754 .ioctl = video_ioctl2, 1428 .ioctl = video_ioctl2,
1429 .poll = zr364xx_poll,
755}; 1430};
756 1431
757static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = { 1432static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = {
@@ -768,6 +1443,10 @@ static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = {
768 .vidioc_queryctrl = zr364xx_vidioc_queryctrl, 1443 .vidioc_queryctrl = zr364xx_vidioc_queryctrl,
769 .vidioc_g_ctrl = zr364xx_vidioc_g_ctrl, 1444 .vidioc_g_ctrl = zr364xx_vidioc_g_ctrl,
770 .vidioc_s_ctrl = zr364xx_vidioc_s_ctrl, 1445 .vidioc_s_ctrl = zr364xx_vidioc_s_ctrl,
1446 .vidioc_reqbufs = zr364xx_vidioc_reqbufs,
1447 .vidioc_querybuf = zr364xx_vidioc_querybuf,
1448 .vidioc_qbuf = zr364xx_vidioc_qbuf,
1449 .vidioc_dqbuf = zr364xx_vidioc_dqbuf,
771}; 1450};
772 1451
773static struct video_device zr364xx_template = { 1452static struct video_device zr364xx_template = {
@@ -783,15 +1462,76 @@ static struct video_device zr364xx_template = {
783/*******************/ 1462/*******************/
784/* USB integration */ 1463/* USB integration */
785/*******************/ 1464/*******************/
1465static int zr364xx_board_init(struct zr364xx_camera *cam)
1466{
1467 struct zr364xx_pipeinfo *pipe = cam->pipe;
1468 unsigned long i;
1469
1470 DBG("board init: %p\n", cam);
1471 memset(pipe, 0, sizeof(*pipe));
1472 pipe->cam = cam;
1473 pipe->transfer_size = BUFFER_SIZE;
1474
1475 pipe->transfer_buffer = kzalloc(pipe->transfer_size,
1476 GFP_KERNEL);
1477 if (pipe->transfer_buffer == NULL) {
1478 DBG("out of memory!\n");
1479 return -ENOMEM;
1480 }
1481
1482 cam->b_acquire = 0;
1483 cam->frame_count = 0;
1484
1485 /*** start create system buffers ***/
1486 for (i = 0; i < FRAMES; i++) {
1487 /* always allocate maximum size for system buffers */
1488 cam->buffer.frame[i].lpvbits = vmalloc(MAX_FRAME_SIZE);
1489
1490 DBG("valloc %p, idx %lu, pdata %p\n",
1491 &cam->buffer.frame[i], i,
1492 cam->buffer.frame[i].lpvbits);
1493 if (cam->buffer.frame[i].lpvbits == NULL) {
1494 printk(KERN_INFO KBUILD_MODNAME ": out of memory. "
1495 "Using less frames\n");
1496 break;
1497 }
1498 }
1499
1500 if (i == 0) {
1501 printk(KERN_INFO KBUILD_MODNAME ": out of memory. Aborting\n");
1502 kfree(cam->pipe->transfer_buffer);
1503 cam->pipe->transfer_buffer = NULL;
1504 return -ENOMEM;
1505 } else
1506 cam->buffer.dwFrames = i;
1507
1508 /* make sure internal states are set */
1509 for (i = 0; i < FRAMES; i++) {
1510 cam->buffer.frame[i].ulState = ZR364XX_READ_IDLE;
1511 cam->buffer.frame[i].cur_size = 0;
1512 }
1513
1514 cam->cur_frame = 0;
1515 cam->last_frame = -1;
1516 /*** end create system buffers ***/
1517
1518 /* start read pipe */
1519 zr364xx_start_readpipe(cam);
1520 DBG(": board initialized\n");
1521 return 0;
1522}
786 1523
787static int zr364xx_probe(struct usb_interface *intf, 1524static int zr364xx_probe(struct usb_interface *intf,
788 const struct usb_device_id *id) 1525 const struct usb_device_id *id)
789{ 1526{
790 struct usb_device *udev = interface_to_usbdev(intf); 1527 struct usb_device *udev = interface_to_usbdev(intf);
791 struct zr364xx_camera *cam = NULL; 1528 struct zr364xx_camera *cam = NULL;
1529 struct usb_host_interface *iface_desc;
1530 struct usb_endpoint_descriptor *endpoint;
792 int err; 1531 int err;
1532 int i;
793 1533
794 DBG("probing..."); 1534 DBG("probing...\n");
795 1535
796 dev_info(&intf->dev, DRIVER_DESC " compatible webcam plugged\n"); 1536 dev_info(&intf->dev, DRIVER_DESC " compatible webcam plugged\n");
797 dev_info(&intf->dev, "model %04x:%04x detected\n", 1537 dev_info(&intf->dev, "model %04x:%04x detected\n",
@@ -810,22 +1550,17 @@ static int zr364xx_probe(struct usb_interface *intf,
810 if (cam->vdev == NULL) { 1550 if (cam->vdev == NULL) {
811 dev_err(&udev->dev, "cam->vdev: out of memory !\n"); 1551 dev_err(&udev->dev, "cam->vdev: out of memory !\n");
812 kfree(cam); 1552 kfree(cam);
1553 cam = NULL;
813 return -ENOMEM; 1554 return -ENOMEM;
814 } 1555 }
815 memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template)); 1556 memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template));
1557 cam->vdev->parent = &intf->dev;
816 video_set_drvdata(cam->vdev, cam); 1558 video_set_drvdata(cam->vdev, cam);
817 if (debug) 1559 if (debug)
818 cam->vdev->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; 1560 cam->vdev->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
819 1561
820 cam->udev = udev; 1562 cam->udev = udev;
821 1563
822 if ((cam->buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL)) == NULL) {
823 dev_info(&udev->dev, "cam->buffer: out of memory !\n");
824 video_device_release(cam->vdev);
825 kfree(cam);
826 return -ENODEV;
827 }
828
829 switch (mode) { 1564 switch (mode) {
830 case 1: 1565 case 1:
831 dev_info(&udev->dev, "160x120 mode selected\n"); 1566 dev_info(&udev->dev, "160x120 mode selected\n");
@@ -852,21 +1587,53 @@ static int zr364xx_probe(struct usb_interface *intf,
852 header2[439] = cam->width / 256; 1587 header2[439] = cam->width / 256;
853 header2[440] = cam->width % 256; 1588 header2[440] = cam->width % 256;
854 1589
1590 cam->users = 0;
855 cam->nb = 0; 1591 cam->nb = 0;
856 cam->brightness = 64; 1592 cam->mode.brightness = 64;
857 mutex_init(&cam->lock); 1593 mutex_init(&cam->lock);
1594 mutex_init(&cam->open_lock);
1595
1596 DBG("dev: %p, udev %p interface %p\n", cam, cam->udev, intf);
1597
1598 /* set up the endpoint information */
1599 iface_desc = intf->cur_altsetting;
1600 DBG("num endpoints %d\n", iface_desc->desc.bNumEndpoints);
1601 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
1602 endpoint = &iface_desc->endpoint[i].desc;
1603 if (!cam->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) {
1604 /* we found the bulk in endpoint */
1605 cam->read_endpoint = endpoint->bEndpointAddress;
1606 }
1607 }
1608
1609 if (!cam->read_endpoint) {
1610 dev_err(&intf->dev, "Could not find bulk-in endpoint\n");
1611 return -ENOMEM;
1612 }
858 1613
1614 /* v4l */
1615 INIT_LIST_HEAD(&cam->vidq.active);
1616 cam->vidq.cam = cam;
859 err = video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1); 1617 err = video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1);
860 if (err) { 1618 if (err) {
861 dev_err(&udev->dev, "video_register_device failed\n"); 1619 dev_err(&udev->dev, "video_register_device failed\n");
862 video_device_release(cam->vdev); 1620 video_device_release(cam->vdev);
863 kfree(cam->buffer);
864 kfree(cam); 1621 kfree(cam);
1622 cam = NULL;
865 return err; 1623 return err;
866 } 1624 }
867 1625
868 usb_set_intfdata(intf, cam); 1626 usb_set_intfdata(intf, cam);
869 1627
1628 /* load zr364xx board specific */
1629 err = zr364xx_board_init(cam);
1630 if (err) {
1631 spin_lock_init(&cam->slock);
1632 return err;
1633 }
1634
1635 spin_lock_init(&cam->slock);
1636
870 dev_info(&udev->dev, DRIVER_DESC " controlling video device %d\n", 1637 dev_info(&udev->dev, DRIVER_DESC " controlling video device %d\n",
871 cam->vdev->num); 1638 cam->vdev->num);
872 return 0; 1639 return 0;
@@ -876,17 +1643,10 @@ static int zr364xx_probe(struct usb_interface *intf,
876static void zr364xx_disconnect(struct usb_interface *intf) 1643static void zr364xx_disconnect(struct usb_interface *intf)
877{ 1644{
878 struct zr364xx_camera *cam = usb_get_intfdata(intf); 1645 struct zr364xx_camera *cam = usb_get_intfdata(intf);
1646 videobuf_mmap_free(&cam->vb_vidq);
879 usb_set_intfdata(intf, NULL); 1647 usb_set_intfdata(intf, NULL);
880 dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n"); 1648 dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n");
881 if (cam->vdev) 1649 zr364xx_destroy(cam);
882 video_unregister_device(cam->vdev);
883 cam->vdev = NULL;
884 kfree(cam->buffer);
885 cam->buffer = NULL;
886 vfree(cam->framebuf);
887 cam->framebuf = NULL;
888 kfree(cam);
889 cam = NULL;
890} 1650}
891 1651
892 1652
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 8664feebc93b..e7563a9872d0 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -5,7 +5,7 @@
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * 7 *
8 * 10/10/2000 Nicolas Pitre <nico@cam.org> 8 * 10/10/2000 Nicolas Pitre <nico@fluxnic.net>
9 * - completely revamped method functions so they are aware and 9 * - completely revamped method functions so they are aware and
10 * independent of the flash geometry (buswidth, interleave, etc.) 10 * independent of the flash geometry (buswidth, interleave, etc.)
11 * - scalability vs code size is completely set at compile-time 11 * - scalability vs code size is completely set at compile-time
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 6c740f346f91..0667a671525d 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * 10/10/2000 Nicolas Pitre <nico@cam.org> 7 * 10/10/2000 Nicolas Pitre <nico@fluxnic.net>
8 * - completely revamped method functions so they are aware and 8 * - completely revamped method functions so they are aware and
9 * independent of the flash geometry (buswidth, interleave, etc.) 9 * independent of the flash geometry (buswidth, interleave, etc.)
10 * - scalability vs code size is completely set at compile-time 10 * - scalability vs code size is completely set at compile-time
diff --git a/drivers/mtd/maps/bfin-async-flash.c b/drivers/mtd/maps/bfin-async-flash.c
index 365c77b1b871..a7c808b577d3 100644
--- a/drivers/mtd/maps/bfin-async-flash.c
+++ b/drivers/mtd/maps/bfin-async-flash.c
@@ -6,7 +6,7 @@
6 * for example. All board-specific configuration goes in your 6 * for example. All board-specific configuration goes in your
7 * board resources file. 7 * board resources file.
8 * 8 *
9 * Copyright 2000 Nicolas Pitre <nico@cam.org> 9 * Copyright 2000 Nicolas Pitre <nico@fluxnic.net>
10 * Copyright 2005-2008 Analog Devices Inc. 10 * Copyright 2005-2008 Analog Devices Inc.
11 * 11 *
12 * Enter bugs at http://blackfin.uclinux.org/ 12 * Enter bugs at http://blackfin.uclinux.org/
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
index 60e68bde0fea..d41f34766e53 100644
--- a/drivers/mtd/maps/ceiva.c
+++ b/drivers/mtd/maps/ceiva.c
@@ -9,7 +9,7 @@
9 * Based on: sa1100-flash.c, which has the following copyright: 9 * Based on: sa1100-flash.c, which has the following copyright:
10 * Flash memory access on SA11x0 based devices 10 * Flash memory access on SA11x0 based devices
11 * 11 *
12 * (C) 2000 Nicolas Pitre <nico@cam.org> 12 * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
13 * 13 *
14 */ 14 */
15 15
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index 42969fe051b2..b3cb3a183809 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * MTD map driver for flash on the DC21285 (the StrongARM-110 companion chip) 2 * MTD map driver for flash on the DC21285 (the StrongARM-110 companion chip)
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 */ 7 */
@@ -249,5 +249,5 @@ module_exit(cleanup_dc21285);
249 249
250 250
251MODULE_LICENSE("GPL"); 251MODULE_LICENSE("GPL");
252MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>"); 252MODULE_AUTHOR("Nicolas Pitre <nico@fluxnic.net>");
253MODULE_DESCRIPTION("MTD map driver for DC21285 boards"); 253MODULE_DESCRIPTION("MTD map driver for DC21285 boards");
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index 748c85f635f1..76708e796b70 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Flash memory access on iPAQ Handhelds (either SA1100 or PXA250 based) 2 * Flash memory access on iPAQ Handhelds (either SA1100 or PXA250 based)
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
5 * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com> 5 * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com>
6 * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes 6 * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes
7 */ 7 */
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index 643aa06b599e..74fa075c838a 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -175,5 +175,5 @@ module_init(init_pxa2xx_flash);
175module_exit(cleanup_pxa2xx_flash); 175module_exit(cleanup_pxa2xx_flash);
176 176
177MODULE_LICENSE("GPL"); 177MODULE_LICENSE("GPL");
178MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>"); 178MODULE_AUTHOR("Nicolas Pitre <nico@fluxnic.net>");
179MODULE_DESCRIPTION("MTD map driver for Intel XScale PXA2xx"); 179MODULE_DESCRIPTION("MTD map driver for Intel XScale PXA2xx");
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index c6210f5118d1..fdb97f3d30e9 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Flash memory access on SA11x0 based devices 2 * Flash memory access on SA11x0 based devices
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
5 */ 5 */
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/types.h> 7#include <linux/types.h>
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 77db5ce24d92..2d70295a5fa3 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Direct MTD block device access 2 * Direct MTD block device access
3 * 3 *
4 * (C) 2000-2003 Nicolas Pitre <nico@cam.org> 4 * (C) 2000-2003 Nicolas Pitre <nico@fluxnic.net>
5 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org> 5 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
6 */ 6 */
7 7
@@ -403,5 +403,5 @@ module_exit(cleanup_mtdblock);
403 403
404 404
405MODULE_LICENSE("GPL"); 405MODULE_LICENSE("GPL");
406MODULE_AUTHOR("Nicolas Pitre <nico@cam.org> et al."); 406MODULE_AUTHOR("Nicolas Pitre <nico@fluxnic.net> et al.");
407MODULE_DESCRIPTION("Caching read/erase/writeback block device emulation access to MTD devices"); 407MODULE_DESCRIPTION("Caching read/erase/writeback block device emulation access to MTD devices");
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 349fcbe5cc0f..742504ea96f5 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Simple MTD partitioning layer 2 * Simple MTD partitioning layer
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 * 7 *
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 61be6d7680f6..05c91ee6921e 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -35,7 +35,7 @@
35 * 35 *
36 * contributors: 36 * contributors:
37 * Daris A Nevil <dnevil@snmc.com> 37 * Daris A Nevil <dnevil@snmc.com>
38 * Nicolas Pitre <nico@cam.org> 38 * Nicolas Pitre <nico@fluxnic.net>
39 * Russell King <rmk@arm.linux.org.uk> 39 * Russell King <rmk@arm.linux.org.uk>
40 * 40 *
41 * History: 41 * History:
@@ -58,7 +58,7 @@
58 * 22/09/04 Nicolas Pitre big update (see commit log for details) 58 * 22/09/04 Nicolas Pitre big update (see commit log for details)
59 */ 59 */
60static const char version[] = 60static const char version[] =
61 "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org>\n"; 61 "smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@fluxnic.net>\n";
62 62
63/* Debugging level */ 63/* Debugging level */
64#ifndef SMC_DEBUG 64#ifndef SMC_DEBUG
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 57a159fac99f..784b631cfa3c 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -28,7 +28,7 @@
28 . Authors 28 . Authors
29 . Erik Stahlman <erik@vt.edu> 29 . Erik Stahlman <erik@vt.edu>
30 . Daris A Nevil <dnevil@snmc.com> 30 . Daris A Nevil <dnevil@snmc.com>
31 . Nicolas Pitre <nico@cam.org> 31 . Nicolas Pitre <nico@fluxnic.net>
32 . 32 .
33 ---------------------------------------------------------------------------*/ 33 ---------------------------------------------------------------------------*/
34#ifndef _SMC91X_H_ 34#ifndef _SMC91X_H_
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 1ebd6b4c743b..4a7f11d8f432 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -8,6 +8,9 @@ obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \
8obj-$(CONFIG_PROC_FS) += proc.o 8obj-$(CONFIG_PROC_FS) += proc.o
9obj-$(CONFIG_SYSFS) += slot.o 9obj-$(CONFIG_SYSFS) += slot.o
10 10
11obj-$(CONFIG_PCI_LEGACY) += legacy.o
12CFLAGS_legacy.o += -Wno-deprecated-declarations
13
11# Build PCI Express stuff if needed 14# Build PCI Express stuff if needed
12obj-$(CONFIG_PCIEPORTBUS) += pcie/ 15obj-$(CONFIG_PCIEPORTBUS) += pcie/
13 16
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 7b287cb38b7a..ab99783dccec 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -33,6 +33,7 @@
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/irq.h> 34#include <linux/irq.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/tboot.h>
36 37
37#undef PREFIX 38#undef PREFIX
38#define PREFIX "DMAR:" 39#define PREFIX "DMAR:"
@@ -413,6 +414,12 @@ parse_dmar_table(void)
413 */ 414 */
414 dmar_table_detect(); 415 dmar_table_detect();
415 416
417 /*
418 * ACPI tables may not be DMA protected by tboot, so use DMAR copy
419 * SINIT saved in SinitMleData in TXT heap (which is DMA protected)
420 */
421 dmar_tbl = tboot_get_dmar_table(dmar_tbl);
422
416 dmar = (struct acpi_table_dmar *)dmar_tbl; 423 dmar = (struct acpi_table_dmar *)dmar_tbl;
417 if (!dmar) 424 if (!dmar)
418 return -ENODEV; 425 return -ENODEV;
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 2aa117c8cd87..3625b094bf7e 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -22,7 +22,7 @@ obj-$(CONFIG_HOTPLUG_PCI_SGI) += sgi_hotplug.o
22# Link this last so it doesn't claim devices that have a real hotplug driver 22# Link this last so it doesn't claim devices that have a real hotplug driver
23obj-$(CONFIG_HOTPLUG_PCI_FAKE) += fakephp.o 23obj-$(CONFIG_HOTPLUG_PCI_FAKE) += fakephp.o
24 24
25pci_hotplug-objs := pci_hotplug_core.o 25pci_hotplug-objs := pci_hotplug_core.o pcihp_slot.o
26 26
27ifdef CONFIG_HOTPLUG_PCI_CPCI 27ifdef CONFIG_HOTPLUG_PCI_CPCI
28pci_hotplug-objs += cpci_hotplug_core.o \ 28pci_hotplug-objs += cpci_hotplug_core.o \
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index eb159587d0bf..a73028ec52e5 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -41,7 +41,6 @@
41#define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) 41#define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg)
42 42
43#define METHOD_NAME__SUN "_SUN" 43#define METHOD_NAME__SUN "_SUN"
44#define METHOD_NAME__HPP "_HPP"
45#define METHOD_NAME_OSHP "OSHP" 44#define METHOD_NAME_OSHP "OSHP"
46 45
47static int debug_acpi; 46static int debug_acpi;
@@ -215,80 +214,41 @@ acpi_run_hpx(acpi_handle handle, struct hotplug_params *hpx)
215static acpi_status 214static acpi_status
216acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp) 215acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
217{ 216{
218 acpi_status status; 217 acpi_status status;
219 u8 nui[4]; 218 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
220 struct acpi_buffer ret_buf = { 0, NULL}; 219 union acpi_object *package, *fields;
221 struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL }; 220 int i;
222 union acpi_object *ext_obj, *package;
223 int i, len = 0;
224
225 acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
226 221
227 /* Clear the return buffer with zeros */
228 memset(hpp, 0, sizeof(struct hotplug_params)); 222 memset(hpp, 0, sizeof(struct hotplug_params));
229 223
230 /* get _hpp */ 224 status = acpi_evaluate_object(handle, "_HPP", NULL, &buffer);
231 status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf); 225 if (ACPI_FAILURE(status))
232 switch (status) { 226 return status;
233 case AE_BUFFER_OVERFLOW:
234 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
235 if (!ret_buf.pointer) {
236 printk(KERN_ERR "%s:%s alloc for _HPP fail\n",
237 __func__, (char *)string.pointer);
238 kfree(string.pointer);
239 return AE_NO_MEMORY;
240 }
241 status = acpi_evaluate_object(handle, METHOD_NAME__HPP,
242 NULL, &ret_buf);
243 if (ACPI_SUCCESS(status))
244 break;
245 default:
246 if (ACPI_FAILURE(status)) {
247 pr_debug("%s:%s _HPP fail=0x%x\n", __func__,
248 (char *)string.pointer, status);
249 kfree(string.pointer);
250 return status;
251 }
252 }
253 227
254 ext_obj = (union acpi_object *) ret_buf.pointer; 228 package = (union acpi_object *) buffer.pointer;
255 if (ext_obj->type != ACPI_TYPE_PACKAGE) { 229 if (package->type != ACPI_TYPE_PACKAGE ||
256 printk(KERN_ERR "%s:%s _HPP obj not a package\n", __func__, 230 package->package.count != 4) {
257 (char *)string.pointer);
258 status = AE_ERROR; 231 status = AE_ERROR;
259 goto free_and_return; 232 goto exit;
260 } 233 }
261 234
262 len = ext_obj->package.count; 235 fields = package->package.elements;
263 package = (union acpi_object *) ret_buf.pointer; 236 for (i = 0; i < 4; i++) {
264 for ( i = 0; (i < len) || (i < 4); i++) { 237 if (fields[i].type != ACPI_TYPE_INTEGER) {
265 ext_obj = (union acpi_object *) &package->package.elements[i];
266 switch (ext_obj->type) {
267 case ACPI_TYPE_INTEGER:
268 nui[i] = (u8)ext_obj->integer.value;
269 break;
270 default:
271 printk(KERN_ERR "%s:%s _HPP obj type incorrect\n",
272 __func__, (char *)string.pointer);
273 status = AE_ERROR; 238 status = AE_ERROR;
274 goto free_and_return; 239 goto exit;
275 } 240 }
276 } 241 }
277 242
278 hpp->t0 = &hpp->type0_data; 243 hpp->t0 = &hpp->type0_data;
279 hpp->t0->cache_line_size = nui[0]; 244 hpp->t0->revision = 1;
280 hpp->t0->latency_timer = nui[1]; 245 hpp->t0->cache_line_size = fields[0].integer.value;
281 hpp->t0->enable_serr = nui[2]; 246 hpp->t0->latency_timer = fields[1].integer.value;
282 hpp->t0->enable_perr = nui[3]; 247 hpp->t0->enable_serr = fields[2].integer.value;
283 248 hpp->t0->enable_perr = fields[3].integer.value;
284 pr_debug(" _HPP: cache_line_size=0x%x\n", hpp->t0->cache_line_size);
285 pr_debug(" _HPP: latency timer =0x%x\n", hpp->t0->latency_timer);
286 pr_debug(" _HPP: enable SERR =0x%x\n", hpp->t0->enable_serr);
287 pr_debug(" _HPP: enable PERR =0x%x\n", hpp->t0->enable_perr);
288 249
289free_and_return: 250exit:
290 kfree(string.pointer); 251 kfree(buffer.pointer);
291 kfree(ret_buf.pointer);
292 return status; 252 return status;
293} 253}
294 254
@@ -322,20 +282,19 @@ static acpi_status acpi_run_oshp(acpi_handle handle)
322 return status; 282 return status;
323} 283}
324 284
325/* acpi_get_hp_params_from_firmware 285/* pci_get_hp_params
326 * 286 *
327 * @bus - the pci_bus of the bus on which the device is newly added 287 * @dev - the pci_dev for which we want parameters
328 * @hpp - allocated by the caller 288 * @hpp - allocated by the caller
329 */ 289 */
330acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, 290int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp)
331 struct hotplug_params *hpp)
332{ 291{
333 acpi_status status = AE_NOT_FOUND; 292 acpi_status status;
334 acpi_handle handle, phandle; 293 acpi_handle handle, phandle;
335 struct pci_bus *pbus; 294 struct pci_bus *pbus;
336 295
337 handle = NULL; 296 handle = NULL;
338 for (pbus = bus; pbus; pbus = pbus->parent) { 297 for (pbus = dev->bus; pbus; pbus = pbus->parent) {
339 handle = acpi_pci_get_bridge_handle(pbus); 298 handle = acpi_pci_get_bridge_handle(pbus);
340 if (handle) 299 if (handle)
341 break; 300 break;
@@ -345,15 +304,15 @@ acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus,
345 * _HPP settings apply to all child buses, until another _HPP is 304 * _HPP settings apply to all child buses, until another _HPP is
346 * encountered. If we don't find an _HPP for the input pci dev, 305 * encountered. If we don't find an _HPP for the input pci dev,
347 * look for it in the parent device scope since that would apply to 306 * look for it in the parent device scope since that would apply to
348 * this pci dev. If we don't find any _HPP, use hardcoded defaults 307 * this pci dev.
349 */ 308 */
350 while (handle) { 309 while (handle) {
351 status = acpi_run_hpx(handle, hpp); 310 status = acpi_run_hpx(handle, hpp);
352 if (ACPI_SUCCESS(status)) 311 if (ACPI_SUCCESS(status))
353 break; 312 return 0;
354 status = acpi_run_hpp(handle, hpp); 313 status = acpi_run_hpp(handle, hpp);
355 if (ACPI_SUCCESS(status)) 314 if (ACPI_SUCCESS(status))
356 break; 315 return 0;
357 if (acpi_is_root_bridge(handle)) 316 if (acpi_is_root_bridge(handle))
358 break; 317 break;
359 status = acpi_get_parent(handle, &phandle); 318 status = acpi_get_parent(handle, &phandle);
@@ -361,9 +320,9 @@ acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus,
361 break; 320 break;
362 handle = phandle; 321 handle = phandle;
363 } 322 }
364 return status; 323 return -ENODEV;
365} 324}
366EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware); 325EXPORT_SYMBOL_GPL(pci_get_hp_params);
367 326
368/** 327/**
369 * acpi_get_hp_hw_control_from_firmware 328 * acpi_get_hp_hw_control_from_firmware
@@ -500,18 +459,18 @@ check_hotplug(acpi_handle handle, u32 lvl, void *context, void **rv)
500 459
501/** 460/**
502 * acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots 461 * acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots
503 * @pbus - PCI bus to scan 462 * @handle - handle of the PCI bus to scan
504 * 463 *
505 * Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise. 464 * Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise.
506 */ 465 */
507int acpi_pci_detect_ejectable(struct pci_bus *pbus) 466int acpi_pci_detect_ejectable(acpi_handle handle)
508{ 467{
509 acpi_handle handle;
510 int found = 0; 468 int found = 0;
511 469
512 if (!(handle = acpi_pci_get_bridge_handle(pbus))) 470 if (!handle)
513 return 0; 471 return found;
514 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 472
473 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
515 check_hotplug, (void *)&found, NULL); 474 check_hotplug, (void *)&found, NULL);
516 return found; 475 return found;
517} 476}
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index e68d5f20ffb3..7d938df79206 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -91,9 +91,6 @@ struct acpiphp_bridge {
91 /* PCI-to-PCI bridge device */ 91 /* PCI-to-PCI bridge device */
92 struct pci_dev *pci_dev; 92 struct pci_dev *pci_dev;
93 93
94 /* ACPI 2.0 _HPP parameters */
95 struct hotplug_params hpp;
96
97 spinlock_t res_lock; 94 spinlock_t res_lock;
98}; 95};
99 96
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 0cb0f830a993..58d25a163a8b 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -59,7 +59,7 @@ static DEFINE_SPINLOCK(ioapic_list_lock);
59 59
60static void handle_hotplug_event_bridge (acpi_handle, u32, void *); 60static void handle_hotplug_event_bridge (acpi_handle, u32, void *);
61static void acpiphp_sanitize_bus(struct pci_bus *bus); 61static void acpiphp_sanitize_bus(struct pci_bus *bus);
62static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); 62static void acpiphp_set_hpp_values(struct pci_bus *bus);
63static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); 63static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
64 64
65/* callback routine to check for the existence of a pci dock device */ 65/* callback routine to check for the existence of a pci dock device */
@@ -261,51 +261,21 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
261 261
262 262
263/* see if it's worth looking at this bridge */ 263/* see if it's worth looking at this bridge */
264static int detect_ejectable_slots(struct pci_bus *pbus) 264static int detect_ejectable_slots(acpi_handle handle)
265{ 265{
266 int found = acpi_pci_detect_ejectable(pbus); 266 int found = acpi_pci_detect_ejectable(handle);
267 if (!found) { 267 if (!found) {
268 acpi_handle bridge_handle = acpi_pci_get_bridge_handle(pbus); 268 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
269 if (!bridge_handle)
270 return 0;
271 acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
272 is_pci_dock_device, (void *)&found, NULL); 269 is_pci_dock_device, (void *)&found, NULL);
273 } 270 }
274 return found; 271 return found;
275} 272}
276 273
277
278/* decode ACPI 2.0 _HPP hot plug parameters */
279static void decode_hpp(struct acpiphp_bridge *bridge)
280{
281 acpi_status status;
282
283 status = acpi_get_hp_params_from_firmware(bridge->pci_bus, &bridge->hpp);
284 if (ACPI_FAILURE(status) ||
285 !bridge->hpp.t0 || (bridge->hpp.t0->revision > 1)) {
286 /* use default numbers */
287 printk(KERN_WARNING
288 "%s: Could not get hotplug parameters. Use defaults\n",
289 __func__);
290 bridge->hpp.t0 = &bridge->hpp.type0_data;
291 bridge->hpp.t0->revision = 0;
292 bridge->hpp.t0->cache_line_size = 0x10;
293 bridge->hpp.t0->latency_timer = 0x40;
294 bridge->hpp.t0->enable_serr = 0;
295 bridge->hpp.t0->enable_perr = 0;
296 }
297}
298
299
300
301/* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ 274/* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */
302static void init_bridge_misc(struct acpiphp_bridge *bridge) 275static void init_bridge_misc(struct acpiphp_bridge *bridge)
303{ 276{
304 acpi_status status; 277 acpi_status status;
305 278
306 /* decode ACPI 2.0 _HPP (hot plug parameters) */
307 decode_hpp(bridge);
308
309 /* must be added to the list prior to calling register_slot */ 279 /* must be added to the list prior to calling register_slot */
310 list_add(&bridge->list, &bridge_list); 280 list_add(&bridge->list, &bridge_list);
311 281
@@ -399,9 +369,10 @@ static inline void config_p2p_bridge_flags(struct acpiphp_bridge *bridge)
399 369
400 370
401/* allocate and initialize host bridge data structure */ 371/* allocate and initialize host bridge data structure */
402static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus) 372static void add_host_bridge(acpi_handle *handle)
403{ 373{
404 struct acpiphp_bridge *bridge; 374 struct acpiphp_bridge *bridge;
375 struct acpi_pci_root *root = acpi_pci_find_root(handle);
405 376
406 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 377 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
407 if (bridge == NULL) 378 if (bridge == NULL)
@@ -410,7 +381,7 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
410 bridge->type = BRIDGE_TYPE_HOST; 381 bridge->type = BRIDGE_TYPE_HOST;
411 bridge->handle = handle; 382 bridge->handle = handle;
412 383
413 bridge->pci_bus = pci_bus; 384 bridge->pci_bus = root->bus;
414 385
415 spin_lock_init(&bridge->res_lock); 386 spin_lock_init(&bridge->res_lock);
416 387
@@ -419,7 +390,7 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
419 390
420 391
421/* allocate and initialize PCI-to-PCI bridge data structure */ 392/* allocate and initialize PCI-to-PCI bridge data structure */
422static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev) 393static void add_p2p_bridge(acpi_handle *handle)
423{ 394{
424 struct acpiphp_bridge *bridge; 395 struct acpiphp_bridge *bridge;
425 396
@@ -433,8 +404,8 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
433 bridge->handle = handle; 404 bridge->handle = handle;
434 config_p2p_bridge_flags(bridge); 405 config_p2p_bridge_flags(bridge);
435 406
436 bridge->pci_dev = pci_dev_get(pci_dev); 407 bridge->pci_dev = acpi_get_pci_dev(handle);
437 bridge->pci_bus = pci_dev->subordinate; 408 bridge->pci_bus = bridge->pci_dev->subordinate;
438 if (!bridge->pci_bus) { 409 if (!bridge->pci_bus) {
439 err("This is not a PCI-to-PCI bridge!\n"); 410 err("This is not a PCI-to-PCI bridge!\n");
440 goto err; 411 goto err;
@@ -451,7 +422,7 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
451 init_bridge_misc(bridge); 422 init_bridge_misc(bridge);
452 return; 423 return;
453 err: 424 err:
454 pci_dev_put(pci_dev); 425 pci_dev_put(bridge->pci_dev);
455 kfree(bridge); 426 kfree(bridge);
456 return; 427 return;
457} 428}
@@ -462,39 +433,21 @@ static acpi_status
462find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv) 433find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
463{ 434{
464 acpi_status status; 435 acpi_status status;
465 acpi_handle dummy_handle;
466 unsigned long long tmp;
467 int device, function;
468 struct pci_dev *dev; 436 struct pci_dev *dev;
469 struct pci_bus *pci_bus = context;
470
471 status = acpi_get_handle(handle, "_ADR", &dummy_handle);
472 if (ACPI_FAILURE(status))
473 return AE_OK; /* continue */
474
475 status = acpi_evaluate_integer(handle, "_ADR", NULL, &tmp);
476 if (ACPI_FAILURE(status)) {
477 dbg("%s: _ADR evaluation failure\n", __func__);
478 return AE_OK;
479 }
480
481 device = (tmp >> 16) & 0xffff;
482 function = tmp & 0xffff;
483
484 dev = pci_get_slot(pci_bus, PCI_DEVFN(device, function));
485 437
438 dev = acpi_get_pci_dev(handle);
486 if (!dev || !dev->subordinate) 439 if (!dev || !dev->subordinate)
487 goto out; 440 goto out;
488 441
489 /* check if this bridge has ejectable slots */ 442 /* check if this bridge has ejectable slots */
490 if ((detect_ejectable_slots(dev->subordinate) > 0)) { 443 if ((detect_ejectable_slots(handle) > 0)) {
491 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); 444 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
492 add_p2p_bridge(handle, dev); 445 add_p2p_bridge(handle);
493 } 446 }
494 447
495 /* search P2P bridges under this p2p bridge */ 448 /* search P2P bridges under this p2p bridge */
496 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 449 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
497 find_p2p_bridge, dev->subordinate, NULL); 450 find_p2p_bridge, NULL, NULL);
498 if (ACPI_FAILURE(status)) 451 if (ACPI_FAILURE(status))
499 warn("find_p2p_bridge failed (error code = 0x%x)\n", status); 452 warn("find_p2p_bridge failed (error code = 0x%x)\n", status);
500 453
@@ -509,9 +462,7 @@ static int add_bridge(acpi_handle handle)
509{ 462{
510 acpi_status status; 463 acpi_status status;
511 unsigned long long tmp; 464 unsigned long long tmp;
512 int seg, bus;
513 acpi_handle dummy_handle; 465 acpi_handle dummy_handle;
514 struct pci_bus *pci_bus;
515 466
516 /* if the bridge doesn't have _STA, we assume it is always there */ 467 /* if the bridge doesn't have _STA, we assume it is always there */
517 status = acpi_get_handle(handle, "_STA", &dummy_handle); 468 status = acpi_get_handle(handle, "_STA", &dummy_handle);
@@ -526,36 +477,15 @@ static int add_bridge(acpi_handle handle)
526 return 0; 477 return 0;
527 } 478 }
528 479
529 /* get PCI segment number */
530 status = acpi_evaluate_integer(handle, "_SEG", NULL, &tmp);
531
532 seg = ACPI_SUCCESS(status) ? tmp : 0;
533
534 /* get PCI bus number */
535 status = acpi_evaluate_integer(handle, "_BBN", NULL, &tmp);
536
537 if (ACPI_SUCCESS(status)) {
538 bus = tmp;
539 } else {
540 warn("can't get bus number, assuming 0\n");
541 bus = 0;
542 }
543
544 pci_bus = pci_find_bus(seg, bus);
545 if (!pci_bus) {
546 err("Can't find bus %04x:%02x\n", seg, bus);
547 return 0;
548 }
549
550 /* check if this bridge has ejectable slots */ 480 /* check if this bridge has ejectable slots */
551 if (detect_ejectable_slots(pci_bus) > 0) { 481 if (detect_ejectable_slots(handle) > 0) {
552 dbg("found PCI host-bus bridge with hot-pluggable slots\n"); 482 dbg("found PCI host-bus bridge with hot-pluggable slots\n");
553 add_host_bridge(handle, pci_bus); 483 add_host_bridge(handle);
554 } 484 }
555 485
556 /* search P2P bridges under this host bridge */ 486 /* search P2P bridges under this host bridge */
557 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, 487 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
558 find_p2p_bridge, pci_bus, NULL); 488 find_p2p_bridge, NULL, NULL);
559 489
560 if (ACPI_FAILURE(status)) 490 if (ACPI_FAILURE(status))
561 warn("find_p2p_bridge failed (error code = 0x%x)\n", status); 491 warn("find_p2p_bridge failed (error code = 0x%x)\n", status);
@@ -1083,7 +1013,7 @@ static int __ref enable_device(struct acpiphp_slot *slot)
1083 1013
1084 pci_bus_assign_resources(bus); 1014 pci_bus_assign_resources(bus);
1085 acpiphp_sanitize_bus(bus); 1015 acpiphp_sanitize_bus(bus);
1086 acpiphp_set_hpp_values(slot->bridge->handle, bus); 1016 acpiphp_set_hpp_values(bus);
1087 list_for_each_entry(func, &slot->funcs, sibling) 1017 list_for_each_entry(func, &slot->funcs, sibling)
1088 acpiphp_configure_ioapics(func->handle); 1018 acpiphp_configure_ioapics(func->handle);
1089 pci_enable_bridges(bus); 1019 pci_enable_bridges(bus);
@@ -1294,70 +1224,12 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
1294 return retval; 1224 return retval;
1295} 1225}
1296 1226
1297static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) 1227static void acpiphp_set_hpp_values(struct pci_bus *bus)
1298{ 1228{
1299 u16 pci_cmd, pci_bctl;
1300 struct pci_dev *cdev;
1301
1302 /* Program hpp values for this device */
1303 if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
1304 (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
1305 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
1306 return;
1307
1308 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
1309 return;
1310
1311 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
1312 bridge->hpp.t0->cache_line_size);
1313 pci_write_config_byte(dev, PCI_LATENCY_TIMER,
1314 bridge->hpp.t0->latency_timer);
1315 pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
1316 if (bridge->hpp.t0->enable_serr)
1317 pci_cmd |= PCI_COMMAND_SERR;
1318 else
1319 pci_cmd &= ~PCI_COMMAND_SERR;
1320 if (bridge->hpp.t0->enable_perr)
1321 pci_cmd |= PCI_COMMAND_PARITY;
1322 else
1323 pci_cmd &= ~PCI_COMMAND_PARITY;
1324 pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
1325
1326 /* Program bridge control value and child devices */
1327 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
1328 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
1329 bridge->hpp.t0->latency_timer);
1330 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
1331 if (bridge->hpp.t0->enable_serr)
1332 pci_bctl |= PCI_BRIDGE_CTL_SERR;
1333 else
1334 pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
1335 if (bridge->hpp.t0->enable_perr)
1336 pci_bctl |= PCI_BRIDGE_CTL_PARITY;
1337 else
1338 pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
1339 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
1340 if (dev->subordinate) {
1341 list_for_each_entry(cdev, &dev->subordinate->devices,
1342 bus_list)
1343 program_hpp(cdev, bridge);
1344 }
1345 }
1346}
1347
1348static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus)
1349{
1350 struct acpiphp_bridge bridge;
1351 struct pci_dev *dev; 1229 struct pci_dev *dev;
1352 1230
1353 memset(&bridge, 0, sizeof(bridge));
1354 bridge.handle = handle;
1355 bridge.pci_bus = bus;
1356 bridge.pci_dev = bus->self;
1357 decode_hpp(&bridge);
1358 list_for_each_entry(dev, &bus->devices, bus_list) 1231 list_for_each_entry(dev, &bus->devices, bus_list)
1359 program_hpp(dev, &bridge); 1232 pci_configure_slot(dev);
1360
1361} 1233}
1362 1234
1363/* 1235/*
@@ -1387,24 +1259,23 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
1387/* Program resources in newly inserted bridge */ 1259/* Program resources in newly inserted bridge */
1388static int acpiphp_configure_bridge (acpi_handle handle) 1260static int acpiphp_configure_bridge (acpi_handle handle)
1389{ 1261{
1390 struct pci_dev *dev;
1391 struct pci_bus *bus; 1262 struct pci_bus *bus;
1392 1263
1393 dev = acpi_get_pci_dev(handle); 1264 if (acpi_is_root_bridge(handle)) {
1394 if (!dev) { 1265 struct acpi_pci_root *root = acpi_pci_find_root(handle);
1395 err("cannot get PCI domain and bus number for bridge\n"); 1266 bus = root->bus;
1396 return -EINVAL; 1267 } else {
1268 struct pci_dev *pdev = acpi_get_pci_dev(handle);
1269 bus = pdev->subordinate;
1270 pci_dev_put(pdev);
1397 } 1271 }
1398 1272
1399 bus = dev->bus;
1400
1401 pci_bus_size_bridges(bus); 1273 pci_bus_size_bridges(bus);
1402 pci_bus_assign_resources(bus); 1274 pci_bus_assign_resources(bus);
1403 acpiphp_sanitize_bus(bus); 1275 acpiphp_sanitize_bus(bus);
1404 acpiphp_set_hpp_values(handle, bus); 1276 acpiphp_set_hpp_values(bus);
1405 pci_enable_bridges(bus); 1277 pci_enable_bridges(bus);
1406 acpiphp_configure_ioapics(handle); 1278 acpiphp_configure_ioapics(handle);
1407 pci_dev_put(dev);
1408 return 0; 1279 return 0;
1409} 1280}
1410 1281
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 5c5043f239cf..0325d989bb46 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -86,7 +86,8 @@ static char *pci_bus_speed_strings[] = {
86 "66 MHz PCIX 533", /* 0x11 */ 86 "66 MHz PCIX 533", /* 0x11 */
87 "100 MHz PCIX 533", /* 0x12 */ 87 "100 MHz PCIX 533", /* 0x12 */
88 "133 MHz PCIX 533", /* 0x13 */ 88 "133 MHz PCIX 533", /* 0x13 */
89 "25 GBps PCI-E", /* 0x14 */ 89 "2.5 GT/s PCI-E", /* 0x14 */
90 "5.0 GT/s PCI-E", /* 0x15 */
90}; 91};
91 92
92#ifdef CONFIG_HOTPLUG_PCI_CPCI 93#ifdef CONFIG_HOTPLUG_PCI_CPCI
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index e6cf096498be..36faa9a8e18f 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -237,17 +237,8 @@ static inline int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
237 return retval; 237 return retval;
238 return pciehp_acpi_slot_detection_check(dev); 238 return pciehp_acpi_slot_detection_check(dev);
239} 239}
240
241static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
242 struct hotplug_params *hpp)
243{
244 if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev->bus, hpp)))
245 return -ENODEV;
246 return 0;
247}
248#else 240#else
249#define pciehp_firmware_init() do {} while (0) 241#define pciehp_firmware_init() do {} while (0)
250#define pciehp_get_hp_hw_control_from_firmware(dev) 0 242#define pciehp_get_hp_hw_control_from_firmware(dev) 0
251#define pciehp_get_hp_params_from_firmware(dev, hpp) (-ENODEV)
252#endif /* CONFIG_ACPI */ 243#endif /* CONFIG_ACPI */
253#endif /* _PCIEHP_H */ 244#endif /* _PCIEHP_H */
diff --git a/drivers/pci/hotplug/pciehp_acpi.c b/drivers/pci/hotplug/pciehp_acpi.c
index 96048010e7d9..7163e6a6cfae 100644
--- a/drivers/pci/hotplug/pciehp_acpi.c
+++ b/drivers/pci/hotplug/pciehp_acpi.c
@@ -47,7 +47,7 @@ int pciehp_acpi_slot_detection_check(struct pci_dev *dev)
47{ 47{
48 if (slot_detection_mode != PCIEHP_DETECT_ACPI) 48 if (slot_detection_mode != PCIEHP_DETECT_ACPI)
49 return 0; 49 return 0;
50 if (acpi_pci_detect_ejectable(dev->subordinate)) 50 if (acpi_pci_detect_ejectable(DEVICE_ACPI_HANDLE(&dev->dev)))
51 return 0; 51 return 0;
52 return -ENODEV; 52 return -ENODEV;
53} 53}
@@ -76,9 +76,9 @@ static int __init dummy_probe(struct pcie_device *dev)
76{ 76{
77 int pos; 77 int pos;
78 u32 slot_cap; 78 u32 slot_cap;
79 acpi_handle handle;
79 struct slot *slot, *tmp; 80 struct slot *slot, *tmp;
80 struct pci_dev *pdev = dev->port; 81 struct pci_dev *pdev = dev->port;
81 struct pci_bus *pbus = pdev->subordinate;
82 /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */ 82 /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */
83 if (pciehp_get_hp_hw_control_from_firmware(pdev)) 83 if (pciehp_get_hp_hw_control_from_firmware(pdev))
84 return -ENODEV; 84 return -ENODEV;
@@ -94,7 +94,8 @@ static int __init dummy_probe(struct pcie_device *dev)
94 dup_slot_id++; 94 dup_slot_id++;
95 } 95 }
96 list_add_tail(&slot->slot_list, &dummy_slots); 96 list_add_tail(&slot->slot_list, &dummy_slots);
97 if (!acpi_slot_detected && acpi_pci_detect_ejectable(pbus)) 97 handle = DEVICE_ACPI_HANDLE(&pdev->dev);
98 if (!acpi_slot_detected && acpi_pci_detect_ejectable(handle))
98 acpi_slot_detected = 1; 99 acpi_slot_detected = 1;
99 return -ENODEV; /* dummy driver always returns error */ 100 return -ENODEV; /* dummy driver always returns error */
100} 101}
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 8aab8edf123e..b97cb4c3e0fe 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -246,11 +246,6 @@ static int board_added(struct slot *p_slot)
246 goto err_exit; 246 goto err_exit;
247 } 247 }
248 248
249 /*
250 * Some PCI Express root ports require fixup after hot-plug operation.
251 */
252 if (pcie_mch_quirk)
253 pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
254 if (PWR_LED(ctrl)) 249 if (PWR_LED(ctrl))
255 p_slot->hpc_ops->green_led_on(p_slot); 250 p_slot->hpc_ops->green_led_on(p_slot);
256 251
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 52813257e5bf..271f917b6f2c 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -693,7 +693,10 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
693 693
694 switch (lnk_cap & 0x000F) { 694 switch (lnk_cap & 0x000F) {
695 case 1: 695 case 1:
696 lnk_speed = PCIE_2PT5GB; 696 lnk_speed = PCIE_2_5GB;
697 break;
698 case 2:
699 lnk_speed = PCIE_5_0GB;
697 break; 700 break;
698 default: 701 default:
699 lnk_speed = PCIE_LNK_SPEED_UNKNOWN; 702 lnk_speed = PCIE_LNK_SPEED_UNKNOWN;
@@ -772,7 +775,10 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
772 775
773 switch (lnk_status & PCI_EXP_LNKSTA_CLS) { 776 switch (lnk_status & PCI_EXP_LNKSTA_CLS) {
774 case 1: 777 case 1:
775 lnk_speed = PCIE_2PT5GB; 778 lnk_speed = PCIE_2_5GB;
779 break;
780 case 2:
781 lnk_speed = PCIE_5_0GB;
776 break; 782 break;
777 default: 783 default:
778 lnk_speed = PCIE_LNK_SPEED_UNKNOWN; 784 lnk_speed = PCIE_LNK_SPEED_UNKNOWN;
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 10f9566cceeb..02e24d63b3ee 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -34,136 +34,6 @@
34#include "../pci.h" 34#include "../pci.h"
35#include "pciehp.h" 35#include "pciehp.h"
36 36
37static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp)
38{
39 u16 pci_cmd, pci_bctl;
40
41 if (hpp->revision > 1) {
42 warn("Rev.%d type0 record not supported\n", hpp->revision);
43 return;
44 }
45
46 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp->cache_line_size);
47 pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp->latency_timer);
48 pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
49 if (hpp->enable_serr)
50 pci_cmd |= PCI_COMMAND_SERR;
51 else
52 pci_cmd &= ~PCI_COMMAND_SERR;
53 if (hpp->enable_perr)
54 pci_cmd |= PCI_COMMAND_PARITY;
55 else
56 pci_cmd &= ~PCI_COMMAND_PARITY;
57 pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
58
59 /* Program bridge control value */
60 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
61 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
62 hpp->latency_timer);
63 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
64 if (hpp->enable_serr)
65 pci_bctl |= PCI_BRIDGE_CTL_SERR;
66 else
67 pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
68 if (hpp->enable_perr)
69 pci_bctl |= PCI_BRIDGE_CTL_PARITY;
70 else
71 pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
72 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
73 }
74}
75
76static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
77{
78 int pos;
79 u16 reg16;
80 u32 reg32;
81
82 if (hpp->revision > 1) {
83 warn("Rev.%d type2 record not supported\n", hpp->revision);
84 return;
85 }
86
87 /* Find PCI Express capability */
88 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
89 if (!pos)
90 return;
91
92 /* Initialize Device Control Register */
93 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16);
94 reg16 = (reg16 & hpp->pci_exp_devctl_and) | hpp->pci_exp_devctl_or;
95 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16);
96
97 /* Initialize Link Control Register */
98 if (dev->subordinate) {
99 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &reg16);
100 reg16 = (reg16 & hpp->pci_exp_lnkctl_and)
101 | hpp->pci_exp_lnkctl_or;
102 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, reg16);
103 }
104
105 /* Find Advanced Error Reporting Enhanced Capability */
106 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
107 if (!pos)
108 return;
109
110 /* Initialize Uncorrectable Error Mask Register */
111 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &reg32);
112 reg32 = (reg32 & hpp->unc_err_mask_and) | hpp->unc_err_mask_or;
113 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, reg32);
114
115 /* Initialize Uncorrectable Error Severity Register */
116 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &reg32);
117 reg32 = (reg32 & hpp->unc_err_sever_and) | hpp->unc_err_sever_or;
118 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, reg32);
119
120 /* Initialize Correctable Error Mask Register */
121 pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &reg32);
122 reg32 = (reg32 & hpp->cor_err_mask_and) | hpp->cor_err_mask_or;
123 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg32);
124
125 /* Initialize Advanced Error Capabilities and Control Register */
126 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
127 reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or;
128 pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
129
130 /*
131 * FIXME: The following two registers are not supported yet.
132 *
133 * o Secondary Uncorrectable Error Severity Register
134 * o Secondary Uncorrectable Error Mask Register
135 */
136}
137
138static void program_fw_provided_values(struct pci_dev *dev)
139{
140 struct pci_dev *cdev;
141 struct hotplug_params hpp;
142
143 /* Program hpp values for this device */
144 if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
145 (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
146 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
147 return;
148
149 if (pciehp_get_hp_params_from_firmware(dev, &hpp)) {
150 warn("Could not get hotplug parameters\n");
151 return;
152 }
153
154 if (hpp.t2)
155 program_hpp_type2(dev, hpp.t2);
156 if (hpp.t0)
157 program_hpp_type0(dev, hpp.t0);
158
159 /* Program child devices */
160 if (dev->subordinate) {
161 list_for_each_entry(cdev, &dev->subordinate->devices,
162 bus_list)
163 program_fw_provided_values(cdev);
164 }
165}
166
167static int __ref pciehp_add_bridge(struct pci_dev *dev) 37static int __ref pciehp_add_bridge(struct pci_dev *dev)
168{ 38{
169 struct pci_bus *parent = dev->bus; 39 struct pci_bus *parent = dev->bus;
@@ -226,7 +96,7 @@ int pciehp_configure_device(struct slot *p_slot)
226 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) { 96 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) {
227 pciehp_add_bridge(dev); 97 pciehp_add_bridge(dev);
228 } 98 }
229 program_fw_provided_values(dev); 99 pci_configure_slot(dev);
230 pci_dev_put(dev); 100 pci_dev_put(dev);
231 } 101 }
232 102
@@ -285,11 +155,6 @@ int pciehp_unconfigure_device(struct slot *p_slot)
285 } 155 }
286 pci_dev_put(temp); 156 pci_dev_put(temp);
287 } 157 }
288 /*
289 * Some PCI Express root ports require fixup after hot-plug operation.
290 */
291 if (pcie_mch_quirk)
292 pci_fixup_device(pci_fixup_final, p_slot->ctrl->pci_dev);
293 158
294 return rc; 159 return rc;
295} 160}
diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c
new file mode 100644
index 000000000000..cc8ec3aa41a7
--- /dev/null
+++ b/drivers/pci/hotplug/pcihp_slot.c
@@ -0,0 +1,187 @@
1/*
2 * Copyright (C) 1995,2001 Compaq Computer Corporation
3 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
4 * Copyright (C) 2001 IBM Corp.
5 * Copyright (C) 2003-2004 Intel Corporation
6 * (c) Copyright 2009 Hewlett-Packard Development Company, L.P.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#include <linux/pci.h>
27#include <linux/pci_hotplug.h>
28
29static struct hpp_type0 pci_default_type0 = {
30 .revision = 1,
31 .cache_line_size = 8,
32 .latency_timer = 0x40,
33 .enable_serr = 0,
34 .enable_perr = 0,
35};
36
37static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp)
38{
39 u16 pci_cmd, pci_bctl;
40
41 if (!hpp) {
42 /*
43 * Perhaps we *should* use default settings for PCIe, but
44 * pciehp didn't, so we won't either.
45 */
46 if (dev->is_pcie)
47 return;
48 dev_info(&dev->dev, "using default PCI settings\n");
49 hpp = &pci_default_type0;
50 }
51
52 if (hpp->revision > 1) {
53 dev_warn(&dev->dev,
54 "PCI settings rev %d not supported; using defaults\n",
55 hpp->revision);
56 hpp = &pci_default_type0;
57 }
58
59 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp->cache_line_size);
60 pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp->latency_timer);
61 pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
62 if (hpp->enable_serr)
63 pci_cmd |= PCI_COMMAND_SERR;
64 else
65 pci_cmd &= ~PCI_COMMAND_SERR;
66 if (hpp->enable_perr)
67 pci_cmd |= PCI_COMMAND_PARITY;
68 else
69 pci_cmd &= ~PCI_COMMAND_PARITY;
70 pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
71
72 /* Program bridge control value */
73 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
74 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
75 hpp->latency_timer);
76 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
77 if (hpp->enable_serr)
78 pci_bctl |= PCI_BRIDGE_CTL_SERR;
79 else
80 pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
81 if (hpp->enable_perr)
82 pci_bctl |= PCI_BRIDGE_CTL_PARITY;
83 else
84 pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
85 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
86 }
87}
88
89static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp)
90{
91 if (hpp)
92 dev_warn(&dev->dev, "PCI-X settings not supported\n");
93}
94
95static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
96{
97 int pos;
98 u16 reg16;
99 u32 reg32;
100
101 if (!hpp)
102 return;
103
104 /* Find PCI Express capability */
105 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
106 if (!pos)
107 return;
108
109 if (hpp->revision > 1) {
110 dev_warn(&dev->dev, "PCIe settings rev %d not supported\n",
111 hpp->revision);
112 return;
113 }
114
115 /* Initialize Device Control Register */
116 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &reg16);
117 reg16 = (reg16 & hpp->pci_exp_devctl_and) | hpp->pci_exp_devctl_or;
118 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16);
119
120 /* Initialize Link Control Register */
121 if (dev->subordinate) {
122 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &reg16);
123 reg16 = (reg16 & hpp->pci_exp_lnkctl_and)
124 | hpp->pci_exp_lnkctl_or;
125 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, reg16);
126 }
127
128 /* Find Advanced Error Reporting Enhanced Capability */
129 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
130 if (!pos)
131 return;
132
133 /* Initialize Uncorrectable Error Mask Register */
134 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &reg32);
135 reg32 = (reg32 & hpp->unc_err_mask_and) | hpp->unc_err_mask_or;
136 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, reg32);
137
138 /* Initialize Uncorrectable Error Severity Register */
139 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &reg32);
140 reg32 = (reg32 & hpp->unc_err_sever_and) | hpp->unc_err_sever_or;
141 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, reg32);
142
143 /* Initialize Correctable Error Mask Register */
144 pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &reg32);
145 reg32 = (reg32 & hpp->cor_err_mask_and) | hpp->cor_err_mask_or;
146 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg32);
147
148 /* Initialize Advanced Error Capabilities and Control Register */
149 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
150 reg32 = (reg32 & hpp->adv_err_cap_and) | hpp->adv_err_cap_or;
151 pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
152
153 /*
154 * FIXME: The following two registers are not supported yet.
155 *
156 * o Secondary Uncorrectable Error Severity Register
157 * o Secondary Uncorrectable Error Mask Register
158 */
159}
160
161void pci_configure_slot(struct pci_dev *dev)
162{
163 struct pci_dev *cdev;
164 struct hotplug_params hpp;
165 int ret;
166
167 if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
168 (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
169 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
170 return;
171
172 memset(&hpp, 0, sizeof(hpp));
173 ret = pci_get_hp_params(dev, &hpp);
174 if (ret)
175 dev_warn(&dev->dev, "no hotplug settings from platform\n");
176
177 program_hpp_type2(dev, hpp.t2);
178 program_hpp_type1(dev, hpp.t1);
179 program_hpp_type0(dev, hpp.t0);
180
181 if (dev->subordinate) {
182 list_for_each_entry(cdev, &dev->subordinate->devices,
183 bus_list)
184 pci_configure_slot(cdev);
185 }
186}
187EXPORT_SYMBOL_GPL(pci_configure_slot);
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 974e924ca96d..bd588eb8e922 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -188,21 +188,12 @@ static inline const char *slot_name(struct slot *slot)
188 188
189#ifdef CONFIG_ACPI 189#ifdef CONFIG_ACPI
190#include <linux/pci-acpi.h> 190#include <linux/pci-acpi.h>
191static inline int get_hp_params_from_firmware(struct pci_dev *dev,
192 struct hotplug_params *hpp)
193{
194 if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev->bus, hpp)))
195 return -ENODEV;
196 return 0;
197}
198
199static inline int get_hp_hw_control_from_firmware(struct pci_dev *dev) 191static inline int get_hp_hw_control_from_firmware(struct pci_dev *dev)
200{ 192{
201 u32 flags = OSC_SHPC_NATIVE_HP_CONTROL; 193 u32 flags = OSC_SHPC_NATIVE_HP_CONTROL;
202 return acpi_get_hp_hw_control_from_firmware(dev, flags); 194 return acpi_get_hp_hw_control_from_firmware(dev, flags);
203} 195}
204#else 196#else
205#define get_hp_params_from_firmware(dev, hpp) (-ENODEV)
206#define get_hp_hw_control_from_firmware(dev) (0) 197#define get_hp_hw_control_from_firmware(dev) (0)
207#endif 198#endif
208 199
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index aa315e52529b..8c3d3219f227 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -34,66 +34,6 @@
34#include "../pci.h" 34#include "../pci.h"
35#include "shpchp.h" 35#include "shpchp.h"
36 36
37static void program_fw_provided_values(struct pci_dev *dev)
38{
39 u16 pci_cmd, pci_bctl;
40 struct pci_dev *cdev;
41 struct hotplug_params hpp;
42
43 /* Program hpp values for this device */
44 if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
45 (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
46 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
47 return;
48
49 /* use default values if we can't get them from firmware */
50 if (get_hp_params_from_firmware(dev, &hpp) ||
51 !hpp.t0 || (hpp.t0->revision > 1)) {
52 warn("Could not get hotplug parameters. Use defaults\n");
53 hpp.t0 = &hpp.type0_data;
54 hpp.t0->revision = 0;
55 hpp.t0->cache_line_size = 8;
56 hpp.t0->latency_timer = 0x40;
57 hpp.t0->enable_serr = 0;
58 hpp.t0->enable_perr = 0;
59 }
60
61 pci_write_config_byte(dev,
62 PCI_CACHE_LINE_SIZE, hpp.t0->cache_line_size);
63 pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.t0->latency_timer);
64 pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
65 if (hpp.t0->enable_serr)
66 pci_cmd |= PCI_COMMAND_SERR;
67 else
68 pci_cmd &= ~PCI_COMMAND_SERR;
69 if (hpp.t0->enable_perr)
70 pci_cmd |= PCI_COMMAND_PARITY;
71 else
72 pci_cmd &= ~PCI_COMMAND_PARITY;
73 pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
74
75 /* Program bridge control value and child devices */
76 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
77 pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
78 hpp.t0->latency_timer);
79 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
80 if (hpp.t0->enable_serr)
81 pci_bctl |= PCI_BRIDGE_CTL_SERR;
82 else
83 pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
84 if (hpp.t0->enable_perr)
85 pci_bctl |= PCI_BRIDGE_CTL_PARITY;
86 else
87 pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
88 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
89 if (dev->subordinate) {
90 list_for_each_entry(cdev, &dev->subordinate->devices,
91 bus_list)
92 program_fw_provided_values(cdev);
93 }
94 }
95}
96
97int __ref shpchp_configure_device(struct slot *p_slot) 37int __ref shpchp_configure_device(struct slot *p_slot)
98{ 38{
99 struct pci_dev *dev; 39 struct pci_dev *dev;
@@ -153,7 +93,7 @@ int __ref shpchp_configure_device(struct slot *p_slot)
153 child->subordinate = pci_do_scan_bus(child); 93 child->subordinate = pci_do_scan_bus(child);
154 pci_bus_size_bridges(child); 94 pci_bus_size_bridges(child);
155 } 95 }
156 program_fw_provided_values(dev); 96 pci_configure_slot(dev);
157 pci_dev_put(dev); 97 pci_dev_put(dev);
158 } 98 }
159 99
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 2314ad7ee5fe..562221e11917 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -37,6 +37,7 @@
37#include <linux/iommu.h> 37#include <linux/iommu.h>
38#include <linux/intel-iommu.h> 38#include <linux/intel-iommu.h>
39#include <linux/sysdev.h> 39#include <linux/sysdev.h>
40#include <linux/tboot.h>
40#include <asm/cacheflush.h> 41#include <asm/cacheflush.h>
41#include <asm/iommu.h> 42#include <asm/iommu.h>
42#include "pci.h" 43#include "pci.h"
@@ -3183,12 +3184,22 @@ static int __init init_iommu_sysfs(void)
3183int __init intel_iommu_init(void) 3184int __init intel_iommu_init(void)
3184{ 3185{
3185 int ret = 0; 3186 int ret = 0;
3187 int force_on = 0;
3186 3188
3187 if (dmar_table_init()) 3189 /* VT-d is required for a TXT/tboot launch, so enforce that */
3190 force_on = tboot_force_iommu();
3191
3192 if (dmar_table_init()) {
3193 if (force_on)
3194 panic("tboot: Failed to initialize DMAR table\n");
3188 return -ENODEV; 3195 return -ENODEV;
3196 }
3189 3197
3190 if (dmar_dev_scope_init()) 3198 if (dmar_dev_scope_init()) {
3199 if (force_on)
3200 panic("tboot: Failed to initialize DMAR device scope\n");
3191 return -ENODEV; 3201 return -ENODEV;
3202 }
3192 3203
3193 /* 3204 /*
3194 * Check the need for DMA-remapping initialization now. 3205 * Check the need for DMA-remapping initialization now.
@@ -3204,6 +3215,8 @@ int __init intel_iommu_init(void)
3204 3215
3205 ret = init_dmars(); 3216 ret = init_dmars();
3206 if (ret) { 3217 if (ret) {
3218 if (force_on)
3219 panic("tboot: Failed to initialize DMARs\n");
3207 printk(KERN_ERR "IOMMU: dmar init failed\n"); 3220 printk(KERN_ERR "IOMMU: dmar init failed\n");
3208 put_iova_domain(&reserved_iova_list); 3221 put_iova_domain(&reserved_iova_list);
3209 iommu_exit_mempool(); 3222 iommu_exit_mempool();
diff --git a/drivers/pci/legacy.c b/drivers/pci/legacy.c
new file mode 100644
index 000000000000..871f65c15936
--- /dev/null
+++ b/drivers/pci/legacy.c
@@ -0,0 +1,34 @@
1#include <linux/init.h>
2#include <linux/pci.h>
3#include <linux/module.h>
4#include <linux/interrupt.h>
5#include "pci.h"
6
7/**
8 * pci_find_device - begin or continue searching for a PCI device by vendor/device id
9 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
10 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
11 * @from: Previous PCI device found in search, or %NULL for new search.
12 *
13 * Iterates through the list of known PCI devices. If a PCI device is found
14 * with a matching @vendor and @device, a pointer to its device structure is
15 * returned. Otherwise, %NULL is returned.
16 * A new search is initiated by passing %NULL as the @from argument.
17 * Otherwise if @from is not %NULL, searches continue from next device
18 * on the global list.
19 *
20 * NOTE: Do not use this function any more; use pci_get_device() instead, as
21 * the PCI device returned by this function can disappear at any moment in
22 * time.
23 */
24struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device,
25 struct pci_dev *from)
26{
27 struct pci_dev *pdev;
28
29 pci_dev_get(from);
30 pdev = pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);
31 pci_dev_put(pdev);
32 return pdev;
33}
34EXPORT_SYMBOL(pci_find_device);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index d986afb7032b..f9cf3173b23d 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -16,9 +16,8 @@
16#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
17#include <linux/msi.h> 17#include <linux/msi.h>
18#include <linux/smp.h> 18#include <linux/smp.h>
19 19#include <linux/errno.h>
20#include <asm/errno.h> 20#include <linux/io.h>
21#include <asm/io.h>
22 21
23#include "pci.h" 22#include "pci.h"
24#include "msi.h" 23#include "msi.h"
@@ -272,7 +271,30 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg)
272 write_msi_msg_desc(desc, msg); 271 write_msi_msg_desc(desc, msg);
273} 272}
274 273
275static int msi_free_irqs(struct pci_dev* dev); 274static void free_msi_irqs(struct pci_dev *dev)
275{
276 struct msi_desc *entry, *tmp;
277
278 list_for_each_entry(entry, &dev->msi_list, list) {
279 int i, nvec;
280 if (!entry->irq)
281 continue;
282 nvec = 1 << entry->msi_attrib.multiple;
283 for (i = 0; i < nvec; i++)
284 BUG_ON(irq_has_action(entry->irq + i));
285 }
286
287 arch_teardown_msi_irqs(dev);
288
289 list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
290 if (entry->msi_attrib.is_msix) {
291 if (list_is_last(&entry->list, &dev->msi_list))
292 iounmap(entry->mask_base);
293 }
294 list_del(&entry->list);
295 kfree(entry);
296 }
297}
276 298
277static struct msi_desc *alloc_msi_entry(struct pci_dev *dev) 299static struct msi_desc *alloc_msi_entry(struct pci_dev *dev)
278{ 300{
@@ -324,7 +346,7 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
324 if (!dev->msix_enabled) 346 if (!dev->msix_enabled)
325 return; 347 return;
326 BUG_ON(list_empty(&dev->msi_list)); 348 BUG_ON(list_empty(&dev->msi_list));
327 entry = list_entry(dev->msi_list.next, struct msi_desc, list); 349 entry = list_first_entry(&dev->msi_list, struct msi_desc, list);
328 pos = entry->msi_attrib.pos; 350 pos = entry->msi_attrib.pos;
329 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control); 351 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control);
330 352
@@ -367,7 +389,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
367 u16 control; 389 u16 control;
368 unsigned mask; 390 unsigned mask;
369 391
370 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 392 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
371 msi_set_enable(dev, pos, 0); /* Disable MSI during set up */ 393 msi_set_enable(dev, pos, 0); /* Disable MSI during set up */
372 394
373 pci_read_config_word(dev, msi_control_reg(pos), &control); 395 pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -376,12 +398,12 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
376 if (!entry) 398 if (!entry)
377 return -ENOMEM; 399 return -ENOMEM;
378 400
379 entry->msi_attrib.is_msix = 0; 401 entry->msi_attrib.is_msix = 0;
380 entry->msi_attrib.is_64 = is_64bit_address(control); 402 entry->msi_attrib.is_64 = is_64bit_address(control);
381 entry->msi_attrib.entry_nr = 0; 403 entry->msi_attrib.entry_nr = 0;
382 entry->msi_attrib.maskbit = is_mask_bit_support(control); 404 entry->msi_attrib.maskbit = is_mask_bit_support(control);
383 entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ 405 entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */
384 entry->msi_attrib.pos = pos; 406 entry->msi_attrib.pos = pos;
385 407
386 entry->mask_pos = msi_mask_reg(pos, entry->msi_attrib.is_64); 408 entry->mask_pos = msi_mask_reg(pos, entry->msi_attrib.is_64);
387 /* All MSIs are unmasked by default, Mask them all */ 409 /* All MSIs are unmasked by default, Mask them all */
@@ -396,7 +418,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
396 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI); 418 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
397 if (ret) { 419 if (ret) {
398 msi_mask_irq(entry, mask, ~mask); 420 msi_mask_irq(entry, mask, ~mask);
399 msi_free_irqs(dev); 421 free_msi_irqs(dev);
400 return ret; 422 return ret;
401 } 423 }
402 424
@@ -409,44 +431,27 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
409 return 0; 431 return 0;
410} 432}
411 433
412/** 434static void __iomem *msix_map_region(struct pci_dev *dev, unsigned pos,
413 * msix_capability_init - configure device's MSI-X capability 435 unsigned nr_entries)
414 * @dev: pointer to the pci_dev data structure of MSI-X device function
415 * @entries: pointer to an array of struct msix_entry entries
416 * @nvec: number of @entries
417 *
418 * Setup the MSI-X capability structure of device function with a
419 * single MSI-X irq. A return of zero indicates the successful setup of
420 * requested MSI-X entries with allocated irqs or non-zero for otherwise.
421 **/
422static int msix_capability_init(struct pci_dev *dev,
423 struct msix_entry *entries, int nvec)
424{ 436{
425 struct msi_desc *entry;
426 int pos, i, j, nr_entries, ret;
427 unsigned long phys_addr; 437 unsigned long phys_addr;
428 u32 table_offset; 438 u32 table_offset;
429 u16 control;
430 u8 bir; 439 u8 bir;
431 void __iomem *base;
432 440
433 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); 441 pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset);
434 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control);
435
436 /* Ensure MSI-X is disabled while it is set up */
437 control &= ~PCI_MSIX_FLAGS_ENABLE;
438 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
439
440 /* Request & Map MSI-X table region */
441 nr_entries = multi_msix_capable(control);
442
443 pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset);
444 bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK); 442 bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
445 table_offset &= ~PCI_MSIX_FLAGS_BIRMASK; 443 table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
446 phys_addr = pci_resource_start (dev, bir) + table_offset; 444 phys_addr = pci_resource_start(dev, bir) + table_offset;
447 base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE); 445
448 if (base == NULL) 446 return ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
449 return -ENOMEM; 447}
448
449static int msix_setup_entries(struct pci_dev *dev, unsigned pos,
450 void __iomem *base, struct msix_entry *entries,
451 int nvec)
452{
453 struct msi_desc *entry;
454 int i;
450 455
451 for (i = 0; i < nvec; i++) { 456 for (i = 0; i < nvec; i++) {
452 entry = alloc_msi_entry(dev); 457 entry = alloc_msi_entry(dev);
@@ -454,41 +459,78 @@ static int msix_capability_init(struct pci_dev *dev,
454 if (!i) 459 if (!i)
455 iounmap(base); 460 iounmap(base);
456 else 461 else
457 msi_free_irqs(dev); 462 free_msi_irqs(dev);
458 /* No enough memory. Don't try again */ 463 /* No enough memory. Don't try again */
459 return -ENOMEM; 464 return -ENOMEM;
460 } 465 }
461 466
462 j = entries[i].entry; 467 entry->msi_attrib.is_msix = 1;
463 entry->msi_attrib.is_msix = 1; 468 entry->msi_attrib.is_64 = 1;
464 entry->msi_attrib.is_64 = 1; 469 entry->msi_attrib.entry_nr = entries[i].entry;
465 entry->msi_attrib.entry_nr = j; 470 entry->msi_attrib.default_irq = dev->irq;
466 entry->msi_attrib.default_irq = dev->irq; 471 entry->msi_attrib.pos = pos;
467 entry->msi_attrib.pos = pos; 472 entry->mask_base = base;
468 entry->mask_base = base;
469 473
470 list_add_tail(&entry->list, &dev->msi_list); 474 list_add_tail(&entry->list, &dev->msi_list);
471 } 475 }
472 476
473 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); 477 return 0;
474 if (ret < 0) { 478}
475 /* If we had some success report the number of irqs
476 * we succeeded in setting up. */
477 int avail = 0;
478 list_for_each_entry(entry, &dev->msi_list, list) {
479 if (entry->irq != 0) {
480 avail++;
481 }
482 }
483 479
484 if (avail != 0) 480static void msix_program_entries(struct pci_dev *dev,
485 ret = avail; 481 struct msix_entry *entries)
482{
483 struct msi_desc *entry;
484 int i = 0;
485
486 list_for_each_entry(entry, &dev->msi_list, list) {
487 int offset = entries[i].entry * PCI_MSIX_ENTRY_SIZE +
488 PCI_MSIX_ENTRY_VECTOR_CTRL;
489
490 entries[i].vector = entry->irq;
491 set_irq_msi(entry->irq, entry);
492 entry->masked = readl(entry->mask_base + offset);
493 msix_mask_irq(entry, 1);
494 i++;
486 } 495 }
496}
487 497
488 if (ret) { 498/**
489 msi_free_irqs(dev); 499 * msix_capability_init - configure device's MSI-X capability
500 * @dev: pointer to the pci_dev data structure of MSI-X device function
501 * @entries: pointer to an array of struct msix_entry entries
502 * @nvec: number of @entries
503 *
504 * Setup the MSI-X capability structure of device function with a
505 * single MSI-X irq. A return of zero indicates the successful setup of
506 * requested MSI-X entries with allocated irqs or non-zero for otherwise.
507 **/
508static int msix_capability_init(struct pci_dev *dev,
509 struct msix_entry *entries, int nvec)
510{
511 int pos, ret;
512 u16 control;
513 void __iomem *base;
514
515 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
516 pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control);
517
518 /* Ensure MSI-X is disabled while it is set up */
519 control &= ~PCI_MSIX_FLAGS_ENABLE;
520 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
521
522 /* Request & Map MSI-X table region */
523 base = msix_map_region(dev, pos, multi_msix_capable(control));
524 if (!base)
525 return -ENOMEM;
526
527 ret = msix_setup_entries(dev, pos, base, entries, nvec);
528 if (ret)
490 return ret; 529 return ret;
491 } 530
531 ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
532 if (ret)
533 goto error;
492 534
493 /* 535 /*
494 * Some devices require MSI-X to be enabled before we can touch the 536 * Some devices require MSI-X to be enabled before we can touch the
@@ -498,16 +540,7 @@ static int msix_capability_init(struct pci_dev *dev,
498 control |= PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE; 540 control |= PCI_MSIX_FLAGS_MASKALL | PCI_MSIX_FLAGS_ENABLE;
499 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); 541 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
500 542
501 i = 0; 543 msix_program_entries(dev, entries);
502 list_for_each_entry(entry, &dev->msi_list, list) {
503 entries[i].vector = entry->irq;
504 set_irq_msi(entry->irq, entry);
505 j = entries[i].entry;
506 entry->masked = readl(base + j * PCI_MSIX_ENTRY_SIZE +
507 PCI_MSIX_ENTRY_VECTOR_CTRL);
508 msix_mask_irq(entry, 1);
509 i++;
510 }
511 544
512 /* Set MSI-X enabled bits and unmask the function */ 545 /* Set MSI-X enabled bits and unmask the function */
513 pci_intx_for_msi(dev, 0); 546 pci_intx_for_msi(dev, 0);
@@ -517,6 +550,27 @@ static int msix_capability_init(struct pci_dev *dev,
517 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); 550 pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
518 551
519 return 0; 552 return 0;
553
554error:
555 if (ret < 0) {
556 /*
557 * If we had some success, report the number of irqs
558 * we succeeded in setting up.
559 */
560 struct msi_desc *entry;
561 int avail = 0;
562
563 list_for_each_entry(entry, &dev->msi_list, list) {
564 if (entry->irq != 0)
565 avail++;
566 }
567 if (avail != 0)
568 ret = avail;
569 }
570
571 free_msi_irqs(dev);
572
573 return ret;
520} 574}
521 575
522/** 576/**
@@ -529,7 +583,7 @@ static int msix_capability_init(struct pci_dev *dev,
529 * to determine if MSI/-X are supported for the device. If MSI/-X is 583 * to determine if MSI/-X are supported for the device. If MSI/-X is
530 * supported return 0, else return an error code. 584 * supported return 0, else return an error code.
531 **/ 585 **/
532static int pci_msi_check_device(struct pci_dev* dev, int nvec, int type) 586static int pci_msi_check_device(struct pci_dev *dev, int nvec, int type)
533{ 587{
534 struct pci_bus *bus; 588 struct pci_bus *bus;
535 int ret; 589 int ret;
@@ -546,8 +600,9 @@ static int pci_msi_check_device(struct pci_dev* dev, int nvec, int type)
546 if (nvec < 1) 600 if (nvec < 1)
547 return -ERANGE; 601 return -ERANGE;
548 602
549 /* Any bridge which does NOT route MSI transactions from it's 603 /*
550 * secondary bus to it's primary bus must set NO_MSI flag on 604 * Any bridge which does NOT route MSI transactions from its
605 * secondary bus to its primary bus must set NO_MSI flag on
551 * the secondary pci_bus. 606 * the secondary pci_bus.
552 * We expect only arch-specific PCI host bus controller driver 607 * We expect only arch-specific PCI host bus controller driver
553 * or quirks for specific PCI bridges to be setting NO_MSI. 608 * or quirks for specific PCI bridges to be setting NO_MSI.
@@ -638,50 +693,16 @@ void pci_msi_shutdown(struct pci_dev *dev)
638 dev->irq = desc->msi_attrib.default_irq; 693 dev->irq = desc->msi_attrib.default_irq;
639} 694}
640 695
641void pci_disable_msi(struct pci_dev* dev) 696void pci_disable_msi(struct pci_dev *dev)
642{ 697{
643 struct msi_desc *entry;
644
645 if (!pci_msi_enable || !dev || !dev->msi_enabled) 698 if (!pci_msi_enable || !dev || !dev->msi_enabled)
646 return; 699 return;
647 700
648 pci_msi_shutdown(dev); 701 pci_msi_shutdown(dev);
649 702 free_msi_irqs(dev);
650 entry = list_entry(dev->msi_list.next, struct msi_desc, list);
651 if (entry->msi_attrib.is_msix)
652 return;
653
654 msi_free_irqs(dev);
655} 703}
656EXPORT_SYMBOL(pci_disable_msi); 704EXPORT_SYMBOL(pci_disable_msi);
657 705
658static int msi_free_irqs(struct pci_dev* dev)
659{
660 struct msi_desc *entry, *tmp;
661
662 list_for_each_entry(entry, &dev->msi_list, list) {
663 int i, nvec;
664 if (!entry->irq)
665 continue;
666 nvec = 1 << entry->msi_attrib.multiple;
667 for (i = 0; i < nvec; i++)
668 BUG_ON(irq_has_action(entry->irq + i));
669 }
670
671 arch_teardown_msi_irqs(dev);
672
673 list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
674 if (entry->msi_attrib.is_msix) {
675 if (list_is_last(&entry->list, &dev->msi_list))
676 iounmap(entry->mask_base);
677 }
678 list_del(&entry->list);
679 kfree(entry);
680 }
681
682 return 0;
683}
684
685/** 706/**
686 * pci_msix_table_size - return the number of device's MSI-X table entries 707 * pci_msix_table_size - return the number of device's MSI-X table entries
687 * @dev: pointer to the pci_dev data structure of MSI-X device function 708 * @dev: pointer to the pci_dev data structure of MSI-X device function
@@ -714,13 +735,13 @@ int pci_msix_table_size(struct pci_dev *dev)
714 * of irqs or MSI-X vectors available. Driver should use the returned value to 735 * of irqs or MSI-X vectors available. Driver should use the returned value to
715 * re-send its request. 736 * re-send its request.
716 **/ 737 **/
717int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) 738int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
718{ 739{
719 int status, nr_entries; 740 int status, nr_entries;
720 int i, j; 741 int i, j;
721 742
722 if (!entries) 743 if (!entries)
723 return -EINVAL; 744 return -EINVAL;
724 745
725 status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX); 746 status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX);
726 if (status) 747 if (status)
@@ -742,7 +763,7 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
742 WARN_ON(!!dev->msix_enabled); 763 WARN_ON(!!dev->msix_enabled);
743 764
744 /* Check whether driver already requested for MSI irq */ 765 /* Check whether driver already requested for MSI irq */
745 if (dev->msi_enabled) { 766 if (dev->msi_enabled) {
746 dev_info(&dev->dev, "can't enable MSI-X " 767 dev_info(&dev->dev, "can't enable MSI-X "
747 "(MSI IRQ already assigned)\n"); 768 "(MSI IRQ already assigned)\n");
748 return -EINVAL; 769 return -EINVAL;
@@ -752,12 +773,7 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
752} 773}
753EXPORT_SYMBOL(pci_enable_msix); 774EXPORT_SYMBOL(pci_enable_msix);
754 775
755static void msix_free_all_irqs(struct pci_dev *dev) 776void pci_msix_shutdown(struct pci_dev *dev)
756{
757 msi_free_irqs(dev);
758}
759
760void pci_msix_shutdown(struct pci_dev* dev)
761{ 777{
762 struct msi_desc *entry; 778 struct msi_desc *entry;
763 779
@@ -774,14 +790,14 @@ void pci_msix_shutdown(struct pci_dev* dev)
774 pci_intx_for_msi(dev, 1); 790 pci_intx_for_msi(dev, 1);
775 dev->msix_enabled = 0; 791 dev->msix_enabled = 0;
776} 792}
777void pci_disable_msix(struct pci_dev* dev) 793
794void pci_disable_msix(struct pci_dev *dev)
778{ 795{
779 if (!pci_msi_enable || !dev || !dev->msix_enabled) 796 if (!pci_msi_enable || !dev || !dev->msix_enabled)
780 return; 797 return;
781 798
782 pci_msix_shutdown(dev); 799 pci_msix_shutdown(dev);
783 800 free_msi_irqs(dev);
784 msix_free_all_irqs(dev);
785} 801}
786EXPORT_SYMBOL(pci_disable_msix); 802EXPORT_SYMBOL(pci_disable_msix);
787 803
@@ -794,16 +810,13 @@ EXPORT_SYMBOL(pci_disable_msix);
794 * allocated for this device function, are reclaimed to unused state, 810 * allocated for this device function, are reclaimed to unused state,
795 * which may be used later on. 811 * which may be used later on.
796 **/ 812 **/
797void msi_remove_pci_irq_vectors(struct pci_dev* dev) 813void msi_remove_pci_irq_vectors(struct pci_dev *dev)
798{ 814{
799 if (!pci_msi_enable || !dev) 815 if (!pci_msi_enable || !dev)
800 return; 816 return;
801
802 if (dev->msi_enabled)
803 msi_free_irqs(dev);
804 817
805 if (dev->msix_enabled) 818 if (dev->msi_enabled || dev->msix_enabled)
806 msix_free_all_irqs(dev); 819 free_msi_irqs(dev);
807} 820}
808 821
809void pci_no_msi(void) 822void pci_no_msi(void)
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index ea15b0537457..33317df47699 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -109,15 +109,32 @@ static bool acpi_pci_can_wakeup(struct pci_dev *dev)
109 return handle ? acpi_bus_can_wakeup(handle) : false; 109 return handle ? acpi_bus_can_wakeup(handle) : false;
110} 110}
111 111
112static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable)
113{
114 while (bus->parent) {
115 struct pci_dev *bridge = bus->self;
116 int ret;
117
118 ret = acpi_pm_device_sleep_wake(&bridge->dev, enable);
119 if (!ret || bridge->is_pcie)
120 return;
121 bus = bus->parent;
122 }
123
124 /* We have reached the root bus. */
125 if (bus->bridge)
126 acpi_pm_device_sleep_wake(bus->bridge, enable);
127}
128
112static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable) 129static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable)
113{ 130{
114 int error = acpi_pm_device_sleep_wake(&dev->dev, enable); 131 if (acpi_pci_can_wakeup(dev))
132 return acpi_pm_device_sleep_wake(&dev->dev, enable);
115 133
116 if (!error) 134 if (!dev->is_pcie)
117 dev_printk(KERN_INFO, &dev->dev, 135 acpi_pci_propagate_wakeup_enable(dev->bus, enable);
118 "wake-up capability %s by ACPI\n", 136
119 enable ? "enabled" : "disabled"); 137 return 0;
120 return error;
121} 138}
122 139
123static struct pci_platform_pm_ops acpi_pci_platform_pm = { 140static struct pci_platform_pm_ops acpi_pci_platform_pm = {
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index a7eb7277b106..e5d47be3c6d7 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -19,37 +19,98 @@
19#include <linux/cpu.h> 19#include <linux/cpu.h>
20#include "pci.h" 20#include "pci.h"
21 21
22/*
23 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
24 */
25
26struct pci_dynid { 22struct pci_dynid {
27 struct list_head node; 23 struct list_head node;
28 struct pci_device_id id; 24 struct pci_device_id id;
29}; 25};
30 26
31#ifdef CONFIG_HOTPLUG 27/**
28 * pci_add_dynid - add a new PCI device ID to this driver and re-probe devices
29 * @drv: target pci driver
30 * @vendor: PCI vendor ID
31 * @device: PCI device ID
32 * @subvendor: PCI subvendor ID
33 * @subdevice: PCI subdevice ID
34 * @class: PCI class
35 * @class_mask: PCI class mask
36 * @driver_data: private driver data
37 *
38 * Adds a new dynamic pci device ID to this driver and causes the
39 * driver to probe for all devices again. @drv must have been
40 * registered prior to calling this function.
41 *
42 * CONTEXT:
43 * Does GFP_KERNEL allocation.
44 *
45 * RETURNS:
46 * 0 on success, -errno on failure.
47 */
48int pci_add_dynid(struct pci_driver *drv,
49 unsigned int vendor, unsigned int device,
50 unsigned int subvendor, unsigned int subdevice,
51 unsigned int class, unsigned int class_mask,
52 unsigned long driver_data)
53{
54 struct pci_dynid *dynid;
55 int retval;
56
57 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
58 if (!dynid)
59 return -ENOMEM;
60
61 dynid->id.vendor = vendor;
62 dynid->id.device = device;
63 dynid->id.subvendor = subvendor;
64 dynid->id.subdevice = subdevice;
65 dynid->id.class = class;
66 dynid->id.class_mask = class_mask;
67 dynid->id.driver_data = driver_data;
68
69 spin_lock(&drv->dynids.lock);
70 list_add_tail(&dynid->node, &drv->dynids.list);
71 spin_unlock(&drv->dynids.lock);
72
73 get_driver(&drv->driver);
74 retval = driver_attach(&drv->driver);
75 put_driver(&drv->driver);
76
77 return retval;
78}
79
80static void pci_free_dynids(struct pci_driver *drv)
81{
82 struct pci_dynid *dynid, *n;
32 83
84 spin_lock(&drv->dynids.lock);
85 list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
86 list_del(&dynid->node);
87 kfree(dynid);
88 }
89 spin_unlock(&drv->dynids.lock);
90}
91
92/*
93 * Dynamic device ID manipulation via sysfs is disabled for !CONFIG_HOTPLUG
94 */
95#ifdef CONFIG_HOTPLUG
33/** 96/**
34 * store_new_id - add a new PCI device ID to this driver and re-probe devices 97 * store_new_id - sysfs frontend to pci_add_dynid()
35 * @driver: target device driver 98 * @driver: target device driver
36 * @buf: buffer for scanning device ID data 99 * @buf: buffer for scanning device ID data
37 * @count: input size 100 * @count: input size
38 * 101 *
39 * Adds a new dynamic pci device ID to this driver, 102 * Allow PCI IDs to be added to an existing driver via sysfs.
40 * and causes the driver to probe for all devices again.
41 */ 103 */
42static ssize_t 104static ssize_t
43store_new_id(struct device_driver *driver, const char *buf, size_t count) 105store_new_id(struct device_driver *driver, const char *buf, size_t count)
44{ 106{
45 struct pci_dynid *dynid;
46 struct pci_driver *pdrv = to_pci_driver(driver); 107 struct pci_driver *pdrv = to_pci_driver(driver);
47 const struct pci_device_id *ids = pdrv->id_table; 108 const struct pci_device_id *ids = pdrv->id_table;
48 __u32 vendor, device, subvendor=PCI_ANY_ID, 109 __u32 vendor, device, subvendor=PCI_ANY_ID,
49 subdevice=PCI_ANY_ID, class=0, class_mask=0; 110 subdevice=PCI_ANY_ID, class=0, class_mask=0;
50 unsigned long driver_data=0; 111 unsigned long driver_data=0;
51 int fields=0; 112 int fields=0;
52 int retval=0; 113 int retval;
53 114
54 fields = sscanf(buf, "%x %x %x %x %x %x %lx", 115 fields = sscanf(buf, "%x %x %x %x %x %x %lx",
55 &vendor, &device, &subvendor, &subdevice, 116 &vendor, &device, &subvendor, &subdevice,
@@ -72,27 +133,8 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
72 return retval; 133 return retval;
73 } 134 }
74 135
75 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 136 retval = pci_add_dynid(pdrv, vendor, device, subvendor, subdevice,
76 if (!dynid) 137 class, class_mask, driver_data);
77 return -ENOMEM;
78
79 dynid->id.vendor = vendor;
80 dynid->id.device = device;
81 dynid->id.subvendor = subvendor;
82 dynid->id.subdevice = subdevice;
83 dynid->id.class = class;
84 dynid->id.class_mask = class_mask;
85 dynid->id.driver_data = driver_data;
86
87 spin_lock(&pdrv->dynids.lock);
88 list_add_tail(&dynid->node, &pdrv->dynids.list);
89 spin_unlock(&pdrv->dynids.lock);
90
91 if (get_driver(&pdrv->driver)) {
92 retval = driver_attach(&pdrv->driver);
93 put_driver(&pdrv->driver);
94 }
95
96 if (retval) 138 if (retval)
97 return retval; 139 return retval;
98 return count; 140 return count;
@@ -145,19 +187,6 @@ store_remove_id(struct device_driver *driver, const char *buf, size_t count)
145} 187}
146static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id); 188static DRIVER_ATTR(remove_id, S_IWUSR, NULL, store_remove_id);
147 189
148static void
149pci_free_dynids(struct pci_driver *drv)
150{
151 struct pci_dynid *dynid, *n;
152
153 spin_lock(&drv->dynids.lock);
154 list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
155 list_del(&dynid->node);
156 kfree(dynid);
157 }
158 spin_unlock(&drv->dynids.lock);
159}
160
161static int 190static int
162pci_create_newid_file(struct pci_driver *drv) 191pci_create_newid_file(struct pci_driver *drv)
163{ 192{
@@ -186,7 +215,6 @@ static void pci_remove_removeid_file(struct pci_driver *drv)
186 driver_remove_file(&drv->driver, &driver_attr_remove_id); 215 driver_remove_file(&drv->driver, &driver_attr_remove_id);
187} 216}
188#else /* !CONFIG_HOTPLUG */ 217#else /* !CONFIG_HOTPLUG */
189static inline void pci_free_dynids(struct pci_driver *drv) {}
190static inline int pci_create_newid_file(struct pci_driver *drv) 218static inline int pci_create_newid_file(struct pci_driver *drv)
191{ 219{
192 return 0; 220 return 0;
@@ -417,8 +445,6 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
417 struct pci_dev * pci_dev = to_pci_dev(dev); 445 struct pci_dev * pci_dev = to_pci_dev(dev);
418 struct pci_driver * drv = pci_dev->driver; 446 struct pci_driver * drv = pci_dev->driver;
419 447
420 pci_dev->state_saved = false;
421
422 if (drv && drv->suspend) { 448 if (drv && drv->suspend) {
423 pci_power_t prev = pci_dev->current_state; 449 pci_power_t prev = pci_dev->current_state;
424 int error; 450 int error;
@@ -514,7 +540,6 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
514static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) 540static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
515{ 541{
516 pci_restore_standard_config(pci_dev); 542 pci_restore_standard_config(pci_dev);
517 pci_dev->state_saved = false;
518 pci_fixup_device(pci_fixup_resume_early, pci_dev); 543 pci_fixup_device(pci_fixup_resume_early, pci_dev);
519} 544}
520 545
@@ -580,8 +605,6 @@ static int pci_pm_suspend(struct device *dev)
580 if (pci_has_legacy_pm_support(pci_dev)) 605 if (pci_has_legacy_pm_support(pci_dev))
581 return pci_legacy_suspend(dev, PMSG_SUSPEND); 606 return pci_legacy_suspend(dev, PMSG_SUSPEND);
582 607
583 pci_dev->state_saved = false;
584
585 if (!pm) { 608 if (!pm) {
586 pci_pm_default_suspend(pci_dev); 609 pci_pm_default_suspend(pci_dev);
587 goto Fixup; 610 goto Fixup;
@@ -694,7 +717,7 @@ static int pci_pm_resume(struct device *dev)
694 pci_pm_reenable_device(pci_dev); 717 pci_pm_reenable_device(pci_dev);
695 } 718 }
696 719
697 return 0; 720 return error;
698} 721}
699 722
700#else /* !CONFIG_SUSPEND */ 723#else /* !CONFIG_SUSPEND */
@@ -716,8 +739,6 @@ static int pci_pm_freeze(struct device *dev)
716 if (pci_has_legacy_pm_support(pci_dev)) 739 if (pci_has_legacy_pm_support(pci_dev))
717 return pci_legacy_suspend(dev, PMSG_FREEZE); 740 return pci_legacy_suspend(dev, PMSG_FREEZE);
718 741
719 pci_dev->state_saved = false;
720
721 if (!pm) { 742 if (!pm) {
722 pci_pm_default_suspend(pci_dev); 743 pci_pm_default_suspend(pci_dev);
723 return 0; 744 return 0;
@@ -793,6 +814,8 @@ static int pci_pm_thaw(struct device *dev)
793 pci_pm_reenable_device(pci_dev); 814 pci_pm_reenable_device(pci_dev);
794 } 815 }
795 816
817 pci_dev->state_saved = false;
818
796 return error; 819 return error;
797} 820}
798 821
@@ -804,8 +827,6 @@ static int pci_pm_poweroff(struct device *dev)
804 if (pci_has_legacy_pm_support(pci_dev)) 827 if (pci_has_legacy_pm_support(pci_dev))
805 return pci_legacy_suspend(dev, PMSG_HIBERNATE); 828 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
806 829
807 pci_dev->state_saved = false;
808
809 if (!pm) { 830 if (!pm) {
810 pci_pm_default_suspend(pci_dev); 831 pci_pm_default_suspend(pci_dev);
811 goto Fixup; 832 goto Fixup;
@@ -1106,6 +1127,7 @@ static int __init pci_driver_init(void)
1106 1127
1107postcore_initcall(pci_driver_init); 1128postcore_initcall(pci_driver_init);
1108 1129
1130EXPORT_SYMBOL_GPL(pci_add_dynid);
1109EXPORT_SYMBOL(pci_match_id); 1131EXPORT_SYMBOL(pci_match_id);
1110EXPORT_SYMBOL(__pci_register_driver); 1132EXPORT_SYMBOL(__pci_register_driver);
1111EXPORT_SYMBOL(pci_unregister_driver); 1133EXPORT_SYMBOL(pci_unregister_driver);
diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c
index 74fbec0bf6cb..f7b68ca6cc98 100644
--- a/drivers/pci/pci-stub.c
+++ b/drivers/pci/pci-stub.c
@@ -19,8 +19,16 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21 21
22static char ids[1024] __initdata;
23
24module_param_string(ids, ids, sizeof(ids), 0);
25MODULE_PARM_DESC(ids, "Initial PCI IDs to add to the stub driver, format is "
26 "\"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\""
27 " and multiple comma separated entries can be specified");
28
22static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id) 29static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
23{ 30{
31 dev_printk(KERN_INFO, &dev->dev, "claimed by stub\n");
24 return 0; 32 return 0;
25} 33}
26 34
@@ -32,7 +40,42 @@ static struct pci_driver stub_driver = {
32 40
33static int __init pci_stub_init(void) 41static int __init pci_stub_init(void)
34{ 42{
35 return pci_register_driver(&stub_driver); 43 char *p, *id;
44 int rc;
45
46 rc = pci_register_driver(&stub_driver);
47 if (rc)
48 return rc;
49
50 /* add ids specified in the module parameter */
51 p = ids;
52 while ((id = strsep(&p, ","))) {
53 unsigned int vendor, device, subvendor = PCI_ANY_ID,
54 subdevice = PCI_ANY_ID, class=0, class_mask=0;
55 int fields;
56
57 fields = sscanf(id, "%x:%x:%x:%x:%x:%x",
58 &vendor, &device, &subvendor, &subdevice,
59 &class, &class_mask);
60
61 if (fields < 2) {
62 printk(KERN_WARNING
63 "pci-stub: invalid id string \"%s\"\n", id);
64 continue;
65 }
66
67 printk(KERN_INFO
68 "pci-stub: add %04X:%04X sub=%04X:%04X cls=%08X/%08X\n",
69 vendor, device, subvendor, subdevice, class, class_mask);
70
71 rc = pci_add_dynid(&stub_driver, vendor, device,
72 subvendor, subdevice, class, class_mask, 0);
73 if (rc)
74 printk(KERN_WARNING
75 "pci-stub: failed to add dynamic id (%d)\n", rc);
76 }
77
78 return 0;
36} 79}
37 80
38static void __exit pci_stub_exit(void) 81static void __exit pci_stub_exit(void)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 85ebd02a64a7..0f6382f090ee 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -916,6 +916,24 @@ int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev)
916 return 0; 916 return 0;
917} 917}
918 918
919static ssize_t reset_store(struct device *dev,
920 struct device_attribute *attr, const char *buf,
921 size_t count)
922{
923 struct pci_dev *pdev = to_pci_dev(dev);
924 unsigned long val;
925 ssize_t result = strict_strtoul(buf, 0, &val);
926
927 if (result < 0)
928 return result;
929
930 if (val != 1)
931 return -EINVAL;
932 return pci_reset_function(pdev);
933}
934
935static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_store);
936
919static int pci_create_capabilities_sysfs(struct pci_dev *dev) 937static int pci_create_capabilities_sysfs(struct pci_dev *dev)
920{ 938{
921 int retval; 939 int retval;
@@ -943,7 +961,22 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)
943 /* Active State Power Management */ 961 /* Active State Power Management */
944 pcie_aspm_create_sysfs_dev_files(dev); 962 pcie_aspm_create_sysfs_dev_files(dev);
945 963
964 if (!pci_probe_reset_function(dev)) {
965 retval = device_create_file(&dev->dev, &reset_attr);
966 if (retval)
967 goto error;
968 dev->reset_fn = 1;
969 }
946 return 0; 970 return 0;
971
972error:
973 pcie_aspm_remove_sysfs_dev_files(dev);
974 if (dev->vpd && dev->vpd->attr) {
975 sysfs_remove_bin_file(&dev->dev.kobj, dev->vpd->attr);
976 kfree(dev->vpd->attr);
977 }
978
979 return retval;
947} 980}
948 981
949int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) 982int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
@@ -1037,6 +1070,10 @@ static void pci_remove_capabilities_sysfs(struct pci_dev *dev)
1037 } 1070 }
1038 1071
1039 pcie_aspm_remove_sysfs_dev_files(dev); 1072 pcie_aspm_remove_sysfs_dev_files(dev);
1073 if (dev->reset_fn) {
1074 device_remove_file(&dev->dev, &reset_attr);
1075 dev->reset_fn = 0;
1076 }
1040} 1077}
1041 1078
1042/** 1079/**
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7b70312181d7..6edecff0b419 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -41,6 +41,12 @@ int pci_domains_supported = 1;
41unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE; 41unsigned long pci_cardbus_io_size = DEFAULT_CARDBUS_IO_SIZE;
42unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE; 42unsigned long pci_cardbus_mem_size = DEFAULT_CARDBUS_MEM_SIZE;
43 43
44#define DEFAULT_HOTPLUG_IO_SIZE (256)
45#define DEFAULT_HOTPLUG_MEM_SIZE (2*1024*1024)
46/* pci=hpmemsize=nnM,hpiosize=nn can override this */
47unsigned long pci_hotplug_io_size = DEFAULT_HOTPLUG_IO_SIZE;
48unsigned long pci_hotplug_mem_size = DEFAULT_HOTPLUG_MEM_SIZE;
49
44/** 50/**
45 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children 51 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children
46 * @bus: pointer to PCI bus structure to search 52 * @bus: pointer to PCI bus structure to search
@@ -848,6 +854,7 @@ pci_restore_state(struct pci_dev *dev)
848 854
849 if (!dev->state_saved) 855 if (!dev->state_saved)
850 return 0; 856 return 0;
857
851 /* PCI Express register must be restored first */ 858 /* PCI Express register must be restored first */
852 pci_restore_pcie_state(dev); 859 pci_restore_pcie_state(dev);
853 860
@@ -869,6 +876,8 @@ pci_restore_state(struct pci_dev *dev)
869 pci_restore_msi_state(dev); 876 pci_restore_msi_state(dev);
870 pci_restore_iov_state(dev); 877 pci_restore_iov_state(dev);
871 878
879 dev->state_saved = false;
880
872 return 0; 881 return 0;
873} 882}
874 883
@@ -1214,30 +1223,40 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
1214 */ 1223 */
1215int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) 1224int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
1216{ 1225{
1217 int error = 0; 1226 int ret = 0;
1218 bool pme_done = false;
1219 1227
1220 if (enable && !device_may_wakeup(&dev->dev)) 1228 if (enable && !device_may_wakeup(&dev->dev))
1221 return -EINVAL; 1229 return -EINVAL;
1222 1230
1231 /* Don't do the same thing twice in a row for one device. */
1232 if (!!enable == !!dev->wakeup_prepared)
1233 return 0;
1234
1223 /* 1235 /*
1224 * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don 1236 * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don
1225 * Anderson we should be doing PME# wake enable followed by ACPI wake 1237 * Anderson we should be doing PME# wake enable followed by ACPI wake
1226 * enable. To disable wake-up we call the platform first, for symmetry. 1238 * enable. To disable wake-up we call the platform first, for symmetry.
1227 */ 1239 */
1228 1240
1229 if (!enable && platform_pci_can_wakeup(dev)) 1241 if (enable) {
1230 error = platform_pci_sleep_wake(dev, false); 1242 int error;
1231
1232 if (!enable || pci_pme_capable(dev, state)) {
1233 pci_pme_active(dev, enable);
1234 pme_done = true;
1235 }
1236 1243
1237 if (enable && platform_pci_can_wakeup(dev)) 1244 if (pci_pme_capable(dev, state))
1245 pci_pme_active(dev, true);
1246 else
1247 ret = 1;
1238 error = platform_pci_sleep_wake(dev, true); 1248 error = platform_pci_sleep_wake(dev, true);
1249 if (ret)
1250 ret = error;
1251 if (!ret)
1252 dev->wakeup_prepared = true;
1253 } else {
1254 platform_pci_sleep_wake(dev, false);
1255 pci_pme_active(dev, false);
1256 dev->wakeup_prepared = false;
1257 }
1239 1258
1240 return pme_done ? 0 : error; 1259 return ret;
1241} 1260}
1242 1261
1243/** 1262/**
@@ -1356,6 +1375,7 @@ void pci_pm_init(struct pci_dev *dev)
1356 int pm; 1375 int pm;
1357 u16 pmc; 1376 u16 pmc;
1358 1377
1378 dev->wakeup_prepared = false;
1359 dev->pm_cap = 0; 1379 dev->pm_cap = 0;
1360 1380
1361 /* find PCI PM capability in list */ 1381 /* find PCI PM capability in list */
@@ -2262,6 +2282,22 @@ int __pci_reset_function(struct pci_dev *dev)
2262EXPORT_SYMBOL_GPL(__pci_reset_function); 2282EXPORT_SYMBOL_GPL(__pci_reset_function);
2263 2283
2264/** 2284/**
2285 * pci_probe_reset_function - check whether the device can be safely reset
2286 * @dev: PCI device to reset
2287 *
2288 * Some devices allow an individual function to be reset without affecting
2289 * other functions in the same device. The PCI device must be responsive
2290 * to PCI config space in order to use this function.
2291 *
2292 * Returns 0 if the device function can be reset or negative if the
2293 * device doesn't support resetting a single function.
2294 */
2295int pci_probe_reset_function(struct pci_dev *dev)
2296{
2297 return pci_dev_reset(dev, 1);
2298}
2299
2300/**
2265 * pci_reset_function - quiesce and reset a PCI device function 2301 * pci_reset_function - quiesce and reset a PCI device function
2266 * @dev: PCI device to reset 2302 * @dev: PCI device to reset
2267 * 2303 *
@@ -2504,6 +2540,50 @@ int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
2504 return 0; 2540 return 0;
2505} 2541}
2506 2542
2543/**
2544 * pci_set_vga_state - set VGA decode state on device and parents if requested
2545 * @dev the PCI device
2546 * @decode - true = enable decoding, false = disable decoding
2547 * @command_bits PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY
2548 * @change_bridge - traverse ancestors and change bridges
2549 */
2550int pci_set_vga_state(struct pci_dev *dev, bool decode,
2551 unsigned int command_bits, bool change_bridge)
2552{
2553 struct pci_bus *bus;
2554 struct pci_dev *bridge;
2555 u16 cmd;
2556
2557 WARN_ON(command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY));
2558
2559 pci_read_config_word(dev, PCI_COMMAND, &cmd);
2560 if (decode == true)
2561 cmd |= command_bits;
2562 else
2563 cmd &= ~command_bits;
2564 pci_write_config_word(dev, PCI_COMMAND, cmd);
2565
2566 if (change_bridge == false)
2567 return 0;
2568
2569 bus = dev->bus;
2570 while (bus) {
2571 bridge = bus->self;
2572 if (bridge) {
2573 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
2574 &cmd);
2575 if (decode == true)
2576 cmd |= PCI_BRIDGE_CTL_VGA;
2577 else
2578 cmd &= ~PCI_BRIDGE_CTL_VGA;
2579 pci_write_config_word(bridge, PCI_BRIDGE_CONTROL,
2580 cmd);
2581 }
2582 bus = bus->parent;
2583 }
2584 return 0;
2585}
2586
2507#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE 2587#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
2508static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; 2588static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
2509spinlock_t resource_alignment_lock = SPIN_LOCK_UNLOCKED; 2589spinlock_t resource_alignment_lock = SPIN_LOCK_UNLOCKED;
@@ -2672,6 +2752,10 @@ static int __init pci_setup(char *str)
2672 strlen(str + 19)); 2752 strlen(str + 19));
2673 } else if (!strncmp(str, "ecrc=", 5)) { 2753 } else if (!strncmp(str, "ecrc=", 5)) {
2674 pcie_ecrc_get_policy(str + 5); 2754 pcie_ecrc_get_policy(str + 5);
2755 } else if (!strncmp(str, "hpiosize=", 9)) {
2756 pci_hotplug_io_size = memparse(str + 9, &str);
2757 } else if (!strncmp(str, "hpmemsize=", 10)) {
2758 pci_hotplug_mem_size = memparse(str + 10, &str);
2675 } else { 2759 } else {
2676 printk(KERN_ERR "PCI: Unknown option `%s'\n", 2760 printk(KERN_ERR "PCI: Unknown option `%s'\n",
2677 str); 2761 str);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 5ff4d25bf0e9..d92d1954a2fb 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -16,6 +16,7 @@ extern void pci_cleanup_rom(struct pci_dev *dev);
16extern int pci_mmap_fits(struct pci_dev *pdev, int resno, 16extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
17 struct vm_area_struct *vma); 17 struct vm_area_struct *vma);
18#endif 18#endif
19int pci_probe_reset_function(struct pci_dev *dev);
19 20
20/** 21/**
21 * struct pci_platform_pm_ops - Firmware PM callbacks 22 * struct pci_platform_pm_ops - Firmware PM callbacks
@@ -133,7 +134,6 @@ static inline int pci_no_d1d2(struct pci_dev *dev)
133 return (dev->no_d1d2 || parent_dstates); 134 return (dev->no_d1d2 || parent_dstates);
134 135
135} 136}
136extern int pcie_mch_quirk;
137extern struct device_attribute pci_dev_attrs[]; 137extern struct device_attribute pci_dev_attrs[];
138extern struct device_attribute dev_attr_cpuaffinity; 138extern struct device_attribute dev_attr_cpuaffinity;
139extern struct device_attribute dev_attr_cpulistaffinity; 139extern struct device_attribute dev_attr_cpulistaffinity;
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index d92ae21a59d8..62d15f652bb6 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -22,11 +22,10 @@
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <asm/uaccess.h> 25#include <linux/uaccess.h>
26#include "aerdrv.h" 26#include "aerdrv.h"
27 27
28struct aer_error_inj 28struct aer_error_inj {
29{
30 u8 bus; 29 u8 bus;
31 u8 dev; 30 u8 dev;
32 u8 fn; 31 u8 fn;
@@ -38,8 +37,7 @@ struct aer_error_inj
38 u32 header_log3; 37 u32 header_log3;
39}; 38};
40 39
41struct aer_error 40struct aer_error {
42{
43 struct list_head list; 41 struct list_head list;
44 unsigned int bus; 42 unsigned int bus;
45 unsigned int devfn; 43 unsigned int devfn;
@@ -55,8 +53,7 @@ struct aer_error
55 u32 source_id; 53 u32 source_id;
56}; 54};
57 55
58struct pci_bus_ops 56struct pci_bus_ops {
59{
60 struct list_head list; 57 struct list_head list;
61 struct pci_bus *bus; 58 struct pci_bus *bus;
62 struct pci_ops *ops; 59 struct pci_ops *ops;
@@ -150,7 +147,7 @@ static u32 *find_pci_config_dword(struct aer_error *err, int where,
150 target = &err->header_log1; 147 target = &err->header_log1;
151 break; 148 break;
152 case PCI_ERR_HEADER_LOG+8: 149 case PCI_ERR_HEADER_LOG+8:
153 target = &err->header_log2; 150 target = &err->header_log2;
154 break; 151 break;
155 case PCI_ERR_HEADER_LOG+12: 152 case PCI_ERR_HEADER_LOG+12:
156 target = &err->header_log3; 153 target = &err->header_log3;
@@ -258,8 +255,7 @@ static int pci_bus_set_aer_ops(struct pci_bus *bus)
258 bus_ops = NULL; 255 bus_ops = NULL;
259out: 256out:
260 spin_unlock_irqrestore(&inject_lock, flags); 257 spin_unlock_irqrestore(&inject_lock, flags);
261 if (bus_ops) 258 kfree(bus_ops);
262 kfree(bus_ops);
263 return 0; 259 return 0;
264} 260}
265 261
@@ -401,10 +397,8 @@ static int aer_inject(struct aer_error_inj *einj)
401 else 397 else
402 ret = -EINVAL; 398 ret = -EINVAL;
403out_put: 399out_put:
404 if (err_alloc) 400 kfree(err_alloc);
405 kfree(err_alloc); 401 kfree(rperr_alloc);
406 if (rperr_alloc)
407 kfree(rperr_alloc);
408 pci_dev_put(dev); 402 pci_dev_put(dev);
409 return ret; 403 return ret;
410} 404}
@@ -458,8 +452,7 @@ static void __exit aer_inject_exit(void)
458 } 452 }
459 453
460 spin_lock_irqsave(&inject_lock, flags); 454 spin_lock_irqsave(&inject_lock, flags);
461 list_for_each_entry_safe(err, err_next, 455 list_for_each_entry_safe(err, err_next, &pci_bus_ops_list, list) {
462 &pci_bus_ops_list, list) {
463 list_del(&err->list); 456 list_del(&err->list);
464 kfree(err); 457 kfree(err);
465 } 458 }
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 4770f13b3ca1..10c0e62bd5a8 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -38,7 +38,7 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
38MODULE_DESCRIPTION(DRIVER_DESC); 38MODULE_DESCRIPTION(DRIVER_DESC);
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41static int __devinit aer_probe (struct pcie_device *dev); 41static int __devinit aer_probe(struct pcie_device *dev);
42static void aer_remove(struct pcie_device *dev); 42static void aer_remove(struct pcie_device *dev);
43static pci_ers_result_t aer_error_detected(struct pci_dev *dev, 43static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
44 enum pci_channel_state error); 44 enum pci_channel_state error);
@@ -47,7 +47,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
47 47
48static struct pci_error_handlers aer_error_handlers = { 48static struct pci_error_handlers aer_error_handlers = {
49 .error_detected = aer_error_detected, 49 .error_detected = aer_error_detected,
50 .resume = aer_error_resume, 50 .resume = aer_error_resume,
51}; 51};
52 52
53static struct pcie_port_service_driver aerdriver = { 53static struct pcie_port_service_driver aerdriver = {
@@ -134,12 +134,12 @@ EXPORT_SYMBOL_GPL(aer_irq);
134 * 134 *
135 * Invoked when Root Port's AER service is loaded. 135 * Invoked when Root Port's AER service is loaded.
136 **/ 136 **/
137static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev) 137static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
138{ 138{
139 struct aer_rpc *rpc; 139 struct aer_rpc *rpc;
140 140
141 if (!(rpc = kzalloc(sizeof(struct aer_rpc), 141 rpc = kzalloc(sizeof(struct aer_rpc), GFP_KERNEL);
142 GFP_KERNEL))) 142 if (!rpc)
143 return NULL; 143 return NULL;
144 144
145 /* 145 /*
@@ -189,26 +189,28 @@ static void aer_remove(struct pcie_device *dev)
189 * 189 *
190 * Invoked when PCI Express bus loads AER service driver. 190 * Invoked when PCI Express bus loads AER service driver.
191 **/ 191 **/
192static int __devinit aer_probe (struct pcie_device *dev) 192static int __devinit aer_probe(struct pcie_device *dev)
193{ 193{
194 int status; 194 int status;
195 struct aer_rpc *rpc; 195 struct aer_rpc *rpc;
196 struct device *device = &dev->device; 196 struct device *device = &dev->device;
197 197
198 /* Init */ 198 /* Init */
199 if ((status = aer_init(dev))) 199 status = aer_init(dev);
200 if (status)
200 return status; 201 return status;
201 202
202 /* Alloc rpc data structure */ 203 /* Alloc rpc data structure */
203 if (!(rpc = aer_alloc_rpc(dev))) { 204 rpc = aer_alloc_rpc(dev);
205 if (!rpc) {
204 dev_printk(KERN_DEBUG, device, "alloc rpc failed\n"); 206 dev_printk(KERN_DEBUG, device, "alloc rpc failed\n");
205 aer_remove(dev); 207 aer_remove(dev);
206 return -ENOMEM; 208 return -ENOMEM;
207 } 209 }
208 210
209 /* Request IRQ ISR */ 211 /* Request IRQ ISR */
210 if ((status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", 212 status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", dev);
211 dev))) { 213 if (status) {
212 dev_printk(KERN_DEBUG, device, "request IRQ failed\n"); 214 dev_printk(KERN_DEBUG, device, "request IRQ failed\n");
213 aer_remove(dev); 215 aer_remove(dev);
214 return status; 216 return status;
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index bbd7428ca2d0..bd833ea3ba49 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -16,12 +16,9 @@
16#define AER_NONFATAL 0 16#define AER_NONFATAL 0
17#define AER_FATAL 1 17#define AER_FATAL 1
18#define AER_CORRECTABLE 2 18#define AER_CORRECTABLE 2
19#define AER_UNCORRECTABLE 4
20#define AER_ERROR_MASK 0x001fffff
21#define AER_ERROR(d) (d & AER_ERROR_MASK)
22 19
23/* Root Error Status Register Bits */ 20/* Root Error Status Register Bits */
24#define ROOT_ERR_STATUS_MASKS 0x0f 21#define ROOT_ERR_STATUS_MASKS 0x0f
25 22
26#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \ 23#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
27 PCI_EXP_RTCTL_SENFEE| \ 24 PCI_EXP_RTCTL_SENFEE| \
@@ -32,8 +29,6 @@
32#define ERR_COR_ID(d) (d & 0xffff) 29#define ERR_COR_ID(d) (d & 0xffff)
33#define ERR_UNCOR_ID(d) (d >> 16) 30#define ERR_UNCOR_ID(d) (d >> 16)
34 31
35#define AER_SUCCESS 0
36#define AER_UNSUCCESS 1
37#define AER_ERROR_SOURCES_MAX 100 32#define AER_ERROR_SOURCES_MAX 100
38 33
39#define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \ 34#define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \
@@ -43,13 +38,6 @@
43 PCI_ERR_UNC_UNX_COMP| \ 38 PCI_ERR_UNC_UNX_COMP| \
44 PCI_ERR_UNC_MALF_TLP) 39 PCI_ERR_UNC_MALF_TLP)
45 40
46/* AER Error Info Flags */
47#define AER_TLP_HEADER_VALID_FLAG 0x00000001
48#define AER_MULTI_ERROR_VALID_FLAG 0x00000002
49
50#define ERR_CORRECTABLE_ERROR_MASK 0x000031c1
51#define ERR_UNCORRECTABLE_ERROR_MASK 0x001ff010
52
53struct header_log_regs { 41struct header_log_regs {
54 unsigned int dw0; 42 unsigned int dw0;
55 unsigned int dw1; 43 unsigned int dw1;
@@ -61,11 +49,20 @@ struct header_log_regs {
61struct aer_err_info { 49struct aer_err_info {
62 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES]; 50 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
63 int error_dev_num; 51 int error_dev_num;
64 u16 id; 52
65 int severity; /* 0:NONFATAL | 1:FATAL | 2:COR */ 53 unsigned int id:16;
66 int flags; 54
55 unsigned int severity:2; /* 0:NONFATAL | 1:FATAL | 2:COR */
56 unsigned int __pad1:5;
57 unsigned int multi_error_valid:1;
58
59 unsigned int first_error:5;
60 unsigned int __pad2:2;
61 unsigned int tlp_header_valid:1;
62
67 unsigned int status; /* COR/UNCOR Error Status */ 63 unsigned int status; /* COR/UNCOR Error Status */
68 struct header_log_regs tlp; /* TLP Header */ 64 unsigned int mask; /* COR/UNCOR Error Mask */
65 struct header_log_regs tlp; /* TLP Header */
69}; 66};
70 67
71struct aer_err_source { 68struct aer_err_source {
@@ -125,6 +122,7 @@ extern void aer_delete_rootport(struct aer_rpc *rpc);
125extern int aer_init(struct pcie_device *dev); 122extern int aer_init(struct pcie_device *dev);
126extern void aer_isr(struct work_struct *work); 123extern void aer_isr(struct work_struct *work);
127extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); 124extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
125extern void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info);
128extern irqreturn_t aer_irq(int irq, void *context); 126extern irqreturn_t aer_irq(int irq, void *context);
129 127
130#ifdef CONFIG_ACPI 128#ifdef CONFIG_ACPI
@@ -136,4 +134,4 @@ static inline int aer_osc_setup(struct pcie_device *pciedev)
136} 134}
137#endif 135#endif
138 136
139#endif //_AERDRV_H_ 137#endif /* _AERDRV_H_ */
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 3d8872704a58..9f5ccbeb4fa5 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -49,10 +49,11 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev)
49 PCI_EXP_DEVCTL_NFERE | 49 PCI_EXP_DEVCTL_NFERE |
50 PCI_EXP_DEVCTL_FERE | 50 PCI_EXP_DEVCTL_FERE |
51 PCI_EXP_DEVCTL_URRE; 51 PCI_EXP_DEVCTL_URRE;
52 pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, 52 pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, reg16);
53 reg16); 53
54 return 0; 54 return 0;
55} 55}
56EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
56 57
57int pci_disable_pcie_error_reporting(struct pci_dev *dev) 58int pci_disable_pcie_error_reporting(struct pci_dev *dev)
58{ 59{
@@ -68,10 +69,11 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev)
68 PCI_EXP_DEVCTL_NFERE | 69 PCI_EXP_DEVCTL_NFERE |
69 PCI_EXP_DEVCTL_FERE | 70 PCI_EXP_DEVCTL_FERE |
70 PCI_EXP_DEVCTL_URRE); 71 PCI_EXP_DEVCTL_URRE);
71 pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, 72 pci_write_config_word(dev, pos+PCI_EXP_DEVCTL, reg16);
72 reg16); 73
73 return 0; 74 return 0;
74} 75}
76EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
75 77
76int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) 78int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
77{ 79{
@@ -92,6 +94,7 @@ int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
92 94
93 return 0; 95 return 0;
94} 96}
97EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
95 98
96#if 0 99#if 0
97int pci_cleanup_aer_correct_error_status(struct pci_dev *dev) 100int pci_cleanup_aer_correct_error_status(struct pci_dev *dev)
@@ -110,7 +113,6 @@ int pci_cleanup_aer_correct_error_status(struct pci_dev *dev)
110} 113}
111#endif /* 0 */ 114#endif /* 0 */
112 115
113
114static int set_device_error_reporting(struct pci_dev *dev, void *data) 116static int set_device_error_reporting(struct pci_dev *dev, void *data)
115{ 117{
116 bool enable = *((bool *)data); 118 bool enable = *((bool *)data);
@@ -164,8 +166,9 @@ static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
164 e_info->dev[e_info->error_dev_num] = dev; 166 e_info->dev[e_info->error_dev_num] = dev;
165 e_info->error_dev_num++; 167 e_info->error_dev_num++;
166 return 1; 168 return 1;
167 } else 169 }
168 return 0; 170
171 return 0;
169} 172}
170 173
171 174
@@ -193,7 +196,7 @@ static int find_device_iter(struct pci_dev *dev, void *data)
193 * If there is no multiple error, we stop 196 * If there is no multiple error, we stop
194 * or continue based on the id comparing. 197 * or continue based on the id comparing.
195 */ 198 */
196 if (!(e_info->flags & AER_MULTI_ERROR_VALID_FLAG)) 199 if (!e_info->multi_error_valid)
197 return result; 200 return result;
198 201
199 /* 202 /*
@@ -233,24 +236,16 @@ static int find_device_iter(struct pci_dev *dev, void *data)
233 status = 0; 236 status = 0;
234 mask = 0; 237 mask = 0;
235 if (e_info->severity == AER_CORRECTABLE) { 238 if (e_info->severity == AER_CORRECTABLE) {
236 pci_read_config_dword(dev, 239 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
237 pos + PCI_ERR_COR_STATUS, 240 pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &mask);
238 &status); 241 if (status & ~mask) {
239 pci_read_config_dword(dev,
240 pos + PCI_ERR_COR_MASK,
241 &mask);
242 if (status & ERR_CORRECTABLE_ERROR_MASK & ~mask) {
243 add_error_device(e_info, dev); 242 add_error_device(e_info, dev);
244 goto added; 243 goto added;
245 } 244 }
246 } else { 245 } else {
247 pci_read_config_dword(dev, 246 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
248 pos + PCI_ERR_UNCOR_STATUS, 247 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
249 &status); 248 if (status & ~mask) {
250 pci_read_config_dword(dev,
251 pos + PCI_ERR_UNCOR_MASK,
252 &mask);
253 if (status & ERR_UNCORRECTABLE_ERROR_MASK & ~mask) {
254 add_error_device(e_info, dev); 249 add_error_device(e_info, dev);
255 goto added; 250 goto added;
256 } 251 }
@@ -259,7 +254,7 @@ static int find_device_iter(struct pci_dev *dev, void *data)
259 return 0; 254 return 0;
260 255
261added: 256added:
262 if (e_info->flags & AER_MULTI_ERROR_VALID_FLAG) 257 if (e_info->multi_error_valid)
263 return 0; 258 return 0;
264 else 259 else
265 return 1; 260 return 1;
@@ -411,8 +406,7 @@ static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,
411 pci_cleanup_aer_uncorrect_error_status(dev); 406 pci_cleanup_aer_uncorrect_error_status(dev);
412 dev->error_state = pci_channel_io_normal; 407 dev->error_state = pci_channel_io_normal;
413 } 408 }
414 } 409 } else {
415 else {
416 /* 410 /*
417 * If the error is reported by an end point, we think this 411 * If the error is reported by an end point, we think this
418 * error is related to the upstream link of the end point. 412 * error is related to the upstream link of the end point.
@@ -473,7 +467,7 @@ static pci_ers_result_t reset_link(struct pcie_device *aerdev,
473 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) 467 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)
474 udev = dev; 468 udev = dev;
475 else 469 else
476 udev= dev->bus->self; 470 udev = dev->bus->self;
477 471
478 data.is_downstream = 0; 472 data.is_downstream = 0;
479 data.aer_driver = NULL; 473 data.aer_driver = NULL;
@@ -576,7 +570,7 @@ static pci_ers_result_t do_recovery(struct pcie_device *aerdev,
576 * 570 *
577 * Invoked when an error being detected by Root Port. 571 * Invoked when an error being detected by Root Port.
578 */ 572 */
579static void handle_error_source(struct pcie_device * aerdev, 573static void handle_error_source(struct pcie_device *aerdev,
580 struct pci_dev *dev, 574 struct pci_dev *dev,
581 struct aer_err_info *info) 575 struct aer_err_info *info)
582{ 576{
@@ -682,7 +676,7 @@ static void disable_root_aer(struct aer_rpc *rpc)
682 * 676 *
683 * Invoked by DPC handler to consume an error. 677 * Invoked by DPC handler to consume an error.
684 */ 678 */
685static struct aer_err_source* get_e_source(struct aer_rpc *rpc) 679static struct aer_err_source *get_e_source(struct aer_rpc *rpc)
686{ 680{
687 struct aer_err_source *e_source; 681 struct aer_err_source *e_source;
688 unsigned long flags; 682 unsigned long flags;
@@ -702,32 +696,50 @@ static struct aer_err_source* get_e_source(struct aer_rpc *rpc)
702 return e_source; 696 return e_source;
703} 697}
704 698
699/**
700 * get_device_error_info - read error status from dev and store it to info
701 * @dev: pointer to the device expected to have a error record
702 * @info: pointer to structure to store the error record
703 *
704 * Return 1 on success, 0 on error.
705 */
705static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info) 706static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
706{ 707{
707 int pos; 708 int pos, temp;
709
710 info->status = 0;
711 info->tlp_header_valid = 0;
708 712
709 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR); 713 pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
710 714
711 /* The device might not support AER */ 715 /* The device might not support AER */
712 if (!pos) 716 if (!pos)
713 return AER_SUCCESS; 717 return 1;
714 718
715 if (info->severity == AER_CORRECTABLE) { 719 if (info->severity == AER_CORRECTABLE) {
716 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, 720 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS,
717 &info->status); 721 &info->status);
718 if (!(info->status & ERR_CORRECTABLE_ERROR_MASK)) 722 pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK,
719 return AER_UNSUCCESS; 723 &info->mask);
724 if (!(info->status & ~info->mask))
725 return 0;
720 } else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE || 726 } else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE ||
721 info->severity == AER_NONFATAL) { 727 info->severity == AER_NONFATAL) {
722 728
723 /* Link is still healthy for IO reads */ 729 /* Link is still healthy for IO reads */
724 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, 730 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
725 &info->status); 731 &info->status);
726 if (!(info->status & ERR_UNCORRECTABLE_ERROR_MASK)) 732 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK,
727 return AER_UNSUCCESS; 733 &info->mask);
734 if (!(info->status & ~info->mask))
735 return 0;
736
737 /* Get First Error Pointer */
738 pci_read_config_dword(dev, pos + PCI_ERR_CAP, &temp);
739 info->first_error = PCI_ERR_CAP_FEP(temp);
728 740
729 if (info->status & AER_LOG_TLP_MASKS) { 741 if (info->status & AER_LOG_TLP_MASKS) {
730 info->flags |= AER_TLP_HEADER_VALID_FLAG; 742 info->tlp_header_valid = 1;
731 pci_read_config_dword(dev, 743 pci_read_config_dword(dev,
732 pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0); 744 pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0);
733 pci_read_config_dword(dev, 745 pci_read_config_dword(dev,
@@ -739,7 +751,7 @@ static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
739 } 751 }
740 } 752 }
741 753
742 return AER_SUCCESS; 754 return 1;
743} 755}
744 756
745static inline void aer_process_err_devices(struct pcie_device *p_device, 757static inline void aer_process_err_devices(struct pcie_device *p_device,
@@ -753,14 +765,14 @@ static inline void aer_process_err_devices(struct pcie_device *p_device,
753 e_info->id); 765 e_info->id);
754 } 766 }
755 767
768 /* Report all before handle them, not to lost records by reset etc. */
756 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) { 769 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
757 if (get_device_error_info(e_info->dev[i], e_info) == 770 if (get_device_error_info(e_info->dev[i], e_info))
758 AER_SUCCESS) {
759 aer_print_error(e_info->dev[i], e_info); 771 aer_print_error(e_info->dev[i], e_info);
760 handle_error_source(p_device, 772 }
761 e_info->dev[i], 773 for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
762 e_info); 774 if (get_device_error_info(e_info->dev[i], e_info))
763 } 775 handle_error_source(p_device, e_info->dev[i], e_info);
764 } 776 }
765} 777}
766 778
@@ -806,7 +818,9 @@ static void aer_isr_one_error(struct pcie_device *p_device,
806 if (e_src->status & 818 if (e_src->status &
807 (PCI_ERR_ROOT_MULTI_COR_RCV | 819 (PCI_ERR_ROOT_MULTI_COR_RCV |
808 PCI_ERR_ROOT_MULTI_UNCOR_RCV)) 820 PCI_ERR_ROOT_MULTI_UNCOR_RCV))
809 e_info->flags |= AER_MULTI_ERROR_VALID_FLAG; 821 e_info->multi_error_valid = 1;
822
823 aer_print_port_info(p_device->port, e_info);
810 824
811 find_source_device(p_device->port, e_info); 825 find_source_device(p_device->port, e_info);
812 aer_process_err_devices(p_device, e_info); 826 aer_process_err_devices(p_device, e_info);
@@ -863,10 +877,5 @@ int aer_init(struct pcie_device *dev)
863 if (aer_osc_setup(dev) && !forceload) 877 if (aer_osc_setup(dev) && !forceload)
864 return -ENXIO; 878 return -ENXIO;
865 879
866 return AER_SUCCESS; 880 return 0;
867} 881}
868
869EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
870EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
871EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
872
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 0fc29ae80df8..44acde72294f 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -27,69 +27,70 @@
27#define AER_AGENT_COMPLETER 2 27#define AER_AGENT_COMPLETER 2
28#define AER_AGENT_TRANSMITTER 3 28#define AER_AGENT_TRANSMITTER 3
29 29
30#define AER_AGENT_REQUESTER_MASK (PCI_ERR_UNC_COMP_TIME| \ 30#define AER_AGENT_REQUESTER_MASK(t) ((t == AER_CORRECTABLE) ? \
31 PCI_ERR_UNC_UNSUP) 31 0 : (PCI_ERR_UNC_COMP_TIME|PCI_ERR_UNC_UNSUP))
32 32#define AER_AGENT_COMPLETER_MASK(t) ((t == AER_CORRECTABLE) ? \
33#define AER_AGENT_COMPLETER_MASK PCI_ERR_UNC_COMP_ABORT 33 0 : PCI_ERR_UNC_COMP_ABORT)
34 34#define AER_AGENT_TRANSMITTER_MASK(t) ((t == AER_CORRECTABLE) ? \
35#define AER_AGENT_TRANSMITTER_MASK(t, e) (e & (PCI_ERR_COR_REP_ROLL| \ 35 (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : 0)
36 ((t == AER_CORRECTABLE) ? PCI_ERR_COR_REP_TIMER: 0)))
37 36
38#define AER_GET_AGENT(t, e) \ 37#define AER_GET_AGENT(t, e) \
39 ((e & AER_AGENT_COMPLETER_MASK) ? AER_AGENT_COMPLETER : \ 38 ((e & AER_AGENT_COMPLETER_MASK(t)) ? AER_AGENT_COMPLETER : \
40 (e & AER_AGENT_REQUESTER_MASK) ? AER_AGENT_REQUESTER : \ 39 (e & AER_AGENT_REQUESTER_MASK(t)) ? AER_AGENT_REQUESTER : \
41 (AER_AGENT_TRANSMITTER_MASK(t, e)) ? AER_AGENT_TRANSMITTER : \ 40 (e & AER_AGENT_TRANSMITTER_MASK(t)) ? AER_AGENT_TRANSMITTER : \
42 AER_AGENT_RECEIVER) 41 AER_AGENT_RECEIVER)
43 42
44#define AER_PHYSICAL_LAYER_ERROR_MASK PCI_ERR_COR_RCVR
45#define AER_DATA_LINK_LAYER_ERROR_MASK(t, e) \
46 (PCI_ERR_UNC_DLP| \
47 PCI_ERR_COR_BAD_TLP| \
48 PCI_ERR_COR_BAD_DLLP| \
49 PCI_ERR_COR_REP_ROLL| \
50 ((t == AER_CORRECTABLE) ? \
51 PCI_ERR_COR_REP_TIMER: 0))
52
53#define AER_PHYSICAL_LAYER_ERROR 0 43#define AER_PHYSICAL_LAYER_ERROR 0
54#define AER_DATA_LINK_LAYER_ERROR 1 44#define AER_DATA_LINK_LAYER_ERROR 1
55#define AER_TRANSACTION_LAYER_ERROR 2 45#define AER_TRANSACTION_LAYER_ERROR 2
56 46
57#define AER_GET_LAYER_ERROR(t, e) \ 47#define AER_PHYSICAL_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
58 ((e & AER_PHYSICAL_LAYER_ERROR_MASK) ? \ 48 PCI_ERR_COR_RCVR : 0)
59 AER_PHYSICAL_LAYER_ERROR : \ 49#define AER_DATA_LINK_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
60 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t, e)) ? \ 50 (PCI_ERR_COR_BAD_TLP| \
61 AER_DATA_LINK_LAYER_ERROR : \ 51 PCI_ERR_COR_BAD_DLLP| \
62 AER_TRANSACTION_LAYER_ERROR) 52 PCI_ERR_COR_REP_ROLL| \
53 PCI_ERR_COR_REP_TIMER) : PCI_ERR_UNC_DLP)
54
55#define AER_GET_LAYER_ERROR(t, e) \
56 ((e & AER_PHYSICAL_LAYER_ERROR_MASK(t)) ? AER_PHYSICAL_LAYER_ERROR : \
57 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
58 AER_TRANSACTION_LAYER_ERROR)
59
60#define AER_PR(info, pdev, fmt, args...) \
61 printk("%s%s %s: " fmt, (info->severity == AER_CORRECTABLE) ? \
62 KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev), \
63 dev_name(&pdev->dev), ## args)
63 64
64/* 65/*
65 * AER error strings 66 * AER error strings
66 */ 67 */
67static char* aer_error_severity_string[] = { 68static char *aer_error_severity_string[] = {
68 "Uncorrected (Non-Fatal)", 69 "Uncorrected (Non-Fatal)",
69 "Uncorrected (Fatal)", 70 "Uncorrected (Fatal)",
70 "Corrected" 71 "Corrected"
71}; 72};
72 73
73static char* aer_error_layer[] = { 74static char *aer_error_layer[] = {
74 "Physical Layer", 75 "Physical Layer",
75 "Data Link Layer", 76 "Data Link Layer",
76 "Transaction Layer" 77 "Transaction Layer"
77}; 78};
78static char* aer_correctable_error_string[] = { 79static char *aer_correctable_error_string[] = {
79 "Receiver Error ", /* Bit Position 0 */ 80 "Receiver Error ", /* Bit Position 0 */
80 NULL, 81 NULL,
81 NULL, 82 NULL,
82 NULL, 83 NULL,
83 NULL, 84 NULL,
84 NULL, 85 NULL,
85 "Bad TLP ", /* Bit Position 6 */ 86 "Bad TLP ", /* Bit Position 6 */
86 "Bad DLLP ", /* Bit Position 7 */ 87 "Bad DLLP ", /* Bit Position 7 */
87 "RELAY_NUM Rollover ", /* Bit Position 8 */ 88 "RELAY_NUM Rollover ", /* Bit Position 8 */
88 NULL, 89 NULL,
89 NULL, 90 NULL,
90 NULL, 91 NULL,
91 "Replay Timer Timeout ", /* Bit Position 12 */ 92 "Replay Timer Timeout ", /* Bit Position 12 */
92 "Advisory Non-Fatal ", /* Bit Position 13 */ 93 "Advisory Non-Fatal ", /* Bit Position 13 */
93 NULL, 94 NULL,
94 NULL, 95 NULL,
95 NULL, 96 NULL,
@@ -110,7 +111,7 @@ static char* aer_correctable_error_string[] = {
110 NULL, 111 NULL,
111}; 112};
112 113
113static char* aer_uncorrectable_error_string[] = { 114static char *aer_uncorrectable_error_string[] = {
114 NULL, 115 NULL,
115 NULL, 116 NULL,
116 NULL, 117 NULL,
@@ -123,10 +124,10 @@ static char* aer_uncorrectable_error_string[] = {
123 NULL, 124 NULL,
124 NULL, 125 NULL,
125 NULL, 126 NULL,
126 "Poisoned TLP ", /* Bit Position 12 */ 127 "Poisoned TLP ", /* Bit Position 12 */
127 "Flow Control Protocol ", /* Bit Position 13 */ 128 "Flow Control Protocol ", /* Bit Position 13 */
128 "Completion Timeout ", /* Bit Position 14 */ 129 "Completion Timeout ", /* Bit Position 14 */
129 "Completer Abort ", /* Bit Position 15 */ 130 "Completer Abort ", /* Bit Position 15 */
130 "Unexpected Completion ", /* Bit Position 16 */ 131 "Unexpected Completion ", /* Bit Position 16 */
131 "Receiver Overflow ", /* Bit Position 17 */ 132 "Receiver Overflow ", /* Bit Position 17 */
132 "Malformed TLP ", /* Bit Position 18 */ 133 "Malformed TLP ", /* Bit Position 18 */
@@ -145,98 +146,69 @@ static char* aer_uncorrectable_error_string[] = {
145 NULL, 146 NULL,
146}; 147};
147 148
148static char* aer_agent_string[] = { 149static char *aer_agent_string[] = {
149 "Receiver ID", 150 "Receiver ID",
150 "Requester ID", 151 "Requester ID",
151 "Completer ID", 152 "Completer ID",
152 "Transmitter ID" 153 "Transmitter ID"
153}; 154};
154 155
155static char * aer_get_error_source_name(int severity, 156static void __aer_print_error(struct aer_err_info *info, struct pci_dev *dev)
156 unsigned int status,
157 char errmsg_buff[])
158{ 157{
159 int i; 158 int i, status;
160 char * errmsg = NULL; 159 char *errmsg = NULL;
160
161 status = (info->status & ~info->mask);
161 162
162 for (i = 0; i < 32; i++) { 163 for (i = 0; i < 32; i++) {
163 if (!(status & (1 << i))) 164 if (!(status & (1 << i)))
164 continue; 165 continue;
165 166
166 if (severity == AER_CORRECTABLE) 167 if (info->severity == AER_CORRECTABLE)
167 errmsg = aer_correctable_error_string[i]; 168 errmsg = aer_correctable_error_string[i];
168 else 169 else
169 errmsg = aer_uncorrectable_error_string[i]; 170 errmsg = aer_uncorrectable_error_string[i];
170 171
171 if (!errmsg) { 172 if (errmsg)
172 sprintf(errmsg_buff, "Unknown Error Bit %2d ", i); 173 AER_PR(info, dev, " [%2d] %s%s\n", i, errmsg,
173 errmsg = errmsg_buff; 174 info->first_error == i ? " (First)" : "");
174 } 175 else
175 176 AER_PR(info, dev, " [%2d] Unknown Error Bit%s\n", i,
176 break; 177 info->first_error == i ? " (First)" : "");
177 } 178 }
178
179 return errmsg;
180} 179}
181 180
182static DEFINE_SPINLOCK(logbuf_lock);
183static char errmsg_buff[100];
184void aer_print_error(struct pci_dev *dev, struct aer_err_info *info) 181void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
185{ 182{
186 char * errmsg; 183 int id = ((dev->bus->number << 8) | dev->devfn);
187 int err_layer, agent; 184
188 char * loglevel; 185 if (info->status == 0) {
189 186 AER_PR(info, dev,
190 if (info->severity == AER_CORRECTABLE) 187 "PCIE Bus Error: severity=%s, type=Unaccessible, "
191 loglevel = KERN_WARNING; 188 "id=%04x(Unregistered Agent ID)\n",
192 else 189 aer_error_severity_string[info->severity], id);
193 loglevel = KERN_ERR;
194
195 printk("%s+------ PCI-Express Device Error ------+\n", loglevel);
196 printk("%sError Severity\t\t: %s\n", loglevel,
197 aer_error_severity_string[info->severity]);
198
199 if ( info->status == 0) {
200 printk("%sPCIE Bus Error type\t: (Unaccessible)\n", loglevel);
201 printk("%sUnaccessible Received\t: %s\n", loglevel,
202 info->flags & AER_MULTI_ERROR_VALID_FLAG ?
203 "Multiple" : "First");
204 printk("%sUnregistered Agent ID\t: %04x\n", loglevel,
205 (dev->bus->number << 8) | dev->devfn);
206 } else { 190 } else {
207 err_layer = AER_GET_LAYER_ERROR(info->severity, info->status); 191 int layer, agent;
208 printk("%sPCIE Bus Error type\t: %s\n", loglevel,
209 aer_error_layer[err_layer]);
210
211 spin_lock(&logbuf_lock);
212 errmsg = aer_get_error_source_name(info->severity,
213 info->status,
214 errmsg_buff);
215 printk("%s%s\t: %s\n", loglevel, errmsg,
216 info->flags & AER_MULTI_ERROR_VALID_FLAG ?
217 "Multiple" : "First");
218 spin_unlock(&logbuf_lock);
219 192
193 layer = AER_GET_LAYER_ERROR(info->severity, info->status);
220 agent = AER_GET_AGENT(info->severity, info->status); 194 agent = AER_GET_AGENT(info->severity, info->status);
221 printk("%s%s\t\t: %04x\n", loglevel, 195
222 aer_agent_string[agent], 196 AER_PR(info, dev,
223 (dev->bus->number << 8) | dev->devfn); 197 "PCIE Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
224 198 aer_error_severity_string[info->severity],
225 printk("%sVendorID=%04xh, DeviceID=%04xh," 199 aer_error_layer[layer], id, aer_agent_string[agent]);
226 " Bus=%02xh, Device=%02xh, Function=%02xh\n", 200
227 loglevel, 201 AER_PR(info, dev,
228 dev->vendor, 202 " device [%04x:%04x] error status/mask=%08x/%08x\n",
229 dev->device, 203 dev->vendor, dev->device, info->status, info->mask);
230 dev->bus->number, 204
231 PCI_SLOT(dev->devfn), 205 __aer_print_error(info, dev);
232 PCI_FUNC(dev->devfn)); 206
233 207 if (info->tlp_header_valid) {
234 if (info->flags & AER_TLP_HEADER_VALID_FLAG) {
235 unsigned char *tlp = (unsigned char *) &info->tlp; 208 unsigned char *tlp = (unsigned char *) &info->tlp;
236 printk("%sTLP Header:\n", loglevel); 209 AER_PR(info, dev, " TLP Header:"
237 printk("%s%02x%02x%02x%02x %02x%02x%02x%02x" 210 " %02x%02x%02x%02x %02x%02x%02x%02x"
238 " %02x%02x%02x%02x %02x%02x%02x%02x\n", 211 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
239 loglevel,
240 *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp, 212 *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
241 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4), 213 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
242 *(tlp + 11), *(tlp + 10), *(tlp + 9), 214 *(tlp + 11), *(tlp + 10), *(tlp + 9),
@@ -244,5 +216,15 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
244 *(tlp + 13), *(tlp + 12)); 216 *(tlp + 13), *(tlp + 12));
245 } 217 }
246 } 218 }
219
220 if (info->id && info->error_dev_num > 1 && info->id == id)
221 AER_PR(info, dev,
222 " Error of this Agent(%04x) is reported first\n", id);
247} 223}
248 224
225void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
226{
227 dev_info(&dev->dev, "AER: %s%s error received: id=%04x\n",
228 info->multi_error_valid ? "Multiple " : "",
229 aer_error_severity_string[info->severity], info->id);
230}
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 3d27c97e0486..f289ca9bf18d 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -26,6 +26,13 @@
26#endif 26#endif
27#define MODULE_PARAM_PREFIX "pcie_aspm." 27#define MODULE_PARAM_PREFIX "pcie_aspm."
28 28
29/* Note: those are not register definitions */
30#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
31#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
32#define ASPM_STATE_L1 (4) /* L1 state */
33#define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
34#define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
35
29struct aspm_latency { 36struct aspm_latency {
30 u32 l0s; /* L0s latency (nsec) */ 37 u32 l0s; /* L0s latency (nsec) */
31 u32 l1; /* L1 latency (nsec) */ 38 u32 l1; /* L1 latency (nsec) */
@@ -40,17 +47,20 @@ struct pcie_link_state {
40 struct list_head link; /* node in parent's children list */ 47 struct list_head link; /* node in parent's children list */
41 48
42 /* ASPM state */ 49 /* ASPM state */
43 u32 aspm_support:2; /* Supported ASPM state */ 50 u32 aspm_support:3; /* Supported ASPM state */
44 u32 aspm_enabled:2; /* Enabled ASPM state */ 51 u32 aspm_enabled:3; /* Enabled ASPM state */
45 u32 aspm_default:2; /* Default ASPM state by BIOS */ 52 u32 aspm_capable:3; /* Capable ASPM state with latency */
53 u32 aspm_default:3; /* Default ASPM state by BIOS */
54 u32 aspm_disable:3; /* Disabled ASPM state */
46 55
47 /* Clock PM state */ 56 /* Clock PM state */
48 u32 clkpm_capable:1; /* Clock PM capable? */ 57 u32 clkpm_capable:1; /* Clock PM capable? */
49 u32 clkpm_enabled:1; /* Current Clock PM state */ 58 u32 clkpm_enabled:1; /* Current Clock PM state */
50 u32 clkpm_default:1; /* Default Clock PM state by BIOS */ 59 u32 clkpm_default:1; /* Default Clock PM state by BIOS */
51 60
52 /* Latencies */ 61 /* Exit latencies */
53 struct aspm_latency latency; /* Exit latency */ 62 struct aspm_latency latency_up; /* Upstream direction exit latency */
63 struct aspm_latency latency_dw; /* Downstream direction exit latency */
54 /* 64 /*
55 * Endpoint acceptable latencies. A pcie downstream port only 65 * Endpoint acceptable latencies. A pcie downstream port only
56 * has one slot under it, so at most there are 8 functions. 66 * has one slot under it, so at most there are 8 functions.
@@ -82,7 +92,7 @@ static int policy_to_aspm_state(struct pcie_link_state *link)
82 return 0; 92 return 0;
83 case POLICY_POWERSAVE: 93 case POLICY_POWERSAVE:
84 /* Enable ASPM L0s/L1 */ 94 /* Enable ASPM L0s/L1 */
85 return PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1; 95 return ASPM_STATE_ALL;
86 case POLICY_DEFAULT: 96 case POLICY_DEFAULT:
87 return link->aspm_default; 97 return link->aspm_default;
88 } 98 }
@@ -164,18 +174,6 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
164 link->clkpm_capable = (blacklist) ? 0 : capable; 174 link->clkpm_capable = (blacklist) ? 0 : capable;
165} 175}
166 176
167static bool pcie_aspm_downstream_has_switch(struct pcie_link_state *link)
168{
169 struct pci_dev *child;
170 struct pci_bus *linkbus = link->pdev->subordinate;
171
172 list_for_each_entry(child, &linkbus->devices, bus_list) {
173 if (child->pcie_type == PCI_EXP_TYPE_UPSTREAM)
174 return true;
175 }
176 return false;
177}
178
179/* 177/*
180 * pcie_aspm_configure_common_clock: check if the 2 ends of a link 178 * pcie_aspm_configure_common_clock: check if the 2 ends of a link
181 * could use common clock. If they are, configure them to use the 179 * could use common clock. If they are, configure them to use the
@@ -288,71 +286,133 @@ static u32 calc_l1_acceptable(u32 encoding)
288 return (1000 << encoding); 286 return (1000 << encoding);
289} 287}
290 288
291static void pcie_aspm_get_cap_device(struct pci_dev *pdev, u32 *state, 289struct aspm_register_info {
292 u32 *l0s, u32 *l1, u32 *enabled) 290 u32 support:2;
291 u32 enabled:2;
292 u32 latency_encoding_l0s;
293 u32 latency_encoding_l1;
294};
295
296static void pcie_get_aspm_reg(struct pci_dev *pdev,
297 struct aspm_register_info *info)
293{ 298{
294 int pos; 299 int pos;
295 u16 reg16; 300 u16 reg16;
296 u32 reg32, encoding; 301 u32 reg32;
297 302
298 *l0s = *l1 = *enabled = 0;
299 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 303 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
300 pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &reg32); 304 pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &reg32);
301 *state = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10; 305 info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10;
302 if (*state != PCIE_LINK_STATE_L0S && 306 /* 00b and 10b are defined as "Reserved". */
303 *state != (PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_L0S)) 307 if (info->support == PCIE_LINK_STATE_L1)
304 *state = 0; 308 info->support = 0;
305 if (*state == 0) 309 info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12;
310 info->latency_encoding_l1 = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15;
311 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
312 info->enabled = reg16 & PCI_EXP_LNKCTL_ASPMC;
313}
314
315static void pcie_aspm_check_latency(struct pci_dev *endpoint)
316{
317 u32 latency, l1_switch_latency = 0;
318 struct aspm_latency *acceptable;
319 struct pcie_link_state *link;
320
321 /* Device not in D0 doesn't need latency check */
322 if ((endpoint->current_state != PCI_D0) &&
323 (endpoint->current_state != PCI_UNKNOWN))
306 return; 324 return;
307 325
308 encoding = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12; 326 link = endpoint->bus->self->link_state;
309 *l0s = calc_l0s_latency(encoding); 327 acceptable = &link->acceptable[PCI_FUNC(endpoint->devfn)];
310 if (*state & PCIE_LINK_STATE_L1) { 328
311 encoding = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15; 329 while (link) {
312 *l1 = calc_l1_latency(encoding); 330 /* Check upstream direction L0s latency */
331 if ((link->aspm_capable & ASPM_STATE_L0S_UP) &&
332 (link->latency_up.l0s > acceptable->l0s))
333 link->aspm_capable &= ~ASPM_STATE_L0S_UP;
334
335 /* Check downstream direction L0s latency */
336 if ((link->aspm_capable & ASPM_STATE_L0S_DW) &&
337 (link->latency_dw.l0s > acceptable->l0s))
338 link->aspm_capable &= ~ASPM_STATE_L0S_DW;
339 /*
340 * Check L1 latency.
341 * Every switch on the path to root complex need 1
342 * more microsecond for L1. Spec doesn't mention L0s.
343 */
344 latency = max_t(u32, link->latency_up.l1, link->latency_dw.l1);
345 if ((link->aspm_capable & ASPM_STATE_L1) &&
346 (latency + l1_switch_latency > acceptable->l1))
347 link->aspm_capable &= ~ASPM_STATE_L1;
348 l1_switch_latency += 1000;
349
350 link = link->parent;
313 } 351 }
314 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
315 *enabled = reg16 & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1);
316} 352}
317 353
318static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) 354static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
319{ 355{
320 u32 support, l0s, l1, enabled;
321 struct pci_dev *child, *parent = link->pdev; 356 struct pci_dev *child, *parent = link->pdev;
322 struct pci_bus *linkbus = parent->subordinate; 357 struct pci_bus *linkbus = parent->subordinate;
358 struct aspm_register_info upreg, dwreg;
323 359
324 if (blacklist) { 360 if (blacklist) {
325 /* Set support state to 0, so we will disable ASPM later */ 361 /* Set enabled/disable so that we will disable ASPM later */
326 link->aspm_support = 0; 362 link->aspm_enabled = ASPM_STATE_ALL;
327 link->aspm_default = 0; 363 link->aspm_disable = ASPM_STATE_ALL;
328 link->aspm_enabled = PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1;
329 return; 364 return;
330 } 365 }
331 366
332 /* Configure common clock before checking latencies */ 367 /* Configure common clock before checking latencies */
333 pcie_aspm_configure_common_clock(link); 368 pcie_aspm_configure_common_clock(link);
334 369
335 /* upstream component states */ 370 /* Get upstream/downstream components' register state */
336 pcie_aspm_get_cap_device(parent, &support, &l0s, &l1, &enabled); 371 pcie_get_aspm_reg(parent, &upreg);
337 link->aspm_support = support;
338 link->latency.l0s = l0s;
339 link->latency.l1 = l1;
340 link->aspm_enabled = enabled;
341
342 /* downstream component states, all functions have the same setting */
343 child = list_entry(linkbus->devices.next, struct pci_dev, bus_list); 372 child = list_entry(linkbus->devices.next, struct pci_dev, bus_list);
344 pcie_aspm_get_cap_device(child, &support, &l0s, &l1, &enabled); 373 pcie_get_aspm_reg(child, &dwreg);
345 link->aspm_support &= support;
346 link->latency.l0s = max_t(u32, link->latency.l0s, l0s);
347 link->latency.l1 = max_t(u32, link->latency.l1, l1);
348 374
349 if (!link->aspm_support) 375 /*
350 return; 376 * Setup L0s state
351 377 *
352 link->aspm_enabled &= link->aspm_support; 378 * Note that we must not enable L0s in either direction on a
379 * given link unless components on both sides of the link each
380 * support L0s.
381 */
382 if (dwreg.support & upreg.support & PCIE_LINK_STATE_L0S)
383 link->aspm_support |= ASPM_STATE_L0S;
384 if (dwreg.enabled & PCIE_LINK_STATE_L0S)
385 link->aspm_enabled |= ASPM_STATE_L0S_UP;
386 if (upreg.enabled & PCIE_LINK_STATE_L0S)
387 link->aspm_enabled |= ASPM_STATE_L0S_DW;
388 link->latency_up.l0s = calc_l0s_latency(upreg.latency_encoding_l0s);
389 link->latency_dw.l0s = calc_l0s_latency(dwreg.latency_encoding_l0s);
390
391 /* Setup L1 state */
392 if (upreg.support & dwreg.support & PCIE_LINK_STATE_L1)
393 link->aspm_support |= ASPM_STATE_L1;
394 if (upreg.enabled & dwreg.enabled & PCIE_LINK_STATE_L1)
395 link->aspm_enabled |= ASPM_STATE_L1;
396 link->latency_up.l1 = calc_l1_latency(upreg.latency_encoding_l1);
397 link->latency_dw.l1 = calc_l1_latency(dwreg.latency_encoding_l1);
398
399 /* Save default state */
353 link->aspm_default = link->aspm_enabled; 400 link->aspm_default = link->aspm_enabled;
354 401
355 /* ENDPOINT states*/ 402 /* Setup initial capable state. Will be updated later */
403 link->aspm_capable = link->aspm_support;
404 /*
405 * If the downstream component has pci bridge function, don't
406 * do ASPM for now.
407 */
408 list_for_each_entry(child, &linkbus->devices, bus_list) {
409 if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) {
410 link->aspm_disable = ASPM_STATE_ALL;
411 break;
412 }
413 }
414
415 /* Get and check endpoint acceptable latencies */
356 list_for_each_entry(child, &linkbus->devices, bus_list) { 416 list_for_each_entry(child, &linkbus->devices, bus_list) {
357 int pos; 417 int pos;
358 u32 reg32, encoding; 418 u32 reg32, encoding;
@@ -365,109 +425,46 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
365 425
366 pos = pci_find_capability(child, PCI_CAP_ID_EXP); 426 pos = pci_find_capability(child, PCI_CAP_ID_EXP);
367 pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, &reg32); 427 pci_read_config_dword(child, pos + PCI_EXP_DEVCAP, &reg32);
428 /* Calculate endpoint L0s acceptable latency */
368 encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6; 429 encoding = (reg32 & PCI_EXP_DEVCAP_L0S) >> 6;
369 acceptable->l0s = calc_l0s_acceptable(encoding); 430 acceptable->l0s = calc_l0s_acceptable(encoding);
370 if (link->aspm_support & PCIE_LINK_STATE_L1) { 431 /* Calculate endpoint L1 acceptable latency */
371 encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9; 432 encoding = (reg32 & PCI_EXP_DEVCAP_L1) >> 9;
372 acceptable->l1 = calc_l1_acceptable(encoding); 433 acceptable->l1 = calc_l1_acceptable(encoding);
373 }
374 }
375}
376
377/**
378 * __pcie_aspm_check_state_one - check latency for endpoint device.
379 * @endpoint: pointer to the struct pci_dev of endpoint device
380 *
381 * TBD: The latency from the endpoint to root complex vary per switch's
382 * upstream link state above the device. Here we just do a simple check
383 * which assumes all links above the device can be in L1 state, that
384 * is we just consider the worst case. If switch's upstream link can't
385 * be put into L0S/L1, then our check is too strictly.
386 */
387static u32 __pcie_aspm_check_state_one(struct pci_dev *endpoint, u32 state)
388{
389 u32 l1_switch_latency = 0;
390 struct aspm_latency *acceptable;
391 struct pcie_link_state *link;
392
393 link = endpoint->bus->self->link_state;
394 state &= link->aspm_support;
395 acceptable = &link->acceptable[PCI_FUNC(endpoint->devfn)];
396 434
397 while (link && state) { 435 pcie_aspm_check_latency(child);
398 if ((state & PCIE_LINK_STATE_L0S) &&
399 (link->latency.l0s > acceptable->l0s))
400 state &= ~PCIE_LINK_STATE_L0S;
401 if ((state & PCIE_LINK_STATE_L1) &&
402 (link->latency.l1 + l1_switch_latency > acceptable->l1))
403 state &= ~PCIE_LINK_STATE_L1;
404 link = link->parent;
405 /*
406 * Every switch on the path to root complex need 1
407 * more microsecond for L1. Spec doesn't mention L0s.
408 */
409 l1_switch_latency += 1000;
410 }
411 return state;
412}
413
414static u32 pcie_aspm_check_state(struct pcie_link_state *link, u32 state)
415{
416 pci_power_t power_state;
417 struct pci_dev *child;
418 struct pci_bus *linkbus = link->pdev->subordinate;
419
420 /* If no child, ignore the link */
421 if (list_empty(&linkbus->devices))
422 return state;
423
424 list_for_each_entry(child, &linkbus->devices, bus_list) {
425 /*
426 * If downstream component of a link is pci bridge, we
427 * disable ASPM for now for the link
428 */
429 if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE)
430 return 0;
431
432 if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT &&
433 child->pcie_type != PCI_EXP_TYPE_LEG_END))
434 continue;
435 /* Device not in D0 doesn't need check latency */
436 power_state = child->current_state;
437 if (power_state == PCI_D1 || power_state == PCI_D2 ||
438 power_state == PCI_D3hot || power_state == PCI_D3cold)
439 continue;
440 state = __pcie_aspm_check_state_one(child, state);
441 } 436 }
442 return state;
443} 437}
444 438
445static void __pcie_aspm_config_one_dev(struct pci_dev *pdev, unsigned int state) 439static void pcie_config_aspm_dev(struct pci_dev *pdev, u32 val)
446{ 440{
447 u16 reg16; 441 u16 reg16;
448 int pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 442 int pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
449 443
450 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); 444 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
451 reg16 &= ~0x3; 445 reg16 &= ~0x3;
452 reg16 |= state; 446 reg16 |= val;
453 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); 447 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
454} 448}
455 449
456static void __pcie_aspm_config_link(struct pcie_link_state *link, u32 state) 450static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state)
457{ 451{
452 u32 upstream = 0, dwstream = 0;
458 struct pci_dev *child, *parent = link->pdev; 453 struct pci_dev *child, *parent = link->pdev;
459 struct pci_bus *linkbus = parent->subordinate; 454 struct pci_bus *linkbus = parent->subordinate;
460 455
461 /* If no child, disable the link */ 456 /* Nothing to do if the link is already in the requested state */
462 if (list_empty(&linkbus->devices)) 457 state &= (link->aspm_capable & ~link->aspm_disable);
463 state = 0; 458 if (link->aspm_enabled == state)
464 /* 459 return;
465 * If the downstream component has pci bridge function, don't 460 /* Convert ASPM state to upstream/downstream ASPM register state */
466 * do ASPM now. 461 if (state & ASPM_STATE_L0S_UP)
467 */ 462 dwstream |= PCIE_LINK_STATE_L0S;
468 list_for_each_entry(child, &linkbus->devices, bus_list) { 463 if (state & ASPM_STATE_L0S_DW)
469 if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) 464 upstream |= PCIE_LINK_STATE_L0S;
470 return; 465 if (state & ASPM_STATE_L1) {
466 upstream |= PCIE_LINK_STATE_L1;
467 dwstream |= PCIE_LINK_STATE_L1;
471 } 468 }
472 /* 469 /*
473 * Spec 2.0 suggests all functions should be configured the 470 * Spec 2.0 suggests all functions should be configured the
@@ -475,67 +472,24 @@ static void __pcie_aspm_config_link(struct pcie_link_state *link, u32 state)
475 * upstream component first and then downstream, and vice 472 * upstream component first and then downstream, and vice
476 * versa for disabling ASPM L1. Spec doesn't mention L0S. 473 * versa for disabling ASPM L1. Spec doesn't mention L0S.
477 */ 474 */
478 if (state & PCIE_LINK_STATE_L1) 475 if (state & ASPM_STATE_L1)
479 __pcie_aspm_config_one_dev(parent, state); 476 pcie_config_aspm_dev(parent, upstream);
480
481 list_for_each_entry(child, &linkbus->devices, bus_list) 477 list_for_each_entry(child, &linkbus->devices, bus_list)
482 __pcie_aspm_config_one_dev(child, state); 478 pcie_config_aspm_dev(child, dwstream);
483 479 if (!(state & ASPM_STATE_L1))
484 if (!(state & PCIE_LINK_STATE_L1)) 480 pcie_config_aspm_dev(parent, upstream);
485 __pcie_aspm_config_one_dev(parent, state);
486 481
487 link->aspm_enabled = state; 482 link->aspm_enabled = state;
488} 483}
489 484
490/* Check the whole hierarchy, and configure each link in the hierarchy */ 485static void pcie_config_aspm_path(struct pcie_link_state *link)
491static void __pcie_aspm_configure_link_state(struct pcie_link_state *link,
492 u32 state)
493{ 486{
494 struct pcie_link_state *leaf, *root = link->root; 487 while (link) {
495 488 pcie_config_aspm_link(link, policy_to_aspm_state(link));
496 state &= (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 489 link = link->parent;
497
498 /* Check all links who have specific root port link */
499 list_for_each_entry(leaf, &link_list, sibling) {
500 if (!list_empty(&leaf->children) || (leaf->root != root))
501 continue;
502 state = pcie_aspm_check_state(leaf, state);
503 }
504 /* Check root port link too in case it hasn't children */
505 state = pcie_aspm_check_state(root, state);
506 if (link->aspm_enabled == state)
507 return;
508 /*
509 * We must change the hierarchy. See comments in
510 * __pcie_aspm_config_link for the order
511 **/
512 if (state & PCIE_LINK_STATE_L1) {
513 list_for_each_entry(leaf, &link_list, sibling) {
514 if (leaf->root == root)
515 __pcie_aspm_config_link(leaf, state);
516 }
517 } else {
518 list_for_each_entry_reverse(leaf, &link_list, sibling) {
519 if (leaf->root == root)
520 __pcie_aspm_config_link(leaf, state);
521 }
522 } 490 }
523} 491}
524 492
525/*
526 * pcie_aspm_configure_link_state: enable/disable PCI express link state
527 * @pdev: the root port or switch downstream port
528 */
529static void pcie_aspm_configure_link_state(struct pcie_link_state *link,
530 u32 state)
531{
532 down_read(&pci_bus_sem);
533 mutex_lock(&aspm_lock);
534 __pcie_aspm_configure_link_state(link, state);
535 mutex_unlock(&aspm_lock);
536 up_read(&pci_bus_sem);
537}
538
539static void free_link_state(struct pcie_link_state *link) 493static void free_link_state(struct pcie_link_state *link)
540{ 494{
541 link->pdev->link_state = NULL; 495 link->pdev->link_state = NULL;
@@ -570,10 +524,9 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
570 return 0; 524 return 0;
571} 525}
572 526
573static struct pcie_link_state *pcie_aspm_setup_link_state(struct pci_dev *pdev) 527static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
574{ 528{
575 struct pcie_link_state *link; 529 struct pcie_link_state *link;
576 int blacklist = !!pcie_aspm_sanity_check(pdev);
577 530
578 link = kzalloc(sizeof(*link), GFP_KERNEL); 531 link = kzalloc(sizeof(*link), GFP_KERNEL);
579 if (!link) 532 if (!link)
@@ -599,15 +552,7 @@ static struct pcie_link_state *pcie_aspm_setup_link_state(struct pci_dev *pdev)
599 link->root = link->parent->root; 552 link->root = link->parent->root;
600 553
601 list_add(&link->sibling, &link_list); 554 list_add(&link->sibling, &link_list);
602
603 pdev->link_state = link; 555 pdev->link_state = link;
604
605 /* Check ASPM capability */
606 pcie_aspm_cap_init(link, blacklist);
607
608 /* Check Clock PM capability */
609 pcie_clkpm_cap_init(link, blacklist);
610
611 return link; 556 return link;
612} 557}
613 558
@@ -618,8 +563,8 @@ static struct pcie_link_state *pcie_aspm_setup_link_state(struct pci_dev *pdev)
618 */ 563 */
619void pcie_aspm_init_link_state(struct pci_dev *pdev) 564void pcie_aspm_init_link_state(struct pci_dev *pdev)
620{ 565{
621 u32 state;
622 struct pcie_link_state *link; 566 struct pcie_link_state *link;
567 int blacklist = !!pcie_aspm_sanity_check(pdev);
623 568
624 if (aspm_disabled || !pdev->is_pcie || pdev->link_state) 569 if (aspm_disabled || !pdev->is_pcie || pdev->link_state)
625 return; 570 return;
@@ -637,47 +582,64 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
637 goto out; 582 goto out;
638 583
639 mutex_lock(&aspm_lock); 584 mutex_lock(&aspm_lock);
640 link = pcie_aspm_setup_link_state(pdev); 585 link = alloc_pcie_link_state(pdev);
641 if (!link) 586 if (!link)
642 goto unlock; 587 goto unlock;
643 /* 588 /*
644 * Setup initial ASPM state 589 * Setup initial ASPM state. Note that we need to configure
645 * 590 * upstream links also because capable state of them can be
646 * If link has switch, delay the link config. The leaf link 591 * update through pcie_aspm_cap_init().
647 * initialization will config the whole hierarchy. But we must
648 * make sure BIOS doesn't set unsupported link state.
649 */ 592 */
650 if (pcie_aspm_downstream_has_switch(link)) { 593 pcie_aspm_cap_init(link, blacklist);
651 state = pcie_aspm_check_state(link, link->aspm_default); 594 pcie_config_aspm_path(link);
652 __pcie_aspm_config_link(link, state);
653 } else {
654 state = policy_to_aspm_state(link);
655 __pcie_aspm_configure_link_state(link, state);
656 }
657 595
658 /* Setup initial Clock PM state */ 596 /* Setup initial Clock PM state */
659 state = (link->clkpm_capable) ? policy_to_clkpm_state(link) : 0; 597 pcie_clkpm_cap_init(link, blacklist);
660 pcie_set_clkpm(link, state); 598 pcie_set_clkpm(link, policy_to_clkpm_state(link));
661unlock: 599unlock:
662 mutex_unlock(&aspm_lock); 600 mutex_unlock(&aspm_lock);
663out: 601out:
664 up_read(&pci_bus_sem); 602 up_read(&pci_bus_sem);
665} 603}
666 604
605/* Recheck latencies and update aspm_capable for links under the root */
606static void pcie_update_aspm_capable(struct pcie_link_state *root)
607{
608 struct pcie_link_state *link;
609 BUG_ON(root->parent);
610 list_for_each_entry(link, &link_list, sibling) {
611 if (link->root != root)
612 continue;
613 link->aspm_capable = link->aspm_support;
614 }
615 list_for_each_entry(link, &link_list, sibling) {
616 struct pci_dev *child;
617 struct pci_bus *linkbus = link->pdev->subordinate;
618 if (link->root != root)
619 continue;
620 list_for_each_entry(child, &linkbus->devices, bus_list) {
621 if ((child->pcie_type != PCI_EXP_TYPE_ENDPOINT) &&
622 (child->pcie_type != PCI_EXP_TYPE_LEG_END))
623 continue;
624 pcie_aspm_check_latency(child);
625 }
626 }
627}
628
667/* @pdev: the endpoint device */ 629/* @pdev: the endpoint device */
668void pcie_aspm_exit_link_state(struct pci_dev *pdev) 630void pcie_aspm_exit_link_state(struct pci_dev *pdev)
669{ 631{
670 struct pci_dev *parent = pdev->bus->self; 632 struct pci_dev *parent = pdev->bus->self;
671 struct pcie_link_state *link_state = parent->link_state; 633 struct pcie_link_state *link, *root, *parent_link;
672 634
673 if (aspm_disabled || !pdev->is_pcie || !parent || !link_state) 635 if (aspm_disabled || !pdev->is_pcie || !parent || !parent->link_state)
674 return; 636 return;
675 if (parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 637 if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
676 parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) 638 (parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
677 return; 639 return;
640
678 down_read(&pci_bus_sem); 641 down_read(&pci_bus_sem);
679 mutex_lock(&aspm_lock); 642 mutex_lock(&aspm_lock);
680
681 /* 643 /*
682 * All PCIe functions are in one slot, remove one function will remove 644 * All PCIe functions are in one slot, remove one function will remove
683 * the whole slot, so just wait until we are the last function left. 645 * the whole slot, so just wait until we are the last function left.
@@ -685,13 +647,20 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
685 if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices)) 647 if (!list_is_last(&pdev->bus_list, &parent->subordinate->devices))
686 goto out; 648 goto out;
687 649
650 link = parent->link_state;
651 root = link->root;
652 parent_link = link->parent;
653
688 /* All functions are removed, so just disable ASPM for the link */ 654 /* All functions are removed, so just disable ASPM for the link */
689 __pcie_aspm_config_one_dev(parent, 0); 655 pcie_config_aspm_link(link, 0);
690 list_del(&link_state->sibling); 656 list_del(&link->sibling);
691 list_del(&link_state->link); 657 list_del(&link->link);
692 /* Clock PM is for endpoint device */ 658 /* Clock PM is for endpoint device */
659 free_link_state(link);
693 660
694 free_link_state(link_state); 661 /* Recheck latencies and configure upstream links */
662 pcie_update_aspm_capable(root);
663 pcie_config_aspm_path(parent_link);
695out: 664out:
696 mutex_unlock(&aspm_lock); 665 mutex_unlock(&aspm_lock);
697 up_read(&pci_bus_sem); 666 up_read(&pci_bus_sem);
@@ -700,18 +669,23 @@ out:
700/* @pdev: the root port or switch downstream port */ 669/* @pdev: the root port or switch downstream port */
701void pcie_aspm_pm_state_change(struct pci_dev *pdev) 670void pcie_aspm_pm_state_change(struct pci_dev *pdev)
702{ 671{
703 struct pcie_link_state *link_state = pdev->link_state; 672 struct pcie_link_state *link = pdev->link_state;
704 673
705 if (aspm_disabled || !pdev->is_pcie || !pdev->link_state) 674 if (aspm_disabled || !pdev->is_pcie || !link)
706 return; 675 return;
707 if (pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT && 676 if ((pdev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
708 pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM) 677 (pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
709 return; 678 return;
710 /* 679 /*
711 * devices changed PM state, we should recheck if latency meets all 680 * Devices changed PM state, we should recheck if latency
712 * functions' requirement 681 * meets all functions' requirement
713 */ 682 */
714 pcie_aspm_configure_link_state(link_state, link_state->aspm_enabled); 683 down_read(&pci_bus_sem);
684 mutex_lock(&aspm_lock);
685 pcie_update_aspm_capable(link->root);
686 pcie_config_aspm_path(link);
687 mutex_unlock(&aspm_lock);
688 up_read(&pci_bus_sem);
715} 689}
716 690
717/* 691/*
@@ -721,7 +695,7 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev)
721void pci_disable_link_state(struct pci_dev *pdev, int state) 695void pci_disable_link_state(struct pci_dev *pdev, int state)
722{ 696{
723 struct pci_dev *parent = pdev->bus->self; 697 struct pci_dev *parent = pdev->bus->self;
724 struct pcie_link_state *link_state; 698 struct pcie_link_state *link;
725 699
726 if (aspm_disabled || !pdev->is_pcie) 700 if (aspm_disabled || !pdev->is_pcie)
727 return; 701 return;
@@ -733,12 +707,16 @@ void pci_disable_link_state(struct pci_dev *pdev, int state)
733 707
734 down_read(&pci_bus_sem); 708 down_read(&pci_bus_sem);
735 mutex_lock(&aspm_lock); 709 mutex_lock(&aspm_lock);
736 link_state = parent->link_state; 710 link = parent->link_state;
737 link_state->aspm_support &= ~state; 711 if (state & PCIE_LINK_STATE_L0S)
738 __pcie_aspm_configure_link_state(link_state, link_state->aspm_enabled); 712 link->aspm_disable |= ASPM_STATE_L0S;
713 if (state & PCIE_LINK_STATE_L1)
714 link->aspm_disable |= ASPM_STATE_L1;
715 pcie_config_aspm_link(link, policy_to_aspm_state(link));
716
739 if (state & PCIE_LINK_STATE_CLKPM) { 717 if (state & PCIE_LINK_STATE_CLKPM) {
740 link_state->clkpm_capable = 0; 718 link->clkpm_capable = 0;
741 pcie_set_clkpm(link_state, 0); 719 pcie_set_clkpm(link, 0);
742 } 720 }
743 mutex_unlock(&aspm_lock); 721 mutex_unlock(&aspm_lock);
744 up_read(&pci_bus_sem); 722 up_read(&pci_bus_sem);
@@ -748,7 +726,7 @@ EXPORT_SYMBOL(pci_disable_link_state);
748static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp) 726static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
749{ 727{
750 int i; 728 int i;
751 struct pcie_link_state *link_state; 729 struct pcie_link_state *link;
752 730
753 for (i = 0; i < ARRAY_SIZE(policy_str); i++) 731 for (i = 0; i < ARRAY_SIZE(policy_str); i++)
754 if (!strncmp(val, policy_str[i], strlen(policy_str[i]))) 732 if (!strncmp(val, policy_str[i], strlen(policy_str[i])))
@@ -761,10 +739,9 @@ static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
761 down_read(&pci_bus_sem); 739 down_read(&pci_bus_sem);
762 mutex_lock(&aspm_lock); 740 mutex_lock(&aspm_lock);
763 aspm_policy = i; 741 aspm_policy = i;
764 list_for_each_entry(link_state, &link_list, sibling) { 742 list_for_each_entry(link, &link_list, sibling) {
765 __pcie_aspm_configure_link_state(link_state, 743 pcie_config_aspm_link(link, policy_to_aspm_state(link));
766 policy_to_aspm_state(link_state)); 744 pcie_set_clkpm(link, policy_to_clkpm_state(link));
767 pcie_set_clkpm(link_state, policy_to_clkpm_state(link_state));
768 } 745 }
769 mutex_unlock(&aspm_lock); 746 mutex_unlock(&aspm_lock);
770 up_read(&pci_bus_sem); 747 up_read(&pci_bus_sem);
@@ -802,18 +779,28 @@ static ssize_t link_state_store(struct device *dev,
802 size_t n) 779 size_t n)
803{ 780{
804 struct pci_dev *pdev = to_pci_dev(dev); 781 struct pci_dev *pdev = to_pci_dev(dev);
805 int state; 782 struct pcie_link_state *link, *root = pdev->link_state->root;
783 u32 val = buf[0] - '0', state = 0;
806 784
807 if (n < 1) 785 if (n < 1 || val > 3)
808 return -EINVAL; 786 return -EINVAL;
809 state = buf[0]-'0';
810 if (state >= 0 && state <= 3) {
811 /* setup link aspm state */
812 pcie_aspm_configure_link_state(pdev->link_state, state);
813 return n;
814 }
815 787
816 return -EINVAL; 788 /* Convert requested state to ASPM state */
789 if (val & PCIE_LINK_STATE_L0S)
790 state |= ASPM_STATE_L0S;
791 if (val & PCIE_LINK_STATE_L1)
792 state |= ASPM_STATE_L1;
793
794 down_read(&pci_bus_sem);
795 mutex_lock(&aspm_lock);
796 list_for_each_entry(link, &link_list, sibling) {
797 if (link->root != root)
798 continue;
799 pcie_config_aspm_link(link, state);
800 }
801 mutex_unlock(&aspm_lock);
802 up_read(&pci_bus_sem);
803 return n;
817} 804}
818 805
819static ssize_t clk_ctl_show(struct device *dev, 806static ssize_t clk_ctl_show(struct device *dev,
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 13ffdc35ea0e..52f84fca9f7d 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -187,14 +187,9 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
187 */ 187 */
188static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask) 188static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
189{ 189{
190 struct pcie_port_data *port_data = pci_get_drvdata(dev);
191 int irq, interrupt_mode = PCIE_PORT_NO_IRQ; 190 int irq, interrupt_mode = PCIE_PORT_NO_IRQ;
192 int i; 191 int i;
193 192
194 /* Check MSI quirk */
195 if (port_data->port_type == PCIE_RC_PORT && pcie_mch_quirk)
196 goto Fallback;
197
198 /* Try to use MSI-X if supported */ 193 /* Try to use MSI-X if supported */
199 if (!pcie_port_enable_msix(dev, vectors, mask)) 194 if (!pcie_port_enable_msix(dev, vectors, mask))
200 return PCIE_PORT_MSIX_MODE; 195 return PCIE_PORT_MSIX_MODE;
@@ -203,7 +198,6 @@ static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
203 if (!pci_enable_msi(dev)) 198 if (!pci_enable_msi(dev))
204 interrupt_mode = PCIE_PORT_MSI_MODE; 199 interrupt_mode = PCIE_PORT_MSI_MODE;
205 200
206 Fallback:
207 if (interrupt_mode == PCIE_PORT_NO_IRQ && dev->pin) 201 if (interrupt_mode == PCIE_PORT_NO_IRQ && dev->pin)
208 interrupt_mode = PCIE_PORT_INTx_MODE; 202 interrupt_mode = PCIE_PORT_INTx_MODE;
209 203
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 091ce70051e0..6df5c984a791 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -205,6 +205,7 @@ static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
205 205
206 /* If fatal, restore cfg space for possible link reset at upstream */ 206 /* If fatal, restore cfg space for possible link reset at upstream */
207 if (dev->error_state == pci_channel_io_frozen) { 207 if (dev->error_state == pci_channel_io_frozen) {
208 dev->state_saved = true;
208 pci_restore_state(dev); 209 pci_restore_state(dev);
209 pcie_portdrv_restore_config(dev); 210 pcie_portdrv_restore_config(dev);
210 pci_enable_pcie_error_reporting(dev); 211 pci_enable_pcie_error_reporting(dev);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 40e75f6a5056..8105e32117f6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -235,7 +235,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
235 res->start = l64; 235 res->start = l64;
236 res->end = l64 + sz64; 236 res->end = l64 + sz64;
237 dev_printk(KERN_DEBUG, &dev->dev, 237 dev_printk(KERN_DEBUG, &dev->dev,
238 "reg %x 64bit mmio: %pR\n", pos, res); 238 "reg %x %s: %pR\n", pos,
239 (res->flags & IORESOURCE_PREFETCH) ?
240 "64bit mmio pref" : "64bit mmio",
241 res);
239 } 242 }
240 243
241 res->flags |= IORESOURCE_MEM_64; 244 res->flags |= IORESOURCE_MEM_64;
@@ -249,7 +252,9 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
249 res->end = l + sz; 252 res->end = l + sz;
250 253
251 dev_printk(KERN_DEBUG, &dev->dev, "reg %x %s: %pR\n", pos, 254 dev_printk(KERN_DEBUG, &dev->dev, "reg %x %s: %pR\n", pos,
252 (res->flags & IORESOURCE_IO) ? "io port" : "32bit mmio", 255 (res->flags & IORESOURCE_IO) ? "io port" :
256 ((res->flags & IORESOURCE_PREFETCH) ?
257 "32bit mmio pref" : "32bit mmio"),
253 res); 258 res);
254 } 259 }
255 260
@@ -692,6 +697,23 @@ static void set_pcie_port_type(struct pci_dev *pdev)
692 pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4; 697 pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4;
693} 698}
694 699
700static void set_pcie_hotplug_bridge(struct pci_dev *pdev)
701{
702 int pos;
703 u16 reg16;
704 u32 reg32;
705
706 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
707 if (!pos)
708 return;
709 pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, &reg16);
710 if (!(reg16 & PCI_EXP_FLAGS_SLOT))
711 return;
712 pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, &reg32);
713 if (reg32 & PCI_EXP_SLTCAP_HPC)
714 pdev->is_hotplug_bridge = 1;
715}
716
695#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED) 717#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)
696 718
697/** 719/**
@@ -799,6 +821,7 @@ int pci_setup_device(struct pci_dev *dev)
799 pci_read_irq(dev); 821 pci_read_irq(dev);
800 dev->transparent = ((dev->class & 0xff) == 1); 822 dev->transparent = ((dev->class & 0xff) == 1);
801 pci_read_bases(dev, 2, PCI_ROM_ADDRESS1); 823 pci_read_bases(dev, 2, PCI_ROM_ADDRESS1);
824 set_pcie_hotplug_bridge(dev);
802 break; 825 break;
803 826
804 case PCI_HEADER_TYPE_CARDBUS: /* CardBus bridge header */ 827 case PCI_HEADER_TYPE_CARDBUS: /* CardBus bridge header */
@@ -1009,6 +1032,9 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
1009 /* Fix up broken headers */ 1032 /* Fix up broken headers */
1010 pci_fixup_device(pci_fixup_header, dev); 1033 pci_fixup_device(pci_fixup_header, dev);
1011 1034
1035 /* Clear the state_saved flag. */
1036 dev->state_saved = false;
1037
1012 /* Initialize various capabilities */ 1038 /* Initialize various capabilities */
1013 pci_init_capabilities(dev); 1039 pci_init_capabilities(dev);
1014 1040
@@ -1061,8 +1087,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
1061 if (dev && !dev->is_added) /* new device? */ 1087 if (dev && !dev->is_added) /* new device? */
1062 nr++; 1088 nr++;
1063 1089
1064 if ((dev && dev->multifunction) || 1090 if (dev && dev->multifunction) {
1065 (!dev && pcibios_scan_all_fns(bus, devfn))) {
1066 for (fn = 1; fn < 8; fn++) { 1091 for (fn = 1; fn < 8; fn++) {
1067 dev = pci_scan_single_device(bus, devfn + fn); 1092 dev = pci_scan_single_device(bus, devfn + fn);
1068 if (dev) { 1093 if (dev) {
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 85ce23997be4..6099facecd79 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -31,8 +31,6 @@ int isa_dma_bridge_buggy;
31EXPORT_SYMBOL(isa_dma_bridge_buggy); 31EXPORT_SYMBOL(isa_dma_bridge_buggy);
32int pci_pci_problems; 32int pci_pci_problems;
33EXPORT_SYMBOL(pci_pci_problems); 33EXPORT_SYMBOL(pci_pci_problems);
34int pcie_mch_quirk;
35EXPORT_SYMBOL(pcie_mch_quirk);
36 34
37#ifdef CONFIG_PCI_QUIRKS 35#ifdef CONFIG_PCI_QUIRKS
38/* 36/*
@@ -1203,6 +1201,7 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
1203 switch(dev->subsystem_device) { 1201 switch(dev->subsystem_device) {
1204 case 0x00b8: /* Compaq Evo D510 CMT */ 1202 case 0x00b8: /* Compaq Evo D510 CMT */
1205 case 0x00b9: /* Compaq Evo D510 SFF */ 1203 case 0x00b9: /* Compaq Evo D510 SFF */
1204 case 0x00ba: /* Compaq Evo D510 USDT */
1206 /* Motherboard doesn't have Host bridge 1205 /* Motherboard doesn't have Host bridge
1207 * subvendor/subdevice IDs and on-board VGA 1206 * subvendor/subdevice IDs and on-board VGA
1208 * controller is disabled if an AGP card is 1207 * controller is disabled if an AGP card is
@@ -1501,7 +1500,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_a
1501 1500
1502static void __devinit quirk_pcie_mch(struct pci_dev *pdev) 1501static void __devinit quirk_pcie_mch(struct pci_dev *pdev)
1503{ 1502{
1504 pcie_mch_quirk = 1; 1503 pci_msi_off(pdev);
1504 pdev->no_msi = 1;
1505} 1505}
1506DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_pcie_mch); 1506DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_pcie_mch);
1507DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch); 1507DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch);
@@ -1569,10 +1569,8 @@ static void quirk_reroute_to_boot_interrupts_intel(struct pci_dev *dev)
1569 return; 1569 return;
1570 1570
1571 dev->irq_reroute_variant = INTEL_IRQ_REROUTE_VARIANT; 1571 dev->irq_reroute_variant = INTEL_IRQ_REROUTE_VARIANT;
1572 1572 dev_info(&dev->dev, "rerouting interrupts for [%04x:%04x]\n",
1573 printk(KERN_INFO "PCI quirk: reroute interrupts for 0x%04x:0x%04x\n", 1573 dev->vendor, dev->device);
1574 dev->vendor, dev->device);
1575 return;
1576} 1574}
1577DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel); 1575DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel);
1578DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_1, quirk_reroute_to_boot_interrupts_intel); 1576DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_1, quirk_reroute_to_boot_interrupts_intel);
@@ -1614,8 +1612,8 @@ static void quirk_disable_intel_boot_interrupt(struct pci_dev *dev)
1614 pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ; 1612 pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ;
1615 pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, pci_config_word); 1613 pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, pci_config_word);
1616 1614
1617 printk(KERN_INFO "disabled boot interrupt on device 0x%04x:0x%04x\n", 1615 dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
1618 dev->vendor, dev->device); 1616 dev->vendor, dev->device);
1619} 1617}
1620DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt); 1618DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt);
1621DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt); 1619DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, quirk_disable_intel_boot_interrupt);
@@ -1647,8 +1645,8 @@ static void quirk_disable_broadcom_boot_interrupt(struct pci_dev *dev)
1647 1645
1648 pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword); 1646 pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword);
1649 1647
1650 printk(KERN_INFO "disabled boot interrupts on PCI device" 1648 dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
1651 "0x%04x:0x%04x\n", dev->vendor, dev->device); 1649 dev->vendor, dev->device);
1652} 1650}
1653DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); 1651DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt);
1654DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); 1652DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt);
@@ -1678,8 +1676,8 @@ static void quirk_disable_amd_813x_boot_interrupt(struct pci_dev *dev)
1678 pci_config_dword &= ~AMD_813X_NOIOAMODE; 1676 pci_config_dword &= ~AMD_813X_NOIOAMODE;
1679 pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword); 1677 pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword);
1680 1678
1681 printk(KERN_INFO "disabled boot interrupts on PCI device " 1679 dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
1682 "0x%04x:0x%04x\n", dev->vendor, dev->device); 1680 dev->vendor, dev->device);
1683} 1681}
1684DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt); 1682DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt);
1685DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE, quirk_disable_amd_813x_boot_interrupt); 1683DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE, quirk_disable_amd_813x_boot_interrupt);
@@ -1695,14 +1693,13 @@ static void quirk_disable_amd_8111_boot_interrupt(struct pci_dev *dev)
1695 1693
1696 pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word); 1694 pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word);
1697 if (!pci_config_word) { 1695 if (!pci_config_word) {
1698 printk(KERN_INFO "boot interrupts on PCI device 0x%04x:0x%04x " 1696 dev_info(&dev->dev, "boot interrupts on device [%04x:%04x] "
1699 "already disabled\n", 1697 "already disabled\n", dev->vendor, dev->device);
1700 dev->vendor, dev->device);
1701 return; 1698 return;
1702 } 1699 }
1703 pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0); 1700 pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0);
1704 printk(KERN_INFO "disabled boot interrupts on PCI device " 1701 dev_info(&dev->dev, "disabled boot interrupts on device [%04x:%04x]\n",
1705 "0x%04x:0x%04x\n", dev->vendor, dev->device); 1702 dev->vendor, dev->device);
1706} 1703}
1707DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); 1704DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt);
1708DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); 1705DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt);
@@ -2384,8 +2381,10 @@ static void __devinit nv_msi_ht_cap_quirk_leaf(struct pci_dev *dev)
2384} 2381}
2385 2382
2386DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk_leaf); 2383DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk_leaf);
2384DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk_leaf);
2387 2385
2388DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all); 2386DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all);
2387DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all);
2389 2388
2390static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) 2389static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev)
2391{ 2390{
@@ -2494,6 +2493,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e6, quirk_i82576_sriov);
2494DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e7, quirk_i82576_sriov); 2493DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e7, quirk_i82576_sriov);
2495DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e8, quirk_i82576_sriov); 2494DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e8, quirk_i82576_sriov);
2496DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150a, quirk_i82576_sriov); 2495DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150a, quirk_i82576_sriov);
2496DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150d, quirk_i82576_sriov);
2497 2497
2498#endif /* CONFIG_PCI_IOV */ 2498#endif /* CONFIG_PCI_IOV */
2499 2499
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index e8cb5051c311..ec415352d9ba 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -113,37 +113,6 @@ pci_find_next_bus(const struct pci_bus *from)
113 return b; 113 return b;
114} 114}
115 115
116#ifdef CONFIG_PCI_LEGACY
117/**
118 * pci_find_device - begin or continue searching for a PCI device by vendor/device id
119 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
120 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
121 * @from: Previous PCI device found in search, or %NULL for new search.
122 *
123 * Iterates through the list of known PCI devices. If a PCI device is found
124 * with a matching @vendor and @device, a pointer to its device structure is
125 * returned. Otherwise, %NULL is returned.
126 * A new search is initiated by passing %NULL as the @from argument.
127 * Otherwise if @from is not %NULL, searches continue from next device
128 * on the global list.
129 *
130 * NOTE: Do not use this function any more; use pci_get_device() instead, as
131 * the PCI device returned by this function can disappear at any moment in
132 * time.
133 */
134struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device,
135 struct pci_dev *from)
136{
137 struct pci_dev *pdev;
138
139 pci_dev_get(from);
140 pdev = pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);
141 pci_dev_put(pdev);
142 return pdev;
143}
144EXPORT_SYMBOL(pci_find_device);
145#endif /* CONFIG_PCI_LEGACY */
146
147/** 116/**
148 * pci_get_slot - locate PCI device for a given PCI slot 117 * pci_get_slot - locate PCI device for a given PCI slot
149 * @bus: PCI bus on which desired PCI device resides 118 * @bus: PCI bus on which desired PCI device resides
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 7c443b4583ab..cb1a027eb552 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -309,7 +309,7 @@ static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned lon
309 since these windows have 4K granularity and the IO ranges 309 since these windows have 4K granularity and the IO ranges
310 of non-bridge PCI devices are limited to 256 bytes. 310 of non-bridge PCI devices are limited to 256 bytes.
311 We must be careful with the ISA aliasing though. */ 311 We must be careful with the ISA aliasing though. */
312static void pbus_size_io(struct pci_bus *bus) 312static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size)
313{ 313{
314 struct pci_dev *dev; 314 struct pci_dev *dev;
315 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); 315 struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
@@ -336,6 +336,8 @@ static void pbus_size_io(struct pci_bus *bus)
336 size1 += r_size; 336 size1 += r_size;
337 } 337 }
338 } 338 }
339 if (size < min_size)
340 size = min_size;
339/* To be fixed in 2.5: we should have sort of HAVE_ISA 341/* To be fixed in 2.5: we should have sort of HAVE_ISA
340 flag in the struct pci_bus. */ 342 flag in the struct pci_bus. */
341#if defined(CONFIG_ISA) || defined(CONFIG_EISA) 343#if defined(CONFIG_ISA) || defined(CONFIG_EISA)
@@ -354,7 +356,8 @@ static void pbus_size_io(struct pci_bus *bus)
354 356
355/* Calculate the size of the bus and minimal alignment which 357/* Calculate the size of the bus and minimal alignment which
356 guarantees that all child resources fit in this size. */ 358 guarantees that all child resources fit in this size. */
357static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long type) 359static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
360 unsigned long type, resource_size_t min_size)
358{ 361{
359 struct pci_dev *dev; 362 struct pci_dev *dev;
360 resource_size_t min_align, align, size; 363 resource_size_t min_align, align, size;
@@ -404,6 +407,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, unsigned long
404 mem64_mask &= r->flags & IORESOURCE_MEM_64; 407 mem64_mask &= r->flags & IORESOURCE_MEM_64;
405 } 408 }
406 } 409 }
410 if (size < min_size)
411 size = min_size;
407 412
408 align = 0; 413 align = 0;
409 min_align = 0; 414 min_align = 0;
@@ -483,6 +488,7 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus)
483{ 488{
484 struct pci_dev *dev; 489 struct pci_dev *dev;
485 unsigned long mask, prefmask; 490 unsigned long mask, prefmask;
491 resource_size_t min_mem_size = 0, min_io_size = 0;
486 492
487 list_for_each_entry(dev, &bus->devices, bus_list) { 493 list_for_each_entry(dev, &bus->devices, bus_list) {
488 struct pci_bus *b = dev->subordinate; 494 struct pci_bus *b = dev->subordinate;
@@ -512,8 +518,12 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus)
512 518
513 case PCI_CLASS_BRIDGE_PCI: 519 case PCI_CLASS_BRIDGE_PCI:
514 pci_bridge_check_ranges(bus); 520 pci_bridge_check_ranges(bus);
521 if (bus->self->is_hotplug_bridge) {
522 min_io_size = pci_hotplug_io_size;
523 min_mem_size = pci_hotplug_mem_size;
524 }
515 default: 525 default:
516 pbus_size_io(bus); 526 pbus_size_io(bus, min_io_size);
517 /* If the bridge supports prefetchable range, size it 527 /* If the bridge supports prefetchable range, size it
518 separately. If it doesn't, or its prefetchable window 528 separately. If it doesn't, or its prefetchable window
519 has already been allocated by arch code, try 529 has already been allocated by arch code, try
@@ -521,9 +531,11 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus)
521 resources. */ 531 resources. */
522 mask = IORESOURCE_MEM; 532 mask = IORESOURCE_MEM;
523 prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; 533 prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
524 if (pbus_size_mem(bus, prefmask, prefmask)) 534 if (pbus_size_mem(bus, prefmask, prefmask, min_mem_size))
525 mask = prefmask; /* Success, size non-prefetch only. */ 535 mask = prefmask; /* Success, size non-prefetch only. */
526 pbus_size_mem(bus, mask, IORESOURCE_MEM); 536 else
537 min_mem_size += min_mem_size;
538 pbus_size_mem(bus, mask, IORESOURCE_MEM, min_mem_size);
527 break; 539 break;
528 } 540 }
529} 541}
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 88cdd1a937d6..706f82d8111f 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -119,6 +119,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
119 119
120 return err; 120 return err;
121} 121}
122EXPORT_SYMBOL(pci_claim_resource);
122 123
123#ifdef CONFIG_PCI_QUIRKS 124#ifdef CONFIG_PCI_QUIRKS
124void pci_disable_bridge_window(struct pci_dev *dev) 125void pci_disable_bridge_window(struct pci_dev *dev)
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 3ecd7c99d8eb..737fe5d87c40 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -622,11 +622,12 @@ static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
622 622
623static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end) 623static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end)
624{ 624{
625 struct resource *root, *res; 625 struct pci_dev *dev = socket->dev;
626 struct resource *res;
626 struct pci_bus_region region; 627 struct pci_bus_region region;
627 unsigned mask; 628 unsigned mask;
628 629
629 res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; 630 res = dev->resource + PCI_BRIDGE_RESOURCES + nr;
630 /* Already allocated? */ 631 /* Already allocated? */
631 if (res->parent) 632 if (res->parent)
632 return 0; 633 return 0;
@@ -636,17 +637,16 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
636 if (type & IORESOURCE_IO) 637 if (type & IORESOURCE_IO)
637 mask = ~3; 638 mask = ~3;
638 639
639 res->name = socket->dev->subordinate->name; 640 res->name = dev->subordinate->name;
640 res->flags = type; 641 res->flags = type;
641 642
642 region.start = config_readl(socket, addr_start) & mask; 643 region.start = config_readl(socket, addr_start) & mask;
643 region.end = config_readl(socket, addr_end) | ~mask; 644 region.end = config_readl(socket, addr_end) | ~mask;
644 if (region.start && region.end > region.start && !override_bios) { 645 if (region.start && region.end > region.start && !override_bios) {
645 pcibios_bus_to_resource(socket->dev, res, &region); 646 pcibios_bus_to_resource(dev, res, &region);
646 root = pci_find_parent_resource(socket->dev, res); 647 if (pci_claim_resource(dev, PCI_BRIDGE_RESOURCES + nr) == 0)
647 if (root && (request_resource(root, res) == 0))
648 return 0; 648 return 0;
649 dev_printk(KERN_INFO, &socket->dev->dev, 649 dev_printk(KERN_INFO, &dev->dev,
650 "Preassigned resource %d busy or not available, " 650 "Preassigned resource %d busy or not available, "
651 "reconfiguring...\n", 651 "reconfiguring...\n",
652 nr); 652 nr);
@@ -672,7 +672,7 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
672 return 1; 672 return 1;
673 } 673 }
674 674
675 dev_printk(KERN_INFO, &socket->dev->dev, 675 dev_printk(KERN_INFO, &dev->dev,
676 "no resource of type %x available, trying to continue...\n", 676 "no resource of type %x available, trying to continue...\n",
677 type); 677 type);
678 res->start = res->end = res->flags = 0; 678 res->start = res->end = res->flags = 0;
diff --git a/drivers/ps3/ps3stor_lib.c b/drivers/ps3/ps3stor_lib.c
index 18066d555397..af0afa1db4a8 100644
--- a/drivers/ps3/ps3stor_lib.c
+++ b/drivers/ps3/ps3stor_lib.c
@@ -23,6 +23,65 @@
23#include <asm/lv1call.h> 23#include <asm/lv1call.h>
24#include <asm/ps3stor.h> 24#include <asm/ps3stor.h>
25 25
26/*
27 * A workaround for flash memory I/O errors when the internal hard disk
28 * has not been formatted for OtherOS use. Delay disk close until flash
29 * memory is closed.
30 */
31
32static struct ps3_flash_workaround {
33 int flash_open;
34 int disk_open;
35 struct ps3_system_bus_device *disk_sbd;
36} ps3_flash_workaround;
37
38static int ps3stor_open_hv_device(struct ps3_system_bus_device *sbd)
39{
40 int error = ps3_open_hv_device(sbd);
41
42 if (error)
43 return error;
44
45 if (sbd->match_id == PS3_MATCH_ID_STOR_FLASH)
46 ps3_flash_workaround.flash_open = 1;
47
48 if (sbd->match_id == PS3_MATCH_ID_STOR_DISK)
49 ps3_flash_workaround.disk_open = 1;
50
51 return 0;
52}
53
54static int ps3stor_close_hv_device(struct ps3_system_bus_device *sbd)
55{
56 int error;
57
58 if (sbd->match_id == PS3_MATCH_ID_STOR_DISK
59 && ps3_flash_workaround.disk_open
60 && ps3_flash_workaround.flash_open) {
61 ps3_flash_workaround.disk_sbd = sbd;
62 return 0;
63 }
64
65 error = ps3_close_hv_device(sbd);
66
67 if (error)
68 return error;
69
70 if (sbd->match_id == PS3_MATCH_ID_STOR_DISK)
71 ps3_flash_workaround.disk_open = 0;
72
73 if (sbd->match_id == PS3_MATCH_ID_STOR_FLASH) {
74 ps3_flash_workaround.flash_open = 0;
75
76 if (ps3_flash_workaround.disk_sbd) {
77 ps3_close_hv_device(ps3_flash_workaround.disk_sbd);
78 ps3_flash_workaround.disk_open = 0;
79 ps3_flash_workaround.disk_sbd = NULL;
80 }
81 }
82
83 return 0;
84}
26 85
27static int ps3stor_probe_access(struct ps3_storage_device *dev) 86static int ps3stor_probe_access(struct ps3_storage_device *dev)
28{ 87{
@@ -90,7 +149,7 @@ int ps3stor_setup(struct ps3_storage_device *dev, irq_handler_t handler)
90 int error, res, alignment; 149 int error, res, alignment;
91 enum ps3_dma_page_size page_size; 150 enum ps3_dma_page_size page_size;
92 151
93 error = ps3_open_hv_device(&dev->sbd); 152 error = ps3stor_open_hv_device(&dev->sbd);
94 if (error) { 153 if (error) {
95 dev_err(&dev->sbd.core, 154 dev_err(&dev->sbd.core,
96 "%s:%u: ps3_open_hv_device failed %d\n", __func__, 155 "%s:%u: ps3_open_hv_device failed %d\n", __func__,
@@ -166,7 +225,7 @@ fail_free_irq:
166fail_sb_event_receive_port_destroy: 225fail_sb_event_receive_port_destroy:
167 ps3_sb_event_receive_port_destroy(&dev->sbd, dev->irq); 226 ps3_sb_event_receive_port_destroy(&dev->sbd, dev->irq);
168fail_close_device: 227fail_close_device:
169 ps3_close_hv_device(&dev->sbd); 228 ps3stor_close_hv_device(&dev->sbd);
170fail: 229fail:
171 return error; 230 return error;
172} 231}
@@ -193,7 +252,7 @@ void ps3stor_teardown(struct ps3_storage_device *dev)
193 "%s:%u: destroy event receive port failed %d\n", 252 "%s:%u: destroy event receive port failed %d\n",
194 __func__, __LINE__, error); 253 __func__, __LINE__, error);
195 254
196 error = ps3_close_hv_device(&dev->sbd); 255 error = ps3stor_close_hv_device(&dev->sbd);
197 if (error) 256 if (error)
198 dev_err(&dev->sbd.core, 257 dev_err(&dev->sbd.core,
199 "%s:%u: ps3_close_hv_device failed %d\n", __func__, 258 "%s:%u: ps3_close_hv_device failed %d\n", __func__,
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 4f247e4dd3f9..021b2928f0b9 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * Modifications from: 10 * Modifications from:
11 * CIH <cih@coventive.com> 11 * CIH <cih@coventive.com>
12 * Nicolas Pitre <nico@cam.org> 12 * Nicolas Pitre <nico@fluxnic.net>
13 * Andrew Christian <andrew.christian@hp.com> 13 * Andrew Christian <andrew.christian@hp.com>
14 * 14 *
15 * Converted to the RTC subsystem and Driver Model 15 * Converted to the RTC subsystem and Driver Model
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 1999b1834814..cef3e1d9b92e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -7,6 +7,8 @@ menu "Graphics support"
7 7
8source "drivers/char/agp/Kconfig" 8source "drivers/char/agp/Kconfig"
9 9
10source "drivers/gpu/vga/Kconfig"
11
10source "drivers/gpu/drm/Kconfig" 12source "drivers/gpu/drm/Kconfig"
11 13
12config VGASTATE 14config VGASTATE
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index c0af638fe702..9c0144ee7ae5 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -32,7 +32,7 @@
32#include <linux/init.h> 32#include <linux/init.h>
33 33
34#include <asm/abs_addr.h> 34#include <asm/abs_addr.h>
35#include <asm/iommu.h> 35#include <asm/cell-regs.h>
36#include <asm/lv1call.h> 36#include <asm/lv1call.h>
37#include <asm/ps3av.h> 37#include <asm/ps3av.h>
38#include <asm/ps3fb.h> 38#include <asm/ps3fb.h>
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index 10ddad8e17d6..cdaa873a6054 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -66,7 +66,7 @@
66 * - FrameBuffer memory is now allocated at run-time when the 66 * - FrameBuffer memory is now allocated at run-time when the
67 * driver is initialized. 67 * driver is initialized.
68 * 68 *
69 * 2000/04/10: Nicolas Pitre <nico@cam.org> 69 * 2000/04/10: Nicolas Pitre <nico@fluxnic.net>
70 * - Big cleanup for dynamic selection of machine type at run time. 70 * - Big cleanup for dynamic selection of machine type at run time.
71 * 71 *
72 * 2000/07/19: Jamey Hicks <jamey@crl.dec.com> 72 * 2000/07/19: Jamey Hicks <jamey@crl.dec.com>
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index abad71b1632b..2f57276e87a2 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -47,10 +47,10 @@
47static DEFINE_SPINLOCK(irq_mapping_update_lock); 47static DEFINE_SPINLOCK(irq_mapping_update_lock);
48 48
49/* IRQ <-> VIRQ mapping. */ 49/* IRQ <-> VIRQ mapping. */
50static DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1}; 50static DEFINE_PER_CPU(int [NR_VIRQS], virq_to_irq) = {[0 ... NR_VIRQS-1] = -1};
51 51
52/* IRQ <-> IPI mapping */ 52/* IRQ <-> IPI mapping */
53static DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1}; 53static DEFINE_PER_CPU(int [XEN_NR_IPIS], ipi_to_irq) = {[0 ... XEN_NR_IPIS-1] = -1};
54 54
55/* Interrupt types. */ 55/* Interrupt types. */
56enum xen_irq_type { 56enum xen_irq_type {
@@ -602,6 +602,8 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
602 return IRQ_HANDLED; 602 return IRQ_HANDLED;
603} 603}
604 604
605static DEFINE_PER_CPU(unsigned, xed_nesting_count);
606
605/* 607/*
606 * Search the CPUs pending events bitmasks. For each one found, map 608 * Search the CPUs pending events bitmasks. For each one found, map
607 * the event number to an irq, and feed it into do_IRQ() for 609 * the event number to an irq, and feed it into do_IRQ() for
@@ -617,7 +619,6 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
617 struct pt_regs *old_regs = set_irq_regs(regs); 619 struct pt_regs *old_regs = set_irq_regs(regs);
618 struct shared_info *s = HYPERVISOR_shared_info; 620 struct shared_info *s = HYPERVISOR_shared_info;
619 struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu); 621 struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu);
620 static DEFINE_PER_CPU(unsigned, nesting_count);
621 unsigned count; 622 unsigned count;
622 623
623 exit_idle(); 624 exit_idle();
@@ -628,7 +629,7 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
628 629
629 vcpu_info->evtchn_upcall_pending = 0; 630 vcpu_info->evtchn_upcall_pending = 0;
630 631
631 if (__get_cpu_var(nesting_count)++) 632 if (__get_cpu_var(xed_nesting_count)++)
632 goto out; 633 goto out;
633 634
634#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ 635#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
@@ -653,8 +654,8 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
653 654
654 BUG_ON(!irqs_disabled()); 655 BUG_ON(!irqs_disabled());
655 656
656 count = __get_cpu_var(nesting_count); 657 count = __get_cpu_var(xed_nesting_count);
657 __get_cpu_var(nesting_count) = 0; 658 __get_cpu_var(xed_nesting_count) = 0;
658 } while(count != 1); 659 } while(count != 1);
659 660
660out: 661out:
diff --git a/fs/afs/write.c b/fs/afs/write.c
index c2e7a7ff0080..c63a3c8beb73 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -712,7 +712,6 @@ int afs_writeback_all(struct afs_vnode *vnode)
712 .bdi = mapping->backing_dev_info, 712 .bdi = mapping->backing_dev_info,
713 .sync_mode = WB_SYNC_ALL, 713 .sync_mode = WB_SYNC_ALL,
714 .nr_to_write = LONG_MAX, 714 .nr_to_write = LONG_MAX,
715 .for_writepages = 1,
716 .range_cyclic = 1, 715 .range_cyclic = 1,
717 }; 716 };
718 int ret; 717 int ret;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 3581a4e53942..71e7e03ac343 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -420,7 +420,6 @@ static void bdev_destroy_inode(struct inode *inode)
420{ 420{
421 struct bdev_inode *bdi = BDEV_I(inode); 421 struct bdev_inode *bdi = BDEV_I(inode);
422 422
423 bdi->bdev.bd_inode_backing_dev_info = NULL;
424 kmem_cache_free(bdev_cachep, bdi); 423 kmem_cache_free(bdev_cachep, bdi);
425} 424}
426 425
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 15831d5c7367..8b8192790011 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1600,6 +1600,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1600 1600
1601 sb->s_blocksize = 4096; 1601 sb->s_blocksize = 4096;
1602 sb->s_blocksize_bits = blksize_bits(4096); 1602 sb->s_blocksize_bits = blksize_bits(4096);
1603 sb->s_bdi = &fs_info->bdi;
1603 1604
1604 /* 1605 /*
1605 * we set the i_size on the btree inode to the max possible int. 1606 * we set the i_size on the btree inode to the max possible int.
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index d6f0806c682f..7b2f401e604e 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -740,7 +740,6 @@ int btrfs_fdatawrite_range(struct address_space *mapping, loff_t start,
740 .nr_to_write = mapping->nrpages * 2, 740 .nr_to_write = mapping->nrpages * 2,
741 .range_start = start, 741 .range_start = start,
742 .range_end = end, 742 .range_end = end,
743 .for_writepages = 1,
744 }; 743 };
745 return btrfs_writepages(mapping, &wbc); 744 return btrfs_writepages(mapping, &wbc);
746} 745}
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 628235cf44b5..8e1e5e19d21e 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -35,21 +35,29 @@
35int nr_pdflush_threads; 35int nr_pdflush_threads;
36 36
37/* 37/*
38 * Passed into wb_writeback(), essentially a subset of writeback_control
39 */
40struct wb_writeback_args {
41 long nr_pages;
42 struct super_block *sb;
43 enum writeback_sync_modes sync_mode;
44 int for_kupdate;
45 int range_cyclic;
46};
47
48/*
38 * Work items for the bdi_writeback threads 49 * Work items for the bdi_writeback threads
39 */ 50 */
40struct bdi_work { 51struct bdi_work {
41 struct list_head list; 52 struct list_head list; /* pending work list */
42 struct list_head wait_list; 53 struct rcu_head rcu_head; /* for RCU free/clear of work */
43 struct rcu_head rcu_head;
44 54
45 unsigned long seen; 55 unsigned long seen; /* threads that have seen this work */
46 atomic_t pending; 56 atomic_t pending; /* number of threads still to do work */
47 57
48 struct super_block *sb; 58 struct wb_writeback_args args; /* writeback arguments */
49 unsigned long nr_pages;
50 enum writeback_sync_modes sync_mode;
51 59
52 unsigned long state; 60 unsigned long state; /* flag bits, see WS_* */
53}; 61};
54 62
55enum { 63enum {
@@ -66,22 +74,13 @@ static inline bool bdi_work_on_stack(struct bdi_work *work)
66} 74}
67 75
68static inline void bdi_work_init(struct bdi_work *work, 76static inline void bdi_work_init(struct bdi_work *work,
69 struct writeback_control *wbc) 77 struct wb_writeback_args *args)
70{ 78{
71 INIT_RCU_HEAD(&work->rcu_head); 79 INIT_RCU_HEAD(&work->rcu_head);
72 work->sb = wbc->sb; 80 work->args = *args;
73 work->nr_pages = wbc->nr_to_write;
74 work->sync_mode = wbc->sync_mode;
75 work->state = WS_USED; 81 work->state = WS_USED;
76} 82}
77 83
78static inline void bdi_work_init_on_stack(struct bdi_work *work,
79 struct writeback_control *wbc)
80{
81 bdi_work_init(work, wbc);
82 work->state |= WS_ONSTACK;
83}
84
85/** 84/**
86 * writeback_in_progress - determine whether there is writeback in progress 85 * writeback_in_progress - determine whether there is writeback in progress
87 * @bdi: the device's backing_dev_info structure. 86 * @bdi: the device's backing_dev_info structure.
@@ -98,6 +97,11 @@ static void bdi_work_clear(struct bdi_work *work)
98{ 97{
99 clear_bit(WS_USED_B, &work->state); 98 clear_bit(WS_USED_B, &work->state);
100 smp_mb__after_clear_bit(); 99 smp_mb__after_clear_bit();
100 /*
101 * work can have disappeared at this point. bit waitq functions
102 * should be able to tolerate this, provided bdi_sched_wait does
103 * not dereference it's pointer argument.
104 */
101 wake_up_bit(&work->state, WS_USED_B); 105 wake_up_bit(&work->state, WS_USED_B);
102} 106}
103 107
@@ -113,7 +117,8 @@ static void bdi_work_free(struct rcu_head *head)
113 117
114static void wb_work_complete(struct bdi_work *work) 118static void wb_work_complete(struct bdi_work *work)
115{ 119{
116 const enum writeback_sync_modes sync_mode = work->sync_mode; 120 const enum writeback_sync_modes sync_mode = work->args.sync_mode;
121 int onstack = bdi_work_on_stack(work);
117 122
118 /* 123 /*
119 * For allocated work, we can clear the done/seen bit right here. 124 * For allocated work, we can clear the done/seen bit right here.
@@ -121,9 +126,9 @@ static void wb_work_complete(struct bdi_work *work)
121 * to after the RCU grace period, since the stack could be invalidated 126 * to after the RCU grace period, since the stack could be invalidated
122 * as soon as bdi_work_clear() has done the wakeup. 127 * as soon as bdi_work_clear() has done the wakeup.
123 */ 128 */
124 if (!bdi_work_on_stack(work)) 129 if (!onstack)
125 bdi_work_clear(work); 130 bdi_work_clear(work);
126 if (sync_mode == WB_SYNC_NONE || bdi_work_on_stack(work)) 131 if (sync_mode == WB_SYNC_NONE || onstack)
127 call_rcu(&work->rcu_head, bdi_work_free); 132 call_rcu(&work->rcu_head, bdi_work_free);
128} 133}
129 134
@@ -146,21 +151,19 @@ static void wb_clear_pending(struct bdi_writeback *wb, struct bdi_work *work)
146 151
147static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work) 152static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work)
148{ 153{
149 if (work) { 154 work->seen = bdi->wb_mask;
150 work->seen = bdi->wb_mask; 155 BUG_ON(!work->seen);
151 BUG_ON(!work->seen); 156 atomic_set(&work->pending, bdi->wb_cnt);
152 atomic_set(&work->pending, bdi->wb_cnt); 157 BUG_ON(!bdi->wb_cnt);
153 BUG_ON(!bdi->wb_cnt);
154
155 /*
156 * Make sure stores are seen before it appears on the list
157 */
158 smp_mb();
159 158
160 spin_lock(&bdi->wb_lock); 159 /*
161 list_add_tail_rcu(&work->list, &bdi->work_list); 160 * list_add_tail_rcu() contains the necessary barriers to
162 spin_unlock(&bdi->wb_lock); 161 * make sure the above stores are seen before the item is
163 } 162 * noticed on the list
163 */
164 spin_lock(&bdi->wb_lock);
165 list_add_tail_rcu(&work->list, &bdi->work_list);
166 spin_unlock(&bdi->wb_lock);
164 167
165 /* 168 /*
166 * If the default thread isn't there, make sure we add it. When 169 * If the default thread isn't there, make sure we add it. When
@@ -171,15 +174,7 @@ static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work)
171 else { 174 else {
172 struct bdi_writeback *wb = &bdi->wb; 175 struct bdi_writeback *wb = &bdi->wb;
173 176
174 /* 177 if (wb->task)
175 * If we failed allocating the bdi work item, wake up the wb
176 * thread always. As a safety precaution, it'll flush out
177 * everything
178 */
179 if (!wb_has_dirty_io(wb)) {
180 if (work)
181 wb_clear_pending(wb, work);
182 } else if (wb->task)
183 wake_up_process(wb->task); 178 wake_up_process(wb->task);
184 } 179 }
185} 180}
@@ -194,48 +189,75 @@ static void bdi_wait_on_work_clear(struct bdi_work *work)
194 TASK_UNINTERRUPTIBLE); 189 TASK_UNINTERRUPTIBLE);
195} 190}
196 191
197static struct bdi_work *bdi_alloc_work(struct writeback_control *wbc) 192static void bdi_alloc_queue_work(struct backing_dev_info *bdi,
193 struct wb_writeback_args *args)
198{ 194{
199 struct bdi_work *work; 195 struct bdi_work *work;
200 196
197 /*
198 * This is WB_SYNC_NONE writeback, so if allocation fails just
199 * wakeup the thread for old dirty data writeback
200 */
201 work = kmalloc(sizeof(*work), GFP_ATOMIC); 201 work = kmalloc(sizeof(*work), GFP_ATOMIC);
202 if (work) 202 if (work) {
203 bdi_work_init(work, wbc); 203 bdi_work_init(work, args);
204 bdi_queue_work(bdi, work);
205 } else {
206 struct bdi_writeback *wb = &bdi->wb;
204 207
205 return work; 208 if (wb->task)
209 wake_up_process(wb->task);
210 }
206} 211}
207 212
208void bdi_start_writeback(struct writeback_control *wbc) 213/**
214 * bdi_sync_writeback - start and wait for writeback
215 * @bdi: the backing device to write from
216 * @sb: write inodes from this super_block
217 *
218 * Description:
219 * This does WB_SYNC_ALL data integrity writeback and waits for the
220 * IO to complete. Callers must hold the sb s_umount semaphore for
221 * reading, to avoid having the super disappear before we are done.
222 */
223static void bdi_sync_writeback(struct backing_dev_info *bdi,
224 struct super_block *sb)
209{ 225{
210 const bool must_wait = wbc->sync_mode == WB_SYNC_ALL; 226 struct wb_writeback_args args = {
211 struct bdi_work work_stack, *work = NULL; 227 .sb = sb,
228 .sync_mode = WB_SYNC_ALL,
229 .nr_pages = LONG_MAX,
230 .range_cyclic = 0,
231 };
232 struct bdi_work work;
212 233
213 if (!must_wait) 234 bdi_work_init(&work, &args);
214 work = bdi_alloc_work(wbc); 235 work.state |= WS_ONSTACK;
215 236
216 if (!work) { 237 bdi_queue_work(bdi, &work);
217 work = &work_stack; 238 bdi_wait_on_work_clear(&work);
218 bdi_work_init_on_stack(work, wbc); 239}
219 }
220 240
221 bdi_queue_work(wbc->bdi, work); 241/**
242 * bdi_start_writeback - start writeback
243 * @bdi: the backing device to write from
244 * @nr_pages: the number of pages to write
245 *
246 * Description:
247 * This does WB_SYNC_NONE opportunistic writeback. The IO is only
248 * started when this function returns, we make no guarentees on
249 * completion. Caller need not hold sb s_umount semaphore.
250 *
251 */
252void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages)
253{
254 struct wb_writeback_args args = {
255 .sync_mode = WB_SYNC_NONE,
256 .nr_pages = nr_pages,
257 .range_cyclic = 1,
258 };
222 259
223 /* 260 bdi_alloc_queue_work(bdi, &args);
224 * If the sync mode is WB_SYNC_ALL, block waiting for the work to
225 * complete. If not, we only need to wait for the work to be started,
226 * if we allocated it on-stack. We use the same mechanism, if the
227 * wait bit is set in the bdi_work struct, then threads will not
228 * clear pending until after they are done.
229 *
230 * Note that work == &work_stack if must_wait is true, so we don't
231 * need to do call_rcu() here ever, since the completion path will
232 * have done that for us.
233 */
234 if (must_wait || work == &work_stack) {
235 bdi_wait_on_work_clear(work);
236 if (work != &work_stack)
237 call_rcu(&work->rcu_head, bdi_work_free);
238 }
239} 261}
240 262
241/* 263/*
@@ -671,17 +693,16 @@ static inline bool over_bground_thresh(void)
671 * older_than_this takes precedence over nr_to_write. So we'll only write back 693 * older_than_this takes precedence over nr_to_write. So we'll only write back
672 * all dirty pages if they are all attached to "old" mappings. 694 * all dirty pages if they are all attached to "old" mappings.
673 */ 695 */
674static long wb_writeback(struct bdi_writeback *wb, long nr_pages, 696static long wb_writeback(struct bdi_writeback *wb,
675 struct super_block *sb, 697 struct wb_writeback_args *args)
676 enum writeback_sync_modes sync_mode, int for_kupdate)
677{ 698{
678 struct writeback_control wbc = { 699 struct writeback_control wbc = {
679 .bdi = wb->bdi, 700 .bdi = wb->bdi,
680 .sb = sb, 701 .sb = args->sb,
681 .sync_mode = sync_mode, 702 .sync_mode = args->sync_mode,
682 .older_than_this = NULL, 703 .older_than_this = NULL,
683 .for_kupdate = for_kupdate, 704 .for_kupdate = args->for_kupdate,
684 .range_cyclic = 1, 705 .range_cyclic = args->range_cyclic,
685 }; 706 };
686 unsigned long oldest_jif; 707 unsigned long oldest_jif;
687 long wrote = 0; 708 long wrote = 0;
@@ -691,13 +712,18 @@ static long wb_writeback(struct bdi_writeback *wb, long nr_pages,
691 oldest_jif = jiffies - 712 oldest_jif = jiffies -
692 msecs_to_jiffies(dirty_expire_interval * 10); 713 msecs_to_jiffies(dirty_expire_interval * 10);
693 } 714 }
715 if (!wbc.range_cyclic) {
716 wbc.range_start = 0;
717 wbc.range_end = LLONG_MAX;
718 }
694 719
695 for (;;) { 720 for (;;) {
696 /* 721 /*
697 * Don't flush anything for non-integrity writeback where 722 * Don't flush anything for non-integrity writeback where
698 * no nr_pages was given 723 * no nr_pages was given
699 */ 724 */
700 if (!for_kupdate && nr_pages <= 0 && sync_mode == WB_SYNC_NONE) 725 if (!args->for_kupdate && args->nr_pages <= 0 &&
726 args->sync_mode == WB_SYNC_NONE)
701 break; 727 break;
702 728
703 /* 729 /*
@@ -705,7 +731,8 @@ static long wb_writeback(struct bdi_writeback *wb, long nr_pages,
705 * periodic background writeout and we are below the 731 * periodic background writeout and we are below the
706 * background dirty threshold, don't do anything 732 * background dirty threshold, don't do anything
707 */ 733 */
708 if (for_kupdate && nr_pages <= 0 && !over_bground_thresh()) 734 if (args->for_kupdate && args->nr_pages <= 0 &&
735 !over_bground_thresh())
709 break; 736 break;
710 737
711 wbc.more_io = 0; 738 wbc.more_io = 0;
@@ -713,7 +740,7 @@ static long wb_writeback(struct bdi_writeback *wb, long nr_pages,
713 wbc.nr_to_write = MAX_WRITEBACK_PAGES; 740 wbc.nr_to_write = MAX_WRITEBACK_PAGES;
714 wbc.pages_skipped = 0; 741 wbc.pages_skipped = 0;
715 writeback_inodes_wb(wb, &wbc); 742 writeback_inodes_wb(wb, &wbc);
716 nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write; 743 args->nr_pages -= MAX_WRITEBACK_PAGES - wbc.nr_to_write;
717 wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write; 744 wrote += MAX_WRITEBACK_PAGES - wbc.nr_to_write;
718 745
719 /* 746 /*
@@ -731,7 +758,11 @@ static long wb_writeback(struct bdi_writeback *wb, long nr_pages,
731 758
732/* 759/*
733 * Return the next bdi_work struct that hasn't been processed by this 760 * Return the next bdi_work struct that hasn't been processed by this
734 * wb thread yet 761 * wb thread yet. ->seen is initially set for each thread that exists
762 * for this device, when a thread first notices a piece of work it
763 * clears its bit. Depending on writeback type, the thread will notify
764 * completion on either receiving the work (WB_SYNC_NONE) or after
765 * it is done (WB_SYNC_ALL).
735 */ 766 */
736static struct bdi_work *get_next_work_item(struct backing_dev_info *bdi, 767static struct bdi_work *get_next_work_item(struct backing_dev_info *bdi,
737 struct bdi_writeback *wb) 768 struct bdi_writeback *wb)
@@ -741,8 +772,9 @@ static struct bdi_work *get_next_work_item(struct backing_dev_info *bdi,
741 rcu_read_lock(); 772 rcu_read_lock();
742 773
743 list_for_each_entry_rcu(work, &bdi->work_list, list) { 774 list_for_each_entry_rcu(work, &bdi->work_list, list) {
744 if (!test_and_clear_bit(wb->nr, &work->seen)) 775 if (!test_bit(wb->nr, &work->seen))
745 continue; 776 continue;
777 clear_bit(wb->nr, &work->seen);
746 778
747 ret = work; 779 ret = work;
748 break; 780 break;
@@ -767,8 +799,16 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
767 global_page_state(NR_UNSTABLE_NFS) + 799 global_page_state(NR_UNSTABLE_NFS) +
768 (inodes_stat.nr_inodes - inodes_stat.nr_unused); 800 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
769 801
770 if (nr_pages) 802 if (nr_pages) {
771 return wb_writeback(wb, nr_pages, NULL, WB_SYNC_NONE, 1); 803 struct wb_writeback_args args = {
804 .nr_pages = nr_pages,
805 .sync_mode = WB_SYNC_NONE,
806 .for_kupdate = 1,
807 .range_cyclic = 1,
808 };
809
810 return wb_writeback(wb, &args);
811 }
772 812
773 return 0; 813 return 0;
774} 814}
@@ -780,35 +820,31 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait)
780{ 820{
781 struct backing_dev_info *bdi = wb->bdi; 821 struct backing_dev_info *bdi = wb->bdi;
782 struct bdi_work *work; 822 struct bdi_work *work;
783 long nr_pages, wrote = 0; 823 long wrote = 0;
784 824
785 while ((work = get_next_work_item(bdi, wb)) != NULL) { 825 while ((work = get_next_work_item(bdi, wb)) != NULL) {
786 enum writeback_sync_modes sync_mode; 826 struct wb_writeback_args args = work->args;
787
788 nr_pages = work->nr_pages;
789 827
790 /* 828 /*
791 * Override sync mode, in case we must wait for completion 829 * Override sync mode, in case we must wait for completion
792 */ 830 */
793 if (force_wait) 831 if (force_wait)
794 work->sync_mode = sync_mode = WB_SYNC_ALL; 832 work->args.sync_mode = args.sync_mode = WB_SYNC_ALL;
795 else
796 sync_mode = work->sync_mode;
797 833
798 /* 834 /*
799 * If this isn't a data integrity operation, just notify 835 * If this isn't a data integrity operation, just notify
800 * that we have seen this work and we are now starting it. 836 * that we have seen this work and we are now starting it.
801 */ 837 */
802 if (sync_mode == WB_SYNC_NONE) 838 if (args.sync_mode == WB_SYNC_NONE)
803 wb_clear_pending(wb, work); 839 wb_clear_pending(wb, work);
804 840
805 wrote += wb_writeback(wb, nr_pages, work->sb, sync_mode, 0); 841 wrote += wb_writeback(wb, &args);
806 842
807 /* 843 /*
808 * This is a data integrity writeback, so only do the 844 * This is a data integrity writeback, so only do the
809 * notification when we have completed the work. 845 * notification when we have completed the work.
810 */ 846 */
811 if (sync_mode == WB_SYNC_ALL) 847 if (args.sync_mode == WB_SYNC_ALL)
812 wb_clear_pending(wb, work); 848 wb_clear_pending(wb, work);
813 } 849 }
814 850
@@ -849,8 +885,7 @@ int bdi_writeback_task(struct bdi_writeback *wb)
849 } 885 }
850 886
851 wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10); 887 wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
852 set_current_state(TASK_INTERRUPTIBLE); 888 schedule_timeout_interruptible(wait_jiffies);
853 schedule_timeout(wait_jiffies);
854 try_to_freeze(); 889 try_to_freeze();
855 } 890 }
856 891
@@ -858,67 +893,28 @@ int bdi_writeback_task(struct bdi_writeback *wb)
858} 893}
859 894
860/* 895/*
861 * Schedule writeback for all backing devices. Expensive! If this is a data 896 * Schedule writeback for all backing devices. This does WB_SYNC_NONE
862 * integrity operation, writeback will be complete when this returns. If 897 * writeback, for integrity writeback see bdi_sync_writeback().
863 * we are simply called for WB_SYNC_NONE, then writeback will merely be
864 * scheduled to run.
865 */ 898 */
866static void bdi_writeback_all(struct writeback_control *wbc) 899static void bdi_writeback_all(struct super_block *sb, long nr_pages)
867{ 900{
868 const bool must_wait = wbc->sync_mode == WB_SYNC_ALL; 901 struct wb_writeback_args args = {
902 .sb = sb,
903 .nr_pages = nr_pages,
904 .sync_mode = WB_SYNC_NONE,
905 };
869 struct backing_dev_info *bdi; 906 struct backing_dev_info *bdi;
870 struct bdi_work *work;
871 LIST_HEAD(list);
872
873restart:
874 spin_lock(&bdi_lock);
875 907
876 list_for_each_entry(bdi, &bdi_list, bdi_list) { 908 rcu_read_lock();
877 struct bdi_work *work;
878 909
910 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) {
879 if (!bdi_has_dirty_io(bdi)) 911 if (!bdi_has_dirty_io(bdi))
880 continue; 912 continue;
881 913
882 /* 914 bdi_alloc_queue_work(bdi, &args);
883 * If work allocation fails, do the writes inline. We drop
884 * the lock and restart the list writeout. This should be OK,
885 * since this happens rarely and because the writeout should
886 * eventually make more free memory available.
887 */
888 work = bdi_alloc_work(wbc);
889 if (!work) {
890 struct writeback_control __wbc;
891
892 /*
893 * Not a data integrity writeout, just continue
894 */
895 if (!must_wait)
896 continue;
897
898 spin_unlock(&bdi_lock);
899 __wbc = *wbc;
900 __wbc.bdi = bdi;
901 writeback_inodes_wbc(&__wbc);
902 goto restart;
903 }
904 if (must_wait)
905 list_add_tail(&work->wait_list, &list);
906
907 bdi_queue_work(bdi, work);
908 } 915 }
909 916
910 spin_unlock(&bdi_lock); 917 rcu_read_unlock();
911
912 /*
913 * If this is for WB_SYNC_ALL, wait for pending work to complete
914 * before returning.
915 */
916 while (!list_empty(&list)) {
917 work = list_entry(list.next, struct bdi_work, wait_list);
918 list_del(&work->wait_list);
919 bdi_wait_on_work_clear(work);
920 call_rcu(&work->rcu_head, bdi_work_free);
921 }
922} 918}
923 919
924/* 920/*
@@ -927,17 +923,10 @@ restart:
927 */ 923 */
928void wakeup_flusher_threads(long nr_pages) 924void wakeup_flusher_threads(long nr_pages)
929{ 925{
930 struct writeback_control wbc = {
931 .sync_mode = WB_SYNC_NONE,
932 .older_than_this = NULL,
933 .range_cyclic = 1,
934 };
935
936 if (nr_pages == 0) 926 if (nr_pages == 0)
937 nr_pages = global_page_state(NR_FILE_DIRTY) + 927 nr_pages = global_page_state(NR_FILE_DIRTY) +
938 global_page_state(NR_UNSTABLE_NFS); 928 global_page_state(NR_UNSTABLE_NFS);
939 wbc.nr_to_write = nr_pages; 929 bdi_writeback_all(NULL, nr_pages);
940 bdi_writeback_all(&wbc);
941} 930}
942 931
943static noinline void block_dump___mark_inode_dirty(struct inode *inode) 932static noinline void block_dump___mark_inode_dirty(struct inode *inode)
@@ -1084,7 +1073,7 @@ EXPORT_SYMBOL(__mark_inode_dirty);
1084 * on the writer throttling path, and we get decent balancing between many 1073 * on the writer throttling path, and we get decent balancing between many
1085 * throttled threads: we don't want them all piling up on inode_sync_wait. 1074 * throttled threads: we don't want them all piling up on inode_sync_wait.
1086 */ 1075 */
1087static void wait_sb_inodes(struct writeback_control *wbc) 1076static void wait_sb_inodes(struct super_block *sb)
1088{ 1077{
1089 struct inode *inode, *old_inode = NULL; 1078 struct inode *inode, *old_inode = NULL;
1090 1079
@@ -1092,7 +1081,7 @@ static void wait_sb_inodes(struct writeback_control *wbc)
1092 * We need to be protected against the filesystem going from 1081 * We need to be protected against the filesystem going from
1093 * r/o to r/w or vice versa. 1082 * r/o to r/w or vice versa.
1094 */ 1083 */
1095 WARN_ON(!rwsem_is_locked(&wbc->sb->s_umount)); 1084 WARN_ON(!rwsem_is_locked(&sb->s_umount));
1096 1085
1097 spin_lock(&inode_lock); 1086 spin_lock(&inode_lock);
1098 1087
@@ -1103,7 +1092,7 @@ static void wait_sb_inodes(struct writeback_control *wbc)
1103 * In which case, the inode may not be on the dirty list, but 1092 * In which case, the inode may not be on the dirty list, but
1104 * we still have to wait for that writeout. 1093 * we still have to wait for that writeout.
1105 */ 1094 */
1106 list_for_each_entry(inode, &wbc->sb->s_inodes, i_sb_list) { 1095 list_for_each_entry(inode, &sb->s_inodes, i_sb_list) {
1107 struct address_space *mapping; 1096 struct address_space *mapping;
1108 1097
1109 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW)) 1098 if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW))
@@ -1143,14 +1132,8 @@ static void wait_sb_inodes(struct writeback_control *wbc)
1143 * for IO completion of submitted IO. The number of pages submitted is 1132 * for IO completion of submitted IO. The number of pages submitted is
1144 * returned. 1133 * returned.
1145 */ 1134 */
1146long writeback_inodes_sb(struct super_block *sb) 1135void writeback_inodes_sb(struct super_block *sb)
1147{ 1136{
1148 struct writeback_control wbc = {
1149 .sb = sb,
1150 .sync_mode = WB_SYNC_NONE,
1151 .range_start = 0,
1152 .range_end = LLONG_MAX,
1153 };
1154 unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY); 1137 unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
1155 unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS); 1138 unsigned long nr_unstable = global_page_state(NR_UNSTABLE_NFS);
1156 long nr_to_write; 1139 long nr_to_write;
@@ -1158,9 +1141,7 @@ long writeback_inodes_sb(struct super_block *sb)
1158 nr_to_write = nr_dirty + nr_unstable + 1141 nr_to_write = nr_dirty + nr_unstable +
1159 (inodes_stat.nr_inodes - inodes_stat.nr_unused); 1142 (inodes_stat.nr_inodes - inodes_stat.nr_unused);
1160 1143
1161 wbc.nr_to_write = nr_to_write; 1144 bdi_writeback_all(sb, nr_to_write);
1162 bdi_writeback_all(&wbc);
1163 return nr_to_write - wbc.nr_to_write;
1164} 1145}
1165EXPORT_SYMBOL(writeback_inodes_sb); 1146EXPORT_SYMBOL(writeback_inodes_sb);
1166 1147
@@ -1171,20 +1152,10 @@ EXPORT_SYMBOL(writeback_inodes_sb);
1171 * This function writes and waits on any dirty inode belonging to this 1152 * This function writes and waits on any dirty inode belonging to this
1172 * super_block. The number of pages synced is returned. 1153 * super_block. The number of pages synced is returned.
1173 */ 1154 */
1174long sync_inodes_sb(struct super_block *sb) 1155void sync_inodes_sb(struct super_block *sb)
1175{ 1156{
1176 struct writeback_control wbc = { 1157 bdi_sync_writeback(sb->s_bdi, sb);
1177 .sb = sb, 1158 wait_sb_inodes(sb);
1178 .sync_mode = WB_SYNC_ALL,
1179 .range_start = 0,
1180 .range_end = LLONG_MAX,
1181 };
1182 long nr_to_write = LONG_MAX; /* doesn't actually matter */
1183
1184 wbc.nr_to_write = nr_to_write;
1185 bdi_writeback_all(&wbc);
1186 wait_sb_inodes(&wbc);
1187 return nr_to_write - wbc.nr_to_write;
1188} 1159}
1189EXPORT_SYMBOL(sync_inodes_sb); 1160EXPORT_SYMBOL(sync_inodes_sb);
1190 1161
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 4567db6f9430..e5dbecd87b0f 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -894,6 +894,8 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
894 if (err) 894 if (err)
895 goto err_put_conn; 895 goto err_put_conn;
896 896
897 sb->s_bdi = &fc->bdi;
898
897 /* Handle umasking inside the fuse code */ 899 /* Handle umasking inside the fuse code */
898 if (sb->s_flags & MS_POSIXACL) 900 if (sb->s_flags & MS_POSIXACL)
899 fc->dont_mask = 1; 901 fc->dont_mask = 1;
diff --git a/fs/inode.c b/fs/inode.c
index ae7b67e48661..b2ba83d2c4e1 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -182,9 +182,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
182 if (sb->s_bdev) { 182 if (sb->s_bdev) {
183 struct backing_dev_info *bdi; 183 struct backing_dev_info *bdi;
184 184
185 bdi = sb->s_bdev->bd_inode_backing_dev_info; 185 bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info;
186 if (!bdi)
187 bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info;
188 mapping->backing_dev_info = bdi; 186 mapping->backing_dev_info = bdi;
189 } 187 }
190 inode->i_private = NULL; 188 inode->i_private = NULL;
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 7b4088b2364d..0df600e9162d 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -220,7 +220,6 @@ static int journal_submit_inode_data_buffers(struct address_space *mapping)
220 .nr_to_write = mapping->nrpages * 2, 220 .nr_to_write = mapping->nrpages * 2,
221 .range_start = 0, 221 .range_start = 0,
222 .range_end = i_size_read(mapping->host), 222 .range_end = i_size_read(mapping->host),
223 .for_writepages = 1,
224 }; 223 };
225 224
226 ret = generic_writepages(mapping, &wbc); 225 ret = generic_writepages(mapping, &wbc);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 867f70504531..de935692d40d 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1918,6 +1918,8 @@ static inline void nfs_initialise_sb(struct super_block *sb)
1918 if (server->flags & NFS_MOUNT_NOAC) 1918 if (server->flags & NFS_MOUNT_NOAC)
1919 sb->s_flags |= MS_SYNCHRONOUS; 1919 sb->s_flags |= MS_SYNCHRONOUS;
1920 1920
1921 sb->s_bdi = &server->backing_dev_info;
1922
1921 nfs_super_set_maxbytes(sb, server->maxfilesize); 1923 nfs_super_set_maxbytes(sb, server->maxfilesize);
1922} 1924}
1923 1925
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 120acadc6a84..53eb26c16b50 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1490,7 +1490,6 @@ static int nfs_write_mapping(struct address_space *mapping, int how)
1490 .nr_to_write = LONG_MAX, 1490 .nr_to_write = LONG_MAX,
1491 .range_start = 0, 1491 .range_start = 0,
1492 .range_end = LLONG_MAX, 1492 .range_end = LLONG_MAX,
1493 .for_writepages = 1,
1494 }; 1493 };
1495 1494
1496 return __nfs_write_mapping(mapping, &wbc, how); 1495 return __nfs_write_mapping(mapping, &wbc, how);
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index d4168e269c5d..ad391a8c3e7e 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -591,9 +591,7 @@ int init_nilfs(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi, char *data)
591 591
592 nilfs->ns_mount_state = le16_to_cpu(sbp->s_state); 592 nilfs->ns_mount_state = le16_to_cpu(sbp->s_state);
593 593
594 bdi = nilfs->ns_bdev->bd_inode_backing_dev_info; 594 bdi = nilfs->ns_bdev->bd_inode->i_mapping->backing_dev_info;
595 if (!bdi)
596 bdi = nilfs->ns_bdev->bd_inode->i_mapping->backing_dev_info;
597 nilfs->ns_bdi = bdi ? : &default_backing_dev_info; 595 nilfs->ns_bdi = bdi ? : &default_backing_dev_info;
598 596
599 /* Finding last segment */ 597 /* Finding last segment */
diff --git a/fs/super.c b/fs/super.c
index 9cda337ddae2..b03fea8fbfb6 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -707,6 +707,12 @@ static int set_bdev_super(struct super_block *s, void *data)
707{ 707{
708 s->s_bdev = data; 708 s->s_bdev = data;
709 s->s_dev = s->s_bdev->bd_dev; 709 s->s_dev = s->s_bdev->bd_dev;
710
711 /*
712 * We set the bdi here to the queue backing, file systems can
713 * overwrite this in ->fill_super()
714 */
715 s->s_bdi = &bdev_get_queue(s->s_bdev)->backing_dev_info;
710 return 0; 716 return 0;
711} 717}
712 718
diff --git a/fs/sync.c b/fs/sync.c
index 192340930bb4..c08467a5d7cb 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -27,6 +27,13 @@
27 */ 27 */
28static int __sync_filesystem(struct super_block *sb, int wait) 28static int __sync_filesystem(struct super_block *sb, int wait)
29{ 29{
30 /*
31 * This should be safe, as we require bdi backing to actually
32 * write out data in the first place
33 */
34 if (!sb->s_bdi)
35 return 0;
36
30 /* Avoid doing twice syncing and cache pruning for quota sync */ 37 /* Avoid doing twice syncing and cache pruning for quota sync */
31 if (!wait) { 38 if (!wait) {
32 writeout_quota_sb(sb, -1); 39 writeout_quota_sb(sb, -1);
@@ -101,7 +108,7 @@ restart:
101 spin_unlock(&sb_lock); 108 spin_unlock(&sb_lock);
102 109
103 down_read(&sb->s_umount); 110 down_read(&sb->s_umount);
104 if (!(sb->s_flags & MS_RDONLY) && sb->s_root) 111 if (!(sb->s_flags & MS_RDONLY) && sb->s_root && sb->s_bdi)
105 __sync_filesystem(sb, wait); 112 __sync_filesystem(sb, wait);
106 up_read(&sb->s_umount); 113 up_read(&sb->s_umount);
107 114
diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c
index 1c8991b0db13..ee1ce68fd98b 100644
--- a/fs/ubifs/budget.c
+++ b/fs/ubifs/budget.c
@@ -54,29 +54,15 @@
54 * @nr_to_write: how many dirty pages to write-back 54 * @nr_to_write: how many dirty pages to write-back
55 * 55 *
56 * This function shrinks UBIFS liability by means of writing back some amount 56 * This function shrinks UBIFS liability by means of writing back some amount
57 * of dirty inodes and their pages. Returns the amount of pages which were 57 * of dirty inodes and their pages.
58 * written back. The returned value does not include dirty inodes which were
59 * synchronized.
60 * 58 *
61 * Note, this function synchronizes even VFS inodes which are locked 59 * Note, this function synchronizes even VFS inodes which are locked
62 * (@i_mutex) by the caller of the budgeting function, because write-back does 60 * (@i_mutex) by the caller of the budgeting function, because write-back does
63 * not touch @i_mutex. 61 * not touch @i_mutex.
64 */ 62 */
65static int shrink_liability(struct ubifs_info *c, int nr_to_write) 63static void shrink_liability(struct ubifs_info *c, int nr_to_write)
66{ 64{
67 int nr_written; 65 writeback_inodes_sb(c->vfs_sb);
68
69 nr_written = writeback_inodes_sb(c->vfs_sb);
70 if (!nr_written) {
71 /*
72 * Re-try again but wait on pages/inodes which are being
73 * written-back concurrently (e.g., by pdflush).
74 */
75 nr_written = sync_inodes_sb(c->vfs_sb);
76 }
77
78 dbg_budg("%d pages were written back", nr_written);
79 return nr_written;
80} 66}
81 67
82/** 68/**
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 51763aa8f4de..c4af069df1ad 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1980,6 +1980,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent)
1980 if (err) 1980 if (err)
1981 goto out_bdi; 1981 goto out_bdi;
1982 1982
1983 sb->s_bdi = &c->bdi;
1983 sb->s_fs_info = c; 1984 sb->s_fs_info = c;
1984 sb->s_magic = UBIFS_SUPER_MAGIC; 1985 sb->s_magic = UBIFS_SUPER_MAGIC;
1985 sb->s_blocksize = UBIFS_BLOCK_SIZE; 1986 sb->s_blocksize = UBIFS_BLOCK_SIZE;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index c65e4ce6c3af..1fa3ffb7c93b 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -248,7 +248,6 @@ struct acpi_device_perf {
248/* Wakeup Management */ 248/* Wakeup Management */
249struct acpi_device_wakeup_flags { 249struct acpi_device_wakeup_flags {
250 u8 valid:1; /* Can successfully enable wakeup? */ 250 u8 valid:1; /* Can successfully enable wakeup? */
251 u8 prepared:1; /* Has the wake-up capability been enabled? */
252 u8 run_wake:1; /* Run-Wake GPE devices */ 251 u8 run_wake:1; /* Run-Wake GPE devices */
253}; 252};
254 253
@@ -263,6 +262,7 @@ struct acpi_device_wakeup {
263 struct acpi_handle_list resources; 262 struct acpi_handle_list resources;
264 struct acpi_device_wakeup_state state; 263 struct acpi_device_wakeup_state state;
265 struct acpi_device_wakeup_flags flags; 264 struct acpi_device_wakeup_flags flags;
265 int prepare_count;
266}; 266};
267 267
268/* Device */ 268/* Device */
@@ -369,10 +369,26 @@ int register_acpi_bus_type(struct acpi_bus_type *);
369int unregister_acpi_bus_type(struct acpi_bus_type *); 369int unregister_acpi_bus_type(struct acpi_bus_type *);
370struct device *acpi_get_physical_device(acpi_handle); 370struct device *acpi_get_physical_device(acpi_handle);
371 371
372struct acpi_pci_root {
373 struct list_head node;
374 struct acpi_device * device;
375 struct acpi_pci_id id;
376 struct pci_bus *bus;
377 u16 segment;
378 u8 bus_nr;
379
380 u32 osc_support_set; /* _OSC state of support bits */
381 u32 osc_control_set; /* _OSC state of control bits */
382 u32 osc_control_qry; /* the latest _OSC query result */
383
384 u32 osc_queried:1; /* has _OSC control been queried? */
385};
386
372/* helper */ 387/* helper */
373acpi_handle acpi_get_child(acpi_handle, acpi_integer); 388acpi_handle acpi_get_child(acpi_handle, acpi_integer);
374int acpi_is_root_bridge(acpi_handle); 389int acpi_is_root_bridge(acpi_handle);
375acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); 390acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
391struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
376#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle)) 392#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
377 393
378#ifdef CONFIG_PM_SLEEP 394#ifdef CONFIG_PM_SLEEP
diff --git a/include/asm-generic/pci.h b/include/asm-generic/pci.h
index b4326b5466eb..26373cff4546 100644
--- a/include/asm-generic/pci.h
+++ b/include/asm-generic/pci.h
@@ -30,7 +30,18 @@ pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
30 res->end = region->end; 30 res->end = region->end;
31} 31}
32 32
33#define pcibios_scan_all_fns(a, b) 0 33static inline struct resource *
34pcibios_select_root(struct pci_dev *pdev, struct resource *res)
35{
36 struct resource *root = NULL;
37
38 if (res->flags & IORESOURCE_IO)
39 root = &ioport_resource;
40 if (res->flags & IORESOURCE_MEM)
41 root = &iomem_resource;
42
43 return root;
44}
34 45
35#ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ 46#ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
36static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 47static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6ad76bf5fb40..a43223af98b6 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -33,13 +33,10 @@
33 * BSS_SECTION(0, 0, 0) 33 * BSS_SECTION(0, 0, 0)
34 * _end = .; 34 * _end = .;
35 * 35 *
36 * /DISCARD/ : {
37 * EXIT_TEXT
38 * EXIT_DATA
39 * EXIT_CALL
40 * }
41 * STABS_DEBUG 36 * STABS_DEBUG
42 * DWARF_DEBUG 37 * DWARF_DEBUG
38 *
39 * DISCARDS // must be the last
43 * } 40 * }
44 * 41 *
45 * [__init_begin, __init_end] is the init section that may be freed after init 42 * [__init_begin, __init_end] is the init section that may be freed after init
@@ -626,6 +623,23 @@
626#define INIT_RAM_FS 623#define INIT_RAM_FS
627#endif 624#endif
628 625
626/*
627 * Default discarded sections.
628 *
629 * Some archs want to discard exit text/data at runtime rather than
630 * link time due to cross-section references such as alt instructions,
631 * bug table, eh_frame, etc. DISCARDS must be the last of output
632 * section definitions so that such archs put those in earlier section
633 * definitions.
634 */
635#define DISCARDS \
636 /DISCARD/ : { \
637 EXIT_TEXT \
638 EXIT_DATA \
639 EXIT_CALL \
640 *(.discard) \
641 }
642
629/** 643/**
630 * PERCPU_VADDR - define output section for percpu area 644 * PERCPU_VADDR - define output section for percpu area
631 * @vaddr: explicit base address (optional) 645 * @vaddr: explicit base address (optional)
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
index 76fa794fdac0..880130f7311f 100644
--- a/include/linux/agp_backend.h
+++ b/include/linux/agp_backend.h
@@ -79,9 +79,12 @@ struct agp_memory {
79 u32 physical; 79 u32 physical;
80 bool is_bound; 80 bool is_bound;
81 bool is_flushed; 81 bool is_flushed;
82 bool vmalloc_flag; 82 bool vmalloc_flag;
83 /* list of agp_memory mapped to the aperture */ 83 /* list of agp_memory mapped to the aperture */
84 struct list_head mapped_list; 84 struct list_head mapped_list;
85 /* DMA-mapped addresses */
86 struct scatterlist *sg_list;
87 int num_sg;
85}; 88};
86 89
87#define AGP_NORMAL_MEMORY 0 90#define AGP_NORMAL_MEMORY 0
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index f169bcb90b58..0ee33c2e6129 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -59,6 +59,7 @@ struct bdi_writeback {
59 59
60struct backing_dev_info { 60struct backing_dev_info {
61 struct list_head bdi_list; 61 struct list_head bdi_list;
62 struct rcu_head rcu_head;
62 unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */ 63 unsigned long ra_pages; /* max readahead in PAGE_CACHE_SIZE units */
63 unsigned long state; /* Always use atomic bitops on this */ 64 unsigned long state; /* Always use atomic bitops on this */
64 unsigned int capabilities; /* Device capabilities */ 65 unsigned int capabilities; /* Device capabilities */
@@ -100,7 +101,7 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
100 const char *fmt, ...); 101 const char *fmt, ...);
101int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev); 102int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
102void bdi_unregister(struct backing_dev_info *bdi); 103void bdi_unregister(struct backing_dev_info *bdi);
103void bdi_start_writeback(struct writeback_control *wbc); 104void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages);
104int bdi_writeback_task(struct bdi_writeback *wb); 105int bdi_writeback_task(struct bdi_writeback *wb);
105int bdi_has_dirty_io(struct backing_dev_info *bdi); 106int bdi_has_dirty_io(struct backing_dev_info *bdi);
106 107
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index c0f6c3cd788c..91b761846061 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -58,6 +58,7 @@ struct dma_map_ops {
58 enum dma_data_direction dir); 58 enum dma_data_direction dir);
59 int (*mapping_error)(struct device *dev, dma_addr_t dma_addr); 59 int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
60 int (*dma_supported)(struct device *dev, u64 mask); 60 int (*dma_supported)(struct device *dev, u64 mask);
61 int (*set_dma_mask)(struct device *dev, u64 mask);
61 int is_phys; 62 int is_phys;
62}; 63};
63 64
diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h
index fef943738a24..f078f3ac82d4 100644
--- a/include/linux/dvb/dmx.h
+++ b/include/linux/dvb/dmx.h
@@ -151,5 +151,7 @@ struct dmx_stc {
151#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t) 151#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
152#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t) 152#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
153#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc) 153#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
154#define DMX_ADD_PID _IOW('o', 51, __u16)
155#define DMX_REMOVE_PID _IOW('o', 52, __u16)
154 156
155#endif /*_DVBDMX_H_*/ 157#endif /*_DVBDMX_H_*/
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b21cf6b9c80b..90162fb3bf04 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -655,7 +655,6 @@ struct block_device {
655 int bd_invalidated; 655 int bd_invalidated;
656 struct gendisk * bd_disk; 656 struct gendisk * bd_disk;
657 struct list_head bd_list; 657 struct list_head bd_list;
658 struct backing_dev_info *bd_inode_backing_dev_info;
659 /* 658 /*
660 * Private data. You must have bd_claim'ed the block_device 659 * Private data. You must have bd_claim'ed the block_device
661 * to use this. NOTE: bd_claim allows an owner to claim 660 * to use this. NOTE: bd_claim allows an owner to claim
@@ -1343,6 +1342,7 @@ struct super_block {
1343 int s_nr_dentry_unused; /* # of dentry on lru */ 1342 int s_nr_dentry_unused; /* # of dentry on lru */
1344 1343
1345 struct block_device *s_bdev; 1344 struct block_device *s_bdev;
1345 struct backing_dev_info *s_bdi;
1346 struct mtd_info *s_mtd; 1346 struct mtd_info *s_mtd;
1347 struct list_head s_instances; 1347 struct list_head s_instances;
1348 struct quota_info s_dquot; /* Diskquota specific options */ 1348 struct quota_info s_dquot; /* Diskquota specific options */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index edc93a6d931d..e4135d6e0556 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -258,6 +258,7 @@ enum {
258 IDE_TFLAG_DYN = (1 << 5), 258 IDE_TFLAG_DYN = (1 << 5),
259 IDE_TFLAG_FS = (1 << 6), 259 IDE_TFLAG_FS = (1 << 6),
260 IDE_TFLAG_MULTI_PIO = (1 << 7), 260 IDE_TFLAG_MULTI_PIO = (1 << 7),
261 IDE_TFLAG_SET_XFER = (1 << 8),
261}; 262};
262 263
263enum { 264enum {
@@ -294,7 +295,7 @@ struct ide_cmd {
294 } out, in; 295 } out, in;
295 } valid; 296 } valid;
296 297
297 u8 tf_flags; 298 u16 tf_flags;
298 u8 ftf_flags; /* for TASKFILE ioctl */ 299 u8 ftf_flags; /* for TASKFILE ioctl */
299 int protocol; 300 int protocol;
300 301
@@ -918,8 +919,7 @@ __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL)
918typedef struct { 919typedef struct {
919 const char *name; 920 const char *name;
920 mode_t mode; 921 mode_t mode;
921 read_proc_t *read_proc; 922 const struct file_operations *proc_fops;
922 write_proc_t *write_proc;
923} ide_proc_entry_t; 923} ide_proc_entry_t;
924 924
925void proc_ide_create(void); 925void proc_ide_create(void);
@@ -931,24 +931,8 @@ void ide_proc_unregister_port(ide_hwif_t *);
931void ide_proc_register_driver(ide_drive_t *, struct ide_driver *); 931void ide_proc_register_driver(ide_drive_t *, struct ide_driver *);
932void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *); 932void ide_proc_unregister_driver(ide_drive_t *, struct ide_driver *);
933 933
934read_proc_t proc_ide_read_capacity; 934extern const struct file_operations ide_capacity_proc_fops;
935read_proc_t proc_ide_read_geometry; 935extern const struct file_operations ide_geometry_proc_fops;
936
937/*
938 * Standard exit stuff:
939 */
940#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \
941{ \
942 len -= off; \
943 if (len < count) { \
944 *eof = 1; \
945 if (len <= 0) \
946 return 0; \
947 } else \
948 len = count; \
949 *start = page + off; \
950 return len; \
951}
952#else 936#else
953static inline void proc_ide_create(void) { ; } 937static inline void proc_ide_create(void) { ; }
954static inline void proc_ide_destroy(void) { ; } 938static inline void proc_ide_destroy(void) { ; }
@@ -960,7 +944,6 @@ static inline void ide_proc_register_driver(ide_drive_t *drive,
960 struct ide_driver *driver) { ; } 944 struct ide_driver *driver) { ; }
961static inline void ide_proc_unregister_driver(ide_drive_t *drive, 945static inline void ide_proc_unregister_driver(ide_drive_t *drive,
962 struct ide_driver *driver) { ; } 946 struct ide_driver *driver) { ; }
963#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
964#endif 947#endif
965 948
966enum { 949enum {
@@ -1081,6 +1064,7 @@ extern void ide_fixstring(u8 *, const int, const int);
1081 1064
1082int ide_busy_sleep(ide_drive_t *, unsigned long, int); 1065int ide_busy_sleep(ide_drive_t *, unsigned long, int);
1083 1066
1067int __ide_wait_stat(ide_drive_t *, u8, u8, unsigned long, u8 *);
1084int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 1068int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
1085 1069
1086ide_startstop_t ide_do_park_unpark(ide_drive_t *, struct request *); 1070ide_startstop_t ide_do_park_unpark(ide_drive_t *, struct request *);
@@ -1169,7 +1153,7 @@ int ide_no_data_taskfile(ide_drive_t *, struct ide_cmd *);
1169 1153
1170int ide_taskfile_ioctl(ide_drive_t *, unsigned long); 1154int ide_taskfile_ioctl(ide_drive_t *, unsigned long);
1171 1155
1172int ide_dev_read_id(ide_drive_t *, u8, u16 *); 1156int ide_dev_read_id(ide_drive_t *, u8, u16 *, int);
1173 1157
1174extern int ide_driveid_update(ide_drive_t *); 1158extern int ide_driveid_update(ide_drive_t *);
1175extern int ide_config_drive_speed(ide_drive_t *, u8); 1159extern int ide_config_drive_speed(ide_drive_t *, u8);
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
index 0adb0f91568c..97eb928b4924 100644
--- a/include/linux/io-mapping.h
+++ b/include/linux/io-mapping.h
@@ -49,23 +49,30 @@ static inline struct io_mapping *
49io_mapping_create_wc(resource_size_t base, unsigned long size) 49io_mapping_create_wc(resource_size_t base, unsigned long size)
50{ 50{
51 struct io_mapping *iomap; 51 struct io_mapping *iomap;
52 52 pgprot_t prot;
53 if (!is_io_mapping_possible(base, size))
54 return NULL;
55 53
56 iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); 54 iomap = kmalloc(sizeof(*iomap), GFP_KERNEL);
57 if (!iomap) 55 if (!iomap)
58 return NULL; 56 goto out_err;
57
58 if (iomap_create_wc(base, size, &prot))
59 goto out_free;
59 60
60 iomap->base = base; 61 iomap->base = base;
61 iomap->size = size; 62 iomap->size = size;
62 iomap->prot = pgprot_writecombine(__pgprot(__PAGE_KERNEL)); 63 iomap->prot = prot;
63 return iomap; 64 return iomap;
65
66out_free:
67 kfree(iomap);
68out_err:
69 return NULL;
64} 70}
65 71
66static inline void 72static inline void
67io_mapping_free(struct io_mapping *mapping) 73io_mapping_free(struct io_mapping *mapping)
68{ 74{
75 iomap_free(mapping->base, mapping->size);
69 kfree(mapping); 76 kfree(mapping);
70} 77}
71 78
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index b70313d33ff8..274b6196091d 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * MTD partitioning layer definitions 2 * MTD partitioning layer definitions
3 * 3 *
4 * (C) 2000 Nicolas Pitre <nico@cam.org> 4 * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
5 * 5 *
6 * This code is GPL 6 * This code is GPL
7 */ 7 */
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index e2e5ce543595..2b87acfc5f87 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -99,7 +99,7 @@ enum pageflags {
99#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT 99#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
100 PG_mlocked, /* Page is vma mlocked */ 100 PG_mlocked, /* Page is vma mlocked */
101#endif 101#endif
102#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR 102#ifdef CONFIG_ARCH_USES_PG_UNCACHED
103 PG_uncached, /* Page has been mapped as uncached */ 103 PG_uncached, /* Page has been mapped as uncached */
104#endif 104#endif
105 __NR_PAGEFLAGS, 105 __NR_PAGEFLAGS,
@@ -257,7 +257,7 @@ PAGEFLAG_FALSE(Mlocked)
257 SETPAGEFLAG_NOOP(Mlocked) TESTCLEARFLAG_FALSE(Mlocked) 257 SETPAGEFLAG_NOOP(Mlocked) TESTCLEARFLAG_FALSE(Mlocked)
258#endif 258#endif
259 259
260#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR 260#ifdef CONFIG_ARCH_USES_PG_UNCACHED
261PAGEFLAG(Uncached, uncached) 261PAGEFLAG(Uncached, uncached)
262#else 262#else
263PAGEFLAG_FALSE(Uncached) 263PAGEFLAG_FALSE(Uncached)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 115fb7ba5089..f5c7cd343e56 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -241,6 +241,7 @@ struct pci_dev {
241 unsigned int d1_support:1; /* Low power state D1 is supported */ 241 unsigned int d1_support:1; /* Low power state D1 is supported */
242 unsigned int d2_support:1; /* Low power state D2 is supported */ 242 unsigned int d2_support:1; /* Low power state D2 is supported */
243 unsigned int no_d1d2:1; /* Only allow D0 and D3 */ 243 unsigned int no_d1d2:1; /* Only allow D0 and D3 */
244 unsigned int wakeup_prepared:1;
244 245
245#ifdef CONFIG_PCIEASPM 246#ifdef CONFIG_PCIEASPM
246 struct pcie_link_state *link_state; /* ASPM link state. */ 247 struct pcie_link_state *link_state; /* ASPM link state. */
@@ -273,9 +274,12 @@ struct pci_dev {
273 unsigned int ari_enabled:1; /* ARI forwarding */ 274 unsigned int ari_enabled:1; /* ARI forwarding */
274 unsigned int is_managed:1; 275 unsigned int is_managed:1;
275 unsigned int is_pcie:1; 276 unsigned int is_pcie:1;
277 unsigned int needs_freset:1; /* Dev requires fundamental reset */
276 unsigned int state_saved:1; 278 unsigned int state_saved:1;
277 unsigned int is_physfn:1; 279 unsigned int is_physfn:1;
278 unsigned int is_virtfn:1; 280 unsigned int is_virtfn:1;
281 unsigned int reset_fn:1;
282 unsigned int is_hotplug_bridge:1;
279 pci_dev_flags_t dev_flags; 283 pci_dev_flags_t dev_flags;
280 atomic_t enable_cnt; /* pci_enable_device has been called */ 284 atomic_t enable_cnt; /* pci_enable_device has been called */
281 285
@@ -794,6 +798,11 @@ int __must_check __pci_register_driver(struct pci_driver *, struct module *,
794void pci_unregister_driver(struct pci_driver *dev); 798void pci_unregister_driver(struct pci_driver *dev);
795void pci_remove_behind_bridge(struct pci_dev *dev); 799void pci_remove_behind_bridge(struct pci_dev *dev);
796struct pci_driver *pci_dev_driver(const struct pci_dev *dev); 800struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
801int pci_add_dynid(struct pci_driver *drv,
802 unsigned int vendor, unsigned int device,
803 unsigned int subvendor, unsigned int subdevice,
804 unsigned int class, unsigned int class_mask,
805 unsigned long driver_data);
797const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, 806const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
798 struct pci_dev *dev); 807 struct pci_dev *dev);
799int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, 808int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
@@ -805,6 +814,8 @@ int pci_cfg_space_size_ext(struct pci_dev *dev);
805int pci_cfg_space_size(struct pci_dev *dev); 814int pci_cfg_space_size(struct pci_dev *dev);
806unsigned char pci_bus_max_busnr(struct pci_bus *bus); 815unsigned char pci_bus_max_busnr(struct pci_bus *bus);
807 816
817int pci_set_vga_state(struct pci_dev *pdev, bool decode,
818 unsigned int command_bits, bool change_bridge);
808/* kmem_cache style wrapper around pci_alloc_consistent() */ 819/* kmem_cache style wrapper around pci_alloc_consistent() */
809 820
810#include <linux/dmapool.h> 821#include <linux/dmapool.h>
@@ -1236,6 +1247,9 @@ extern int pci_pci_problems;
1236extern unsigned long pci_cardbus_io_size; 1247extern unsigned long pci_cardbus_io_size;
1237extern unsigned long pci_cardbus_mem_size; 1248extern unsigned long pci_cardbus_mem_size;
1238 1249
1250extern unsigned long pci_hotplug_io_size;
1251extern unsigned long pci_hotplug_mem_size;
1252
1239int pcibios_add_platform_entries(struct pci_dev *dev); 1253int pcibios_add_platform_entries(struct pci_dev *dev);
1240void pcibios_disable_device(struct pci_dev *dev); 1254void pcibios_disable_device(struct pci_dev *dev);
1241int pcibios_set_pcie_reset_state(struct pci_dev *dev, 1255int pcibios_set_pcie_reset_state(struct pci_dev *dev,
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 4391741b99dc..652ba797696d 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -62,7 +62,8 @@ enum pcie_link_width {
62}; 62};
63 63
64enum pcie_link_speed { 64enum pcie_link_speed {
65 PCIE_2PT5GB = 0x14, 65 PCIE_2_5GB = 0x14,
66 PCIE_5_0GB = 0x15,
66 PCIE_LNK_SPEED_UNKNOWN = 0xFF, 67 PCIE_LNK_SPEED_UNKNOWN = 0xFF,
67}; 68};
68 69
@@ -226,11 +227,18 @@ struct hotplug_params {
226#ifdef CONFIG_ACPI 227#ifdef CONFIG_ACPI
227#include <acpi/acpi.h> 228#include <acpi/acpi.h>
228#include <acpi/acpi_bus.h> 229#include <acpi/acpi_bus.h>
229extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus, 230int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
230 struct hotplug_params *hpp);
231int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags); 231int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
232int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle); 232int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
233int acpi_pci_detect_ejectable(struct pci_bus *pbus); 233int acpi_pci_detect_ejectable(acpi_handle handle);
234#else
235static inline int pci_get_hp_params(struct pci_dev *dev,
236 struct hotplug_params *hpp)
237{
238 return -ENODEV;
239}
234#endif 240#endif
241
242void pci_configure_slot(struct pci_dev *dev);
235#endif 243#endif
236 244
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 555a8262fbc2..8975add8668f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2,6 +2,9 @@
2 * PCI Class, Vendor and Device IDs 2 * PCI Class, Vendor and Device IDs
3 * 3 *
4 * Please keep sorted. 4 * Please keep sorted.
5 *
6 * Do not add new entries to this file unless the definitions
7 * are shared between multiple drivers.
5 */ 8 */
6 9
7/* Device classes and subclasses */ 10/* Device classes and subclasses */
@@ -881,6 +884,7 @@
881#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051 884#define PCI_DEVICE_ID_APPLE_SH_SUNGEM 0x0051
882#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058 885#define PCI_DEVICE_ID_APPLE_U3L_AGP 0x0058
883#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059 886#define PCI_DEVICE_ID_APPLE_U3H_AGP 0x0059
887#define PCI_DEVICE_ID_APPLE_U4_PCIE 0x005b
884#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066 888#define PCI_DEVICE_ID_APPLE_IPID2_AGP 0x0066
885#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069 889#define PCI_DEVICE_ID_APPLE_IPID2_ATA 0x0069
886#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a 890#define PCI_DEVICE_ID_APPLE_IPID2_FW 0x006a
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 0761491b3eec..9bd03193ecd4 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -10,22 +10,70 @@
10/* 10/*
11 * Base implementations of per-CPU variable declarations and definitions, where 11 * Base implementations of per-CPU variable declarations and definitions, where
12 * the section in which the variable is to be placed is provided by the 12 * the section in which the variable is to be placed is provided by the
13 * 'section' argument. This may be used to affect the parameters governing the 13 * 'sec' argument. This may be used to affect the parameters governing the
14 * variable's storage. 14 * variable's storage.
15 * 15 *
16 * NOTE! The sections for the DECLARE and for the DEFINE must match, lest 16 * NOTE! The sections for the DECLARE and for the DEFINE must match, lest
17 * linkage errors occur due the compiler generating the wrong code to access 17 * linkage errors occur due the compiler generating the wrong code to access
18 * that section. 18 * that section.
19 */ 19 */
20#define DECLARE_PER_CPU_SECTION(type, name, section) \ 20#define __PCPU_ATTRS(sec) \
21 extern \ 21 __attribute__((section(PER_CPU_BASE_SECTION sec))) \
22 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ 22 PER_CPU_ATTRIBUTES
23 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name 23
24 24#define __PCPU_DUMMY_ATTRS \
25#define DEFINE_PER_CPU_SECTION(type, name, section) \ 25 __attribute__((section(".discard"), unused))
26 __attribute__((__section__(PER_CPU_BASE_SECTION section))) \ 26
27 PER_CPU_ATTRIBUTES PER_CPU_DEF_ATTRIBUTES \ 27/*
28 * s390 and alpha modules require percpu variables to be defined as
29 * weak to force the compiler to generate GOT based external
30 * references for them. This is necessary because percpu sections
31 * will be located outside of the usually addressable area.
32 *
33 * This definition puts the following two extra restrictions when
34 * defining percpu variables.
35 *
36 * 1. The symbol must be globally unique, even the static ones.
37 * 2. Static percpu variables cannot be defined inside a function.
38 *
39 * Archs which need weak percpu definitions should define
40 * ARCH_NEEDS_WEAK_PER_CPU in asm/percpu.h when necessary.
41 *
42 * To ensure that the generic code observes the above two
43 * restrictions, if CONFIG_DEBUG_FORCE_WEAK_PER_CPU is set weak
44 * definition is used for all cases.
45 */
46#if defined(ARCH_NEEDS_WEAK_PER_CPU) || defined(CONFIG_DEBUG_FORCE_WEAK_PER_CPU)
47/*
48 * __pcpu_scope_* dummy variable is used to enforce scope. It
49 * receives the static modifier when it's used in front of
50 * DEFINE_PER_CPU() and will trigger build failure if
51 * DECLARE_PER_CPU() is used for the same variable.
52 *
53 * __pcpu_unique_* dummy variable is used to enforce symbol uniqueness
54 * such that hidden weak symbol collision, which will cause unrelated
55 * variables to share the same address, can be detected during build.
56 */
57#define DECLARE_PER_CPU_SECTION(type, name, sec) \
58 extern __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
59 extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
60
61#define DEFINE_PER_CPU_SECTION(type, name, sec) \
62 __PCPU_DUMMY_ATTRS char __pcpu_scope_##name; \
63 __PCPU_DUMMY_ATTRS char __pcpu_unique_##name; \
64 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES __weak \
65 __typeof__(type) per_cpu__##name
66#else
67/*
68 * Normal declaration and definition macros.
69 */
70#define DECLARE_PER_CPU_SECTION(type, name, sec) \
71 extern __PCPU_ATTRS(sec) __typeof__(type) per_cpu__##name
72
73#define DEFINE_PER_CPU_SECTION(type, name, sec) \
74 __PCPU_ATTRS(sec) PER_CPU_DEF_ATTRIBUTES \
28 __typeof__(type) per_cpu__##name 75 __typeof__(type) per_cpu__##name
76#endif
29 77
30/* 78/*
31 * Variant on the per-CPU variable declaration/definition theme used for 79 * Variant on the per-CPU variable declaration/definition theme used for
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 26fd9d12f050..878836ca999c 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -34,7 +34,7 @@
34 34
35#ifdef CONFIG_SMP 35#ifdef CONFIG_SMP
36 36
37#ifdef CONFIG_HAVE_DYNAMIC_PER_CPU_AREA 37#ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA
38 38
39/* minimum unit size, also is the maximum supported allocation size */ 39/* minimum unit size, also is the maximum supported allocation size */
40#define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10) 40#define PCPU_MIN_UNIT_SIZE PFN_ALIGN(64 << 10)
@@ -57,19 +57,70 @@
57#endif 57#endif
58 58
59extern void *pcpu_base_addr; 59extern void *pcpu_base_addr;
60extern const unsigned long *pcpu_unit_offsets;
60 61
61typedef struct page * (*pcpu_get_page_fn_t)(unsigned int cpu, int pageno); 62struct pcpu_group_info {
62typedef void (*pcpu_populate_pte_fn_t)(unsigned long addr); 63 int nr_units; /* aligned # of units */
64 unsigned long base_offset; /* base address offset */
65 unsigned int *cpu_map; /* unit->cpu map, empty
66 * entries contain NR_CPUS */
67};
68
69struct pcpu_alloc_info {
70 size_t static_size;
71 size_t reserved_size;
72 size_t dyn_size;
73 size_t unit_size;
74 size_t atom_size;
75 size_t alloc_size;
76 size_t __ai_size; /* internal, don't use */
77 int nr_groups; /* 0 if grouping unnecessary */
78 struct pcpu_group_info groups[];
79};
63 80
64extern size_t __init pcpu_setup_first_chunk(pcpu_get_page_fn_t get_page_fn, 81enum pcpu_fc {
65 size_t static_size, size_t reserved_size, 82 PCPU_FC_AUTO,
66 ssize_t dyn_size, ssize_t unit_size, 83 PCPU_FC_EMBED,
67 void *base_addr, 84 PCPU_FC_PAGE,
68 pcpu_populate_pte_fn_t populate_pte_fn);
69 85
70extern ssize_t __init pcpu_embed_first_chunk( 86 PCPU_FC_NR,
71 size_t static_size, size_t reserved_size, 87};
72 ssize_t dyn_size, ssize_t unit_size); 88extern const char *pcpu_fc_names[PCPU_FC_NR];
89
90extern enum pcpu_fc pcpu_chosen_fc;
91
92typedef void * (*pcpu_fc_alloc_fn_t)(unsigned int cpu, size_t size,
93 size_t align);
94typedef void (*pcpu_fc_free_fn_t)(void *ptr, size_t size);
95typedef void (*pcpu_fc_populate_pte_fn_t)(unsigned long addr);
96typedef int (pcpu_fc_cpu_distance_fn_t)(unsigned int from, unsigned int to);
97
98extern struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
99 int nr_units);
100extern void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai);
101
102extern struct pcpu_alloc_info * __init pcpu_build_alloc_info(
103 size_t reserved_size, ssize_t dyn_size,
104 size_t atom_size,
105 pcpu_fc_cpu_distance_fn_t cpu_distance_fn);
106
107extern int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
108 void *base_addr);
109
110#ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK
111extern int __init pcpu_embed_first_chunk(size_t reserved_size, ssize_t dyn_size,
112 size_t atom_size,
113 pcpu_fc_cpu_distance_fn_t cpu_distance_fn,
114 pcpu_fc_alloc_fn_t alloc_fn,
115 pcpu_fc_free_fn_t free_fn);
116#endif
117
118#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
119extern int __init pcpu_page_first_chunk(size_t reserved_size,
120 pcpu_fc_alloc_fn_t alloc_fn,
121 pcpu_fc_free_fn_t free_fn,
122 pcpu_fc_populate_pte_fn_t populate_pte_fn);
123#endif
73 124
74/* 125/*
75 * Use this to get to a cpu's version of the per-cpu object 126 * Use this to get to a cpu's version of the per-cpu object
@@ -80,7 +131,7 @@ extern ssize_t __init pcpu_embed_first_chunk(
80 131
81extern void *__alloc_reserved_percpu(size_t size, size_t align); 132extern void *__alloc_reserved_percpu(size_t size, size_t align);
82 133
83#else /* CONFIG_HAVE_DYNAMIC_PER_CPU_AREA */ 134#else /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */
84 135
85struct percpu_data { 136struct percpu_data {
86 void *ptrs[1]; 137 void *ptrs[1];
@@ -99,11 +150,15 @@ struct percpu_data {
99 (__typeof__(ptr))__p->ptrs[(cpu)]; \ 150 (__typeof__(ptr))__p->ptrs[(cpu)]; \
100}) 151})
101 152
102#endif /* CONFIG_HAVE_DYNAMIC_PER_CPU_AREA */ 153#endif /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */
103 154
104extern void *__alloc_percpu(size_t size, size_t align); 155extern void *__alloc_percpu(size_t size, size_t align);
105extern void free_percpu(void *__pdata); 156extern void free_percpu(void *__pdata);
106 157
158#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
159extern void __init setup_per_cpu_areas(void);
160#endif
161
107#else /* CONFIG_SMP */ 162#else /* CONFIG_SMP */
108 163
109#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) 164#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); })
@@ -124,6 +179,13 @@ static inline void free_percpu(void *p)
124 kfree(p); 179 kfree(p);
125} 180}
126 181
182static inline void __init setup_per_cpu_areas(void) { }
183
184static inline void *pcpu_lpage_remapped(void *kaddr)
185{
186 return NULL;
187}
188
127#endif /* CONFIG_SMP */ 189#endif /* CONFIG_SMP */
128 190
129#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \ 191#define alloc_percpu(type) (type *)__alloc_percpu(sizeof(type), \
diff --git a/include/linux/tboot.h b/include/linux/tboot.h
new file mode 100644
index 000000000000..bf2a0c748878
--- /dev/null
+++ b/include/linux/tboot.h
@@ -0,0 +1,162 @@
1/*
2 * tboot.h: shared data structure with tboot and kernel and functions
3 * used by kernel for runtime support of Intel(R) Trusted
4 * Execution Technology
5 *
6 * Copyright (c) 2006-2009, Intel Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23#ifndef _LINUX_TBOOT_H
24#define _LINUX_TBOOT_H
25
26/* these must have the values from 0-5 in this order */
27enum {
28 TB_SHUTDOWN_REBOOT = 0,
29 TB_SHUTDOWN_S5,
30 TB_SHUTDOWN_S4,
31 TB_SHUTDOWN_S3,
32 TB_SHUTDOWN_HALT,
33 TB_SHUTDOWN_WFS
34};
35
36#ifdef CONFIG_INTEL_TXT
37#include <acpi/acpi.h>
38/* used to communicate between tboot and the launched kernel */
39
40#define TB_KEY_SIZE 64 /* 512 bits */
41
42#define MAX_TB_MAC_REGIONS 32
43
44struct tboot_mac_region {
45 u64 start; /* must be 64 byte -aligned */
46 u32 size; /* must be 64 byte -granular */
47} __packed;
48
49/* GAS - Generic Address Structure (ACPI 2.0+) */
50struct tboot_acpi_generic_address {
51 u8 space_id;
52 u8 bit_width;
53 u8 bit_offset;
54 u8 access_width;
55 u64 address;
56} __packed;
57
58/*
59 * combines Sx info from FADT and FACS tables per ACPI 2.0+ spec
60 * (http://www.acpi.info/)
61 */
62struct tboot_acpi_sleep_info {
63 struct tboot_acpi_generic_address pm1a_cnt_blk;
64 struct tboot_acpi_generic_address pm1b_cnt_blk;
65 struct tboot_acpi_generic_address pm1a_evt_blk;
66 struct tboot_acpi_generic_address pm1b_evt_blk;
67 u16 pm1a_cnt_val;
68 u16 pm1b_cnt_val;
69 u64 wakeup_vector;
70 u32 vector_width;
71 u64 kernel_s3_resume_vector;
72} __packed;
73
74/*
75 * shared memory page used for communication between tboot and kernel
76 */
77struct tboot {
78 /*
79 * version 3+ fields:
80 */
81
82 /* TBOOT_UUID */
83 u8 uuid[16];
84
85 /* version number: 5 is current */
86 u32 version;
87
88 /* physical addr of tb_log_t log */
89 u32 log_addr;
90
91 /*
92 * physical addr of entry point for tboot shutdown and
93 * type of shutdown (TB_SHUTDOWN_*) being requested
94 */
95 u32 shutdown_entry;
96 u32 shutdown_type;
97
98 /* kernel-specified ACPI info for Sx shutdown */
99 struct tboot_acpi_sleep_info acpi_sinfo;
100
101 /* tboot location in memory (physical) */
102 u32 tboot_base;
103 u32 tboot_size;
104
105 /* memory regions (phys addrs) for tboot to MAC on S3 */
106 u8 num_mac_regions;
107 struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS];
108
109
110 /*
111 * version 4+ fields:
112 */
113
114 /* symmetric key for use by kernel; will be encrypted on S3 */
115 u8 s3_key[TB_KEY_SIZE];
116
117
118 /*
119 * version 5+ fields:
120 */
121
122 /* used to 4byte-align num_in_wfs */
123 u8 reserved_align[3];
124
125 /* number of processors in wait-for-SIPI */
126 u32 num_in_wfs;
127} __packed;
128
129/*
130 * UUID for tboot data struct to facilitate matching
131 * defined as {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} by tboot, which is
132 * represented as {} in the char array used here
133 */
134#define TBOOT_UUID {0xff, 0x8d, 0x3c, 0x66, 0xb3, 0xe8, 0x82, 0x4b, 0xbf,\
135 0xaa, 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8}
136
137extern struct tboot *tboot;
138
139static inline int tboot_enabled(void)
140{
141 return tboot != NULL;
142}
143
144extern void tboot_probe(void);
145extern void tboot_shutdown(u32 shutdown_type);
146extern void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control);
147extern struct acpi_table_header *tboot_get_dmar_table(
148 struct acpi_table_header *dmar_tbl);
149extern int tboot_force_iommu(void);
150
151#else
152
153#define tboot_probe() do { } while (0)
154#define tboot_shutdown(shutdown_type) do { } while (0)
155#define tboot_sleep(sleep_state, pm1a_control, pm1b_control) \
156 do { } while (0)
157#define tboot_get_dmar_table(dmar_tbl) (dmar_tbl)
158#define tboot_force_iommu() 0
159
160#endif /* !CONFIG_INTEL_TXT */
161
162#endif /* _LINUX_TBOOT_H */
diff --git a/include/linux/usb/video.h b/include/linux/usb/video.h
new file mode 100644
index 000000000000..be436d9ee479
--- /dev/null
+++ b/include/linux/usb/video.h
@@ -0,0 +1,164 @@
1/*
2 * USB Video Class definitions.
3 *
4 * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
5 *
6 * This file holds USB constants and structures defined by the USB Device
7 * Class Definition for Video Devices. Unless otherwise stated, comments
8 * below reference relevant sections of the USB Video Class 1.1 specification
9 * available at
10 *
11 * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
12 */
13
14#ifndef __LINUX_USB_VIDEO_H
15#define __LINUX_USB_VIDEO_H
16
17#include <linux/types.h>
18
19/* --------------------------------------------------------------------------
20 * UVC constants
21 */
22
23/* A.2. Video Interface Subclass Codes */
24#define UVC_SC_UNDEFINED 0x00
25#define UVC_SC_VIDEOCONTROL 0x01
26#define UVC_SC_VIDEOSTREAMING 0x02
27#define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
28
29/* A.3. Video Interface Protocol Codes */
30#define UVC_PC_PROTOCOL_UNDEFINED 0x00
31
32/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
33#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
34#define UVC_VC_HEADER 0x01
35#define UVC_VC_INPUT_TERMINAL 0x02
36#define UVC_VC_OUTPUT_TERMINAL 0x03
37#define UVC_VC_SELECTOR_UNIT 0x04
38#define UVC_VC_PROCESSING_UNIT 0x05
39#define UVC_VC_EXTENSION_UNIT 0x06
40
41/* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
42#define UVC_VS_UNDEFINED 0x00
43#define UVC_VS_INPUT_HEADER 0x01
44#define UVC_VS_OUTPUT_HEADER 0x02
45#define UVC_VS_STILL_IMAGE_FRAME 0x03
46#define UVC_VS_FORMAT_UNCOMPRESSED 0x04
47#define UVC_VS_FRAME_UNCOMPRESSED 0x05
48#define UVC_VS_FORMAT_MJPEG 0x06
49#define UVC_VS_FRAME_MJPEG 0x07
50#define UVC_VS_FORMAT_MPEG2TS 0x0a
51#define UVC_VS_FORMAT_DV 0x0c
52#define UVC_VS_COLORFORMAT 0x0d
53#define UVC_VS_FORMAT_FRAME_BASED 0x10
54#define UVC_VS_FRAME_FRAME_BASED 0x11
55#define UVC_VS_FORMAT_STREAM_BASED 0x12
56
57/* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
58#define UVC_EP_UNDEFINED 0x00
59#define UVC_EP_GENERAL 0x01
60#define UVC_EP_ENDPOINT 0x02
61#define UVC_EP_INTERRUPT 0x03
62
63/* A.8. Video Class-Specific Request Codes */
64#define UVC_RC_UNDEFINED 0x00
65#define UVC_SET_CUR 0x01
66#define UVC_GET_CUR 0x81
67#define UVC_GET_MIN 0x82
68#define UVC_GET_MAX 0x83
69#define UVC_GET_RES 0x84
70#define UVC_GET_LEN 0x85
71#define UVC_GET_INFO 0x86
72#define UVC_GET_DEF 0x87
73
74/* A.9.1. VideoControl Interface Control Selectors */
75#define UVC_VC_CONTROL_UNDEFINED 0x00
76#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
77#define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
78
79/* A.9.2. Terminal Control Selectors */
80#define UVC_TE_CONTROL_UNDEFINED 0x00
81
82/* A.9.3. Selector Unit Control Selectors */
83#define UVC_SU_CONTROL_UNDEFINED 0x00
84#define UVC_SU_INPUT_SELECT_CONTROL 0x01
85
86/* A.9.4. Camera Terminal Control Selectors */
87#define UVC_CT_CONTROL_UNDEFINED 0x00
88#define UVC_CT_SCANNING_MODE_CONTROL 0x01
89#define UVC_CT_AE_MODE_CONTROL 0x02
90#define UVC_CT_AE_PRIORITY_CONTROL 0x03
91#define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
92#define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
93#define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
94#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
95#define UVC_CT_FOCUS_AUTO_CONTROL 0x08
96#define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
97#define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
98#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
99#define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
100#define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
101#define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
102#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
103#define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
104#define UVC_CT_PRIVACY_CONTROL 0x11
105
106/* A.9.5. Processing Unit Control Selectors */
107#define UVC_PU_CONTROL_UNDEFINED 0x00
108#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
109#define UVC_PU_BRIGHTNESS_CONTROL 0x02
110#define UVC_PU_CONTRAST_CONTROL 0x03
111#define UVC_PU_GAIN_CONTROL 0x04
112#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
113#define UVC_PU_HUE_CONTROL 0x06
114#define UVC_PU_SATURATION_CONTROL 0x07
115#define UVC_PU_SHARPNESS_CONTROL 0x08
116#define UVC_PU_GAMMA_CONTROL 0x09
117#define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
118#define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
119#define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
120#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
121#define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
122#define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
123#define UVC_PU_HUE_AUTO_CONTROL 0x10
124#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
125#define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
126
127/* A.9.7. VideoStreaming Interface Control Selectors */
128#define UVC_VS_CONTROL_UNDEFINED 0x00
129#define UVC_VS_PROBE_CONTROL 0x01
130#define UVC_VS_COMMIT_CONTROL 0x02
131#define UVC_VS_STILL_PROBE_CONTROL 0x03
132#define UVC_VS_STILL_COMMIT_CONTROL 0x04
133#define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
134#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
135#define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
136#define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
137#define UVC_VS_SYNC_DELAY_CONTROL 0x09
138
139/* B.1. USB Terminal Types */
140#define UVC_TT_VENDOR_SPECIFIC 0x0100
141#define UVC_TT_STREAMING 0x0101
142
143/* B.2. Input Terminal Types */
144#define UVC_ITT_VENDOR_SPECIFIC 0x0200
145#define UVC_ITT_CAMERA 0x0201
146#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
147
148/* B.3. Output Terminal Types */
149#define UVC_OTT_VENDOR_SPECIFIC 0x0300
150#define UVC_OTT_DISPLAY 0x0301
151#define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
152
153/* B.4. External Terminal Types */
154#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
155#define UVC_COMPOSITE_CONNECTOR 0x0401
156#define UVC_SVIDEO_CONNECTOR 0x0402
157#define UVC_COMPONENT_CONNECTOR 0x0403
158
159/* 2.4.2.2. Status Packet Type */
160#define UVC_STATUS_TYPE_CONTROL 1
161#define UVC_STATUS_TYPE_STREAMING 2
162
163#endif /* __LINUX_USB_VIDEO_H */
164
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
new file mode 100644
index 000000000000..e81c64af80c1
--- /dev/null
+++ b/include/linux/vgaarb.h
@@ -0,0 +1,200 @@
1/*
2 * vgaarb.c
3 *
4 * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com>
6 * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org>
7 */
8
9#ifndef LINUX_VGA_H
10
11#include <asm/vga.h>
12
13/* Legacy VGA regions */
14#define VGA_RSRC_NONE 0x00
15#define VGA_RSRC_LEGACY_IO 0x01
16#define VGA_RSRC_LEGACY_MEM 0x02
17#define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
18/* Non-legacy access */
19#define VGA_RSRC_NORMAL_IO 0x04
20#define VGA_RSRC_NORMAL_MEM 0x08
21
22/* Passing that instead of a pci_dev to use the system "default"
23 * device, that is the one used by vgacon. Archs will probably
24 * have to provide their own vga_default_device();
25 */
26#define VGA_DEFAULT_DEVICE (NULL)
27
28/* For use by clients */
29
30/**
31 * vga_set_legacy_decoding
32 *
33 * @pdev: pci device of the VGA card
34 * @decodes: bit mask of what legacy regions the card decodes
35 *
36 * Indicates to the arbiter if the card decodes legacy VGA IOs,
37 * legacy VGA Memory, both, or none. All cards default to both,
38 * the card driver (fbdev for example) should tell the arbiter
39 * if it has disabled legacy decoding, so the card can be left
40 * out of the arbitration process (and can be safe to take
41 * interrupts at any time.
42 */
43extern void vga_set_legacy_decoding(struct pci_dev *pdev,
44 unsigned int decodes);
45
46/**
47 * vga_get - acquire & locks VGA resources
48 *
49 * @pdev: pci device of the VGA card or NULL for the system default
50 * @rsrc: bit mask of resources to acquire and lock
51 * @interruptible: blocking should be interruptible by signals ?
52 *
53 * This function acquires VGA resources for the given
54 * card and mark those resources locked. If the resource requested
55 * are "normal" (and not legacy) resources, the arbiter will first check
56 * wether the card is doing legacy decoding for that type of resource. If
57 * yes, the lock is "converted" into a legacy resource lock.
58 * The arbiter will first look for all VGA cards that might conflict
59 * and disable their IOs and/or Memory access, inlcuding VGA forwarding
60 * on P2P bridges if necessary, so that the requested resources can
61 * be used. Then, the card is marked as locking these resources and
62 * the IO and/or Memory accesse are enabled on the card (including
63 * VGA forwarding on parent P2P bridges if any).
64 * This function will block if some conflicting card is already locking
65 * one of the required resources (or any resource on a different bus
66 * segment, since P2P bridges don't differenciate VGA memory and IO
67 * afaik). You can indicate wether this blocking should be interruptible
68 * by a signal (for userland interface) or not.
69 * Must not be called at interrupt time or in atomic context.
70 * If the card already owns the resources, the function succeeds.
71 * Nested calls are supported (a per-resource counter is maintained)
72 */
73
74extern int vga_get(struct pci_dev *pdev, unsigned int rsrc,
75 int interruptible);
76
77/**
78 * vga_get_interruptible
79 *
80 * Shortcut to vga_get
81 */
82
83static inline int vga_get_interruptible(struct pci_dev *pdev,
84 unsigned int rsrc)
85{
86 return vga_get(pdev, rsrc, 1);
87}
88
89/**
90 * vga_get_uninterruptible
91 *
92 * Shortcut to vga_get
93 */
94
95static inline int vga_get_uninterruptible(struct pci_dev *pdev,
96 unsigned int rsrc)
97{
98 return vga_get(pdev, rsrc, 0);
99}
100
101/**
102 * vga_tryget - try to acquire & lock legacy VGA resources
103 *
104 * @pdev: pci devivce of VGA card or NULL for system default
105 * @rsrc: bit mask of resources to acquire and lock
106 *
107 * This function performs the same operation as vga_get(), but
108 * will return an error (-EBUSY) instead of blocking if the resources
109 * are already locked by another card. It can be called in any context
110 */
111
112extern int vga_tryget(struct pci_dev *pdev, unsigned int rsrc);
113
114/**
115 * vga_put - release lock on legacy VGA resources
116 *
117 * @pdev: pci device of VGA card or NULL for system default
118 * @rsrc: but mask of resource to release
119 *
120 * This function releases resources previously locked by vga_get()
121 * or vga_tryget(). The resources aren't disabled right away, so
122 * that a subsequence vga_get() on the same card will succeed
123 * immediately. Resources have a counter, so locks are only
124 * released if the counter reaches 0.
125 */
126
127extern void vga_put(struct pci_dev *pdev, unsigned int rsrc);
128
129
130/**
131 * vga_default_device
132 *
133 * This can be defined by the platform. The default implementation
134 * is rather dumb and will probably only work properly on single
135 * vga card setups and/or x86 platforms.
136 *
137 * If your VGA default device is not PCI, you'll have to return
138 * NULL here. In this case, I assume it will not conflict with
139 * any PCI card. If this is not true, I'll have to define two archs
140 * hooks for enabling/disabling the VGA default device if that is
141 * possible. This may be a problem with real _ISA_ VGA cards, in
142 * addition to a PCI one. I don't know at this point how to deal
143 * with that card. Can theirs IOs be disabled at all ? If not, then
144 * I suppose it's a matter of having the proper arch hook telling
145 * us about it, so we basically never allow anybody to succeed a
146 * vga_get()...
147 */
148
149#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
150extern struct pci_dev *vga_default_device(void);
151#endif
152
153/**
154 * vga_conflicts
155 *
156 * Architectures should define this if they have several
157 * independant PCI domains that can afford concurrent VGA
158 * decoding
159 */
160
161#ifndef __ARCH_HAS_VGA_CONFLICT
162static inline int vga_conflicts(struct pci_dev *p1, struct pci_dev *p2)
163{
164 return 1;
165}
166#endif
167
168/**
169 * vga_client_register
170 *
171 * @pdev: pci device of the VGA client
172 * @cookie: client cookie to be used in callbacks
173 * @irq_set_state: irq state change callback
174 * @set_vga_decode: vga decode change callback
175 *
176 * return value: 0 on success, -1 on failure
177 * Register a client with the VGA arbitration logic
178 *
179 * Clients have two callback mechanisms they can use.
180 * irq enable/disable callback -
181 * If a client can't disable its GPUs VGA resources, then we
182 * need to be able to ask it to turn off its irqs when we
183 * turn off its mem and io decoding.
184 * set_vga_decode
185 * If a client can disable its GPU VGA resource, it will
186 * get a callback from this to set the encode/decode state
187 *
188 * Rationale: we cannot disable VGA decode resources unconditionally
189 * some single GPU laptops seem to require ACPI or BIOS access to the
190 * VGA registers to control things like backlights etc.
191 * Hopefully newer multi-GPU laptops do something saner, and desktops
192 * won't have any special ACPI for this.
193 * They driver will get a callback when VGA arbitration is first used
194 * by userspace since we some older X servers have issues.
195 */
196int vga_client_register(struct pci_dev *pdev, void *cookie,
197 void (*irq_set_state)(void *cookie, bool state),
198 unsigned int (*set_vga_decode)(void *cookie, bool state));
199
200#endif /* LINUX_VGA_H */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 74f16876f38d..3689d7d81fe9 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -167,6 +167,7 @@ enum v4l2_ctrl_type {
167 V4L2_CTRL_TYPE_BUTTON = 4, 167 V4L2_CTRL_TYPE_BUTTON = 4,
168 V4L2_CTRL_TYPE_INTEGER64 = 5, 168 V4L2_CTRL_TYPE_INTEGER64 = 5,
169 V4L2_CTRL_TYPE_CTRL_CLASS = 6, 169 V4L2_CTRL_TYPE_CTRL_CLASS = 6,
170 V4L2_CTRL_TYPE_STRING = 7,
170}; 171};
171 172
172enum v4l2_tuner_type { 173enum v4l2_tuner_type {
@@ -252,10 +253,12 @@ struct v4l2_capability {
252#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ 253#define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */
253#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */ 254#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */
254#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */ 255#define V4L2_CAP_HW_FREQ_SEEK 0x00000400 /* Can do hardware frequency seek */
256#define V4L2_CAP_RDS_OUTPUT 0x00000800 /* Is an RDS encoder */
255 257
256#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 258#define V4L2_CAP_TUNER 0x00010000 /* has a tuner */
257#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ 259#define V4L2_CAP_AUDIO 0x00020000 /* has audio support */
258#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */ 260#define V4L2_CAP_RADIO 0x00040000 /* is a radio device */
261#define V4L2_CAP_MODULATOR 0x00080000 /* has a modulator */
259 262
260#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */ 263#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
261#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */ 264#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
@@ -275,7 +278,9 @@ struct v4l2_pix_format {
275 __u32 priv; /* private data, depends on pixelformat */ 278 __u32 priv; /* private data, depends on pixelformat */
276}; 279};
277 280
278/* Pixel format FOURCC depth Description */ 281/* Pixel format FOURCC depth Description */
282
283/* RGB formats */
279#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */ 284#define V4L2_PIX_FMT_RGB332 v4l2_fourcc('R', 'G', 'B', '1') /* 8 RGB-3-3-2 */
280#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */ 285#define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R', '4', '4', '4') /* 16 xxxxrrrr ggggbbbb */
281#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */ 286#define V4L2_PIX_FMT_RGB555 v4l2_fourcc('R', 'G', 'B', 'O') /* 16 RGB-5-5-5 */
@@ -286,12 +291,20 @@ struct v4l2_pix_format {
286#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */ 291#define V4L2_PIX_FMT_RGB24 v4l2_fourcc('R', 'G', 'B', '3') /* 24 RGB-8-8-8 */
287#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */ 292#define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B', 'G', 'R', '4') /* 32 BGR-8-8-8-8 */
288#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */ 293#define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R', 'G', 'B', '4') /* 32 RGB-8-8-8-8 */
294
295/* Grey formats */
289#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */ 296#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
290#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */ 297#define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y', '1', '6', ' ') /* 16 Greyscale */
298
299/* Palette formats */
291#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */ 300#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
301
302/* Luminance+Chrominance formats */
292#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */ 303#define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */
293#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ 304#define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */
294#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ 305#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */
306#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
307#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
295#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ 308#define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */
296#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ 309#define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */
297#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ 310#define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */
@@ -301,6 +314,10 @@ struct v4l2_pix_format {
301#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ 314#define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */
302#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ 315#define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */
303#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ 316#define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */
317#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
318#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
319#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
320#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
304 321
305/* two planes -- one Y, one Cr + Cb interleaved */ 322/* two planes -- one Y, one Cr + Cb interleaved */
306#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */ 323#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
@@ -308,25 +325,17 @@ struct v4l2_pix_format {
308#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */ 325#define V4L2_PIX_FMT_NV16 v4l2_fourcc('N', 'V', '1', '6') /* 16 Y/CbCr 4:2:2 */
309#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */ 326#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
310 327
311/* The following formats are not defined in the V4L2 specification */ 328/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
312#define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */
313#define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */
314#define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */
315#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */
316#define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */
317
318/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
319#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */ 329#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
320#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */ 330#define V4L2_PIX_FMT_SGBRG8 v4l2_fourcc('G', 'B', 'R', 'G') /* 8 GBGB.. RGRG.. */
321#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */ 331#define V4L2_PIX_FMT_SGRBG8 v4l2_fourcc('G', 'R', 'B', 'G') /* 8 GRGR.. BGBG.. */
322 332#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10bit raw bayer */
323/* 333 /* 10bit raw bayer DPCM compressed to 8 bits */
324 * 10bit raw bayer, expanded to 16 bits
325 * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
326 */
327#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0')
328/* 10bit raw bayer DPCM compressed to 8 bits */
329#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0') 334#define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
335 /*
336 * 10bit raw bayer, expanded to 16 bits
337 * xxxxrrrrrrrrrrxxxxgggggggggg xxxxggggggggggxxxxbbbbbbbbbb...
338 */
330#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */ 339#define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B', 'Y', 'R', '2') /* 16 BGBG.. GRGR.. */
331 340
332/* compressed formats */ 341/* compressed formats */
@@ -350,7 +359,6 @@ struct v4l2_pix_format {
350#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */ 359#define V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer */
351#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */ 360#define V4L2_PIX_FMT_SQ905C v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer */
352#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */ 361#define V4L2_PIX_FMT_PJPG v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */
353#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */
354#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */ 362#define V4L2_PIX_FMT_OV511 v4l2_fourcc('O', '5', '1', '1') /* ov511 JPEG */
355#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */ 363#define V4L2_PIX_FMT_OV518 v4l2_fourcc('O', '5', '1', '8') /* ov518 JPEG */
356 364
@@ -367,6 +375,7 @@ struct v4l2_fmtdesc {
367}; 375};
368 376
369#define V4L2_FMT_FLAG_COMPRESSED 0x0001 377#define V4L2_FMT_FLAG_COMPRESSED 0x0001
378#define V4L2_FMT_FLAG_EMULATED 0x0002
370 379
371#if 1 380#if 1
372 /* Experimental Frame Size and frame rate enumeration */ 381 /* Experimental Frame Size and frame rate enumeration */
@@ -788,11 +797,12 @@ struct v4l2_control {
788 797
789struct v4l2_ext_control { 798struct v4l2_ext_control {
790 __u32 id; 799 __u32 id;
791 __u32 reserved2[2]; 800 __u32 size;
801 __u32 reserved2[1];
792 union { 802 union {
793 __s32 value; 803 __s32 value;
794 __s64 value64; 804 __s64 value64;
795 void *reserved; 805 char *string;
796 }; 806 };
797} __attribute__ ((packed)); 807} __attribute__ ((packed));
798 808
@@ -808,6 +818,7 @@ struct v4l2_ext_controls {
808#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ 818#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
809#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ 819#define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */
810#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */ 820#define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */
821#define V4L2_CTRL_CLASS_FM_TX 0x009b0000 /* FM Modulator control class */
811 822
812#define V4L2_CTRL_ID_MASK (0x0fffffff) 823#define V4L2_CTRL_ID_MASK (0x0fffffff)
813#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) 824#define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL)
@@ -1147,6 +1158,39 @@ enum v4l2_exposure_auto_type {
1147 1158
1148#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16) 1159#define V4L2_CID_PRIVACY (V4L2_CID_CAMERA_CLASS_BASE+16)
1149 1160
1161/* FM Modulator class control IDs */
1162#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
1163#define V4L2_CID_FM_TX_CLASS (V4L2_CTRL_CLASS_FM_TX | 1)
1164
1165#define V4L2_CID_RDS_TX_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 1)
1166#define V4L2_CID_RDS_TX_PI (V4L2_CID_FM_TX_CLASS_BASE + 2)
1167#define V4L2_CID_RDS_TX_PTY (V4L2_CID_FM_TX_CLASS_BASE + 3)
1168#define V4L2_CID_RDS_TX_PS_NAME (V4L2_CID_FM_TX_CLASS_BASE + 5)
1169#define V4L2_CID_RDS_TX_RADIO_TEXT (V4L2_CID_FM_TX_CLASS_BASE + 6)
1170
1171#define V4L2_CID_AUDIO_LIMITER_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 64)
1172#define V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 65)
1173#define V4L2_CID_AUDIO_LIMITER_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 66)
1174
1175#define V4L2_CID_AUDIO_COMPRESSION_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 80)
1176#define V4L2_CID_AUDIO_COMPRESSION_GAIN (V4L2_CID_FM_TX_CLASS_BASE + 81)
1177#define V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (V4L2_CID_FM_TX_CLASS_BASE + 82)
1178#define V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (V4L2_CID_FM_TX_CLASS_BASE + 83)
1179#define V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (V4L2_CID_FM_TX_CLASS_BASE + 84)
1180
1181#define V4L2_CID_PILOT_TONE_ENABLED (V4L2_CID_FM_TX_CLASS_BASE + 96)
1182#define V4L2_CID_PILOT_TONE_DEVIATION (V4L2_CID_FM_TX_CLASS_BASE + 97)
1183#define V4L2_CID_PILOT_TONE_FREQUENCY (V4L2_CID_FM_TX_CLASS_BASE + 98)
1184
1185#define V4L2_CID_TUNE_PREEMPHASIS (V4L2_CID_FM_TX_CLASS_BASE + 112)
1186enum v4l2_preemphasis {
1187 V4L2_PREEMPHASIS_DISABLED = 0,
1188 V4L2_PREEMPHASIS_50_uS = 1,
1189 V4L2_PREEMPHASIS_75_uS = 2,
1190};
1191#define V4L2_CID_TUNE_POWER_LEVEL (V4L2_CID_FM_TX_CLASS_BASE + 113)
1192#define V4L2_CID_TUNE_ANTENNA_CAPACITOR (V4L2_CID_FM_TX_CLASS_BASE + 114)
1193
1150/* 1194/*
1151 * T U N I N G 1195 * T U N I N G
1152 */ 1196 */
@@ -1181,6 +1225,7 @@ struct v4l2_modulator {
1181#define V4L2_TUNER_CAP_LANG2 0x0020 1225#define V4L2_TUNER_CAP_LANG2 0x0020
1182#define V4L2_TUNER_CAP_SAP 0x0020 1226#define V4L2_TUNER_CAP_SAP 0x0020
1183#define V4L2_TUNER_CAP_LANG1 0x0040 1227#define V4L2_TUNER_CAP_LANG1 0x0040
1228#define V4L2_TUNER_CAP_RDS 0x0080
1184 1229
1185/* Flags for the 'rxsubchans' field */ 1230/* Flags for the 'rxsubchans' field */
1186#define V4L2_TUNER_SUB_MONO 0x0001 1231#define V4L2_TUNER_SUB_MONO 0x0001
@@ -1188,6 +1233,7 @@ struct v4l2_modulator {
1188#define V4L2_TUNER_SUB_LANG2 0x0004 1233#define V4L2_TUNER_SUB_LANG2 0x0004
1189#define V4L2_TUNER_SUB_SAP 0x0004 1234#define V4L2_TUNER_SUB_SAP 0x0004
1190#define V4L2_TUNER_SUB_LANG1 0x0008 1235#define V4L2_TUNER_SUB_LANG1 0x0008
1236#define V4L2_TUNER_SUB_RDS 0x0010
1191 1237
1192/* Values for the 'audmode' field */ 1238/* Values for the 'audmode' field */
1193#define V4L2_TUNER_MODE_MONO 0x0000 1239#define V4L2_TUNER_MODE_MONO 0x0000
@@ -1213,6 +1259,27 @@ struct v4l2_hw_freq_seek {
1213}; 1259};
1214 1260
1215/* 1261/*
1262 * R D S
1263 */
1264
1265struct v4l2_rds_data {
1266 __u8 lsb;
1267 __u8 msb;
1268 __u8 block;
1269} __attribute__ ((packed));
1270
1271#define V4L2_RDS_BLOCK_MSK 0x7
1272#define V4L2_RDS_BLOCK_A 0
1273#define V4L2_RDS_BLOCK_B 1
1274#define V4L2_RDS_BLOCK_C 2
1275#define V4L2_RDS_BLOCK_D 3
1276#define V4L2_RDS_BLOCK_C_ALT 4
1277#define V4L2_RDS_BLOCK_INVALID 7
1278
1279#define V4L2_RDS_BLOCK_CORRECTED 0x40
1280#define V4L2_RDS_BLOCK_ERROR 0x80
1281
1282/*
1216 * A U D I O 1283 * A U D I O
1217 */ 1284 */
1218struct v4l2_audio { 1285struct v4l2_audio {
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index a43ebec3a7b9..227c2a585e4f 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -115,4 +115,10 @@ extern rwlock_t vmlist_lock;
115extern struct vm_struct *vmlist; 115extern struct vm_struct *vmlist;
116extern __init void vm_area_register_early(struct vm_struct *vm, size_t align); 116extern __init void vm_area_register_early(struct vm_struct *vm, size_t align);
117 117
118struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
119 const size_t *sizes, int nr_vms,
120 size_t align, gfp_t gfp_mask);
121
122void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms);
123
118#endif /* _LINUX_VMALLOC_H */ 124#endif /* _LINUX_VMALLOC_H */
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index d347632f1861..75cf58666ff9 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -50,7 +50,6 @@ struct writeback_control {
50 unsigned encountered_congestion:1; /* An output: a queue is full */ 50 unsigned encountered_congestion:1; /* An output: a queue is full */
51 unsigned for_kupdate:1; /* A kupdate writeback */ 51 unsigned for_kupdate:1; /* A kupdate writeback */
52 unsigned for_reclaim:1; /* Invoked from the page allocator */ 52 unsigned for_reclaim:1; /* Invoked from the page allocator */
53 unsigned for_writepages:1; /* This is a writepages() call */
54 unsigned range_cyclic:1; /* range_start is cyclic */ 53 unsigned range_cyclic:1; /* range_start is cyclic */
55 unsigned more_io:1; /* more io to be dispatched */ 54 unsigned more_io:1; /* more io to be dispatched */
56 /* 55 /*
@@ -69,8 +68,8 @@ struct writeback_control {
69 */ 68 */
70struct bdi_writeback; 69struct bdi_writeback;
71int inode_wait(void *); 70int inode_wait(void *);
72long writeback_inodes_sb(struct super_block *); 71void writeback_inodes_sb(struct super_block *);
73long sync_inodes_sb(struct super_block *); 72void sync_inodes_sb(struct super_block *);
74void writeback_inodes_wbc(struct writeback_control *wbc); 73void writeback_inodes_wbc(struct writeback_control *wbc);
75long wb_do_writeback(struct bdi_writeback *wb, int force_wait); 74long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
76void wakeup_flusher_threads(long nr_pages); 75void wakeup_flusher_threads(long nr_pages);
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 9dcb632f6083..29f0e53cff94 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -31,8 +31,18 @@
31#define IR_TYPE_PD 2 /* Pulse distance encoded IR */ 31#define IR_TYPE_PD 2 /* Pulse distance encoded IR */
32#define IR_TYPE_OTHER 99 32#define IR_TYPE_OTHER 99
33 33
34#define IR_KEYTAB_TYPE u32 34#define IR_KEYTAB_TYPE u32
35#define IR_KEYTAB_SIZE 128 // enougth for rc5, probably need more some day ... 35#define IR_KEYTAB_SIZE 128 /* enougth for rc5, probably need more some day */
36
37struct ir_scancode {
38 u16 scancode;
39 u32 keycode;
40};
41
42struct ir_scancode_table {
43 struct ir_scancode *scan;
44 int size;
45};
36 46
37#define IR_KEYCODE(tab,code) (((unsigned)code < IR_KEYTAB_SIZE) \ 47#define IR_KEYCODE(tab,code) (((unsigned)code < IR_KEYTAB_SIZE) \
38 ? tab[code] : KEY_RESERVED) 48 ? tab[code] : KEY_RESERVED)
@@ -93,7 +103,7 @@ struct card_ir {
93}; 103};
94 104
95void ir_input_init(struct input_dev *dev, struct ir_input_state *ir, 105void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
96 int ir_type, IR_KEYTAB_TYPE *ir_codes); 106 int ir_type, struct ir_scancode_table *ir_codes);
97void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir); 107void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
98void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir, 108void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
99 u32 ir_key, u32 ir_raw); 109 u32 ir_key, u32 ir_raw);
@@ -107,67 +117,63 @@ void ir_rc5_timer_keyup(unsigned long data);
107 117
108/* Keymaps to be used by other modules */ 118/* Keymaps to be used by other modules */
109 119
110extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE]; 120extern struct ir_scancode_table ir_codes_empty_table;
111extern IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE]; 121extern struct ir_scancode_table ir_codes_avermedia_table;
112extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE]; 122extern struct ir_scancode_table ir_codes_avermedia_dvbt_table;
113extern IR_KEYTAB_TYPE ir_codes_avermedia_m135a[IR_KEYTAB_SIZE]; 123extern struct ir_scancode_table ir_codes_avermedia_m135a_table;
114extern IR_KEYTAB_TYPE ir_codes_avermedia_cardbus[IR_KEYTAB_SIZE]; 124extern struct ir_scancode_table ir_codes_avermedia_cardbus_table;
115extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE]; 125extern struct ir_scancode_table ir_codes_apac_viewcomp_table;
116extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE]; 126extern struct ir_scancode_table ir_codes_pixelview_table;
117extern IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE]; 127extern struct ir_scancode_table ir_codes_pixelview_new_table;
118extern IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE]; 128extern struct ir_scancode_table ir_codes_nebula_table;
119extern IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE]; 129extern struct ir_scancode_table ir_codes_dntv_live_dvb_t_table;
120extern IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE]; 130extern struct ir_scancode_table ir_codes_iodata_bctv7e_table;
121extern IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE]; 131extern struct ir_scancode_table ir_codes_adstech_dvb_t_pci_table;
122extern IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE]; 132extern struct ir_scancode_table ir_codes_msi_tvanywhere_table;
123extern IR_KEYTAB_TYPE ir_codes_cinergy_1400[IR_KEYTAB_SIZE]; 133extern struct ir_scancode_table ir_codes_cinergy_1400_table;
124extern IR_KEYTAB_TYPE ir_codes_avertv_303[IR_KEYTAB_SIZE]; 134extern struct ir_scancode_table ir_codes_avertv_303_table;
125extern IR_KEYTAB_TYPE ir_codes_dntv_live_dvbt_pro[IR_KEYTAB_SIZE]; 135extern struct ir_scancode_table ir_codes_dntv_live_dvbt_pro_table;
126extern IR_KEYTAB_TYPE ir_codes_em_terratec[IR_KEYTAB_SIZE]; 136extern struct ir_scancode_table ir_codes_em_terratec_table;
127extern IR_KEYTAB_TYPE ir_codes_pinnacle_grey[IR_KEYTAB_SIZE]; 137extern struct ir_scancode_table ir_codes_pinnacle_grey_table;
128extern IR_KEYTAB_TYPE ir_codes_flyvideo[IR_KEYTAB_SIZE]; 138extern struct ir_scancode_table ir_codes_flyvideo_table;
129extern IR_KEYTAB_TYPE ir_codes_flydvb[IR_KEYTAB_SIZE]; 139extern struct ir_scancode_table ir_codes_flydvb_table;
130extern IR_KEYTAB_TYPE ir_codes_cinergy[IR_KEYTAB_SIZE]; 140extern struct ir_scancode_table ir_codes_cinergy_table;
131extern IR_KEYTAB_TYPE ir_codes_eztv[IR_KEYTAB_SIZE]; 141extern struct ir_scancode_table ir_codes_eztv_table;
132extern IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE]; 142extern struct ir_scancode_table ir_codes_avermedia_table;
133extern IR_KEYTAB_TYPE ir_codes_videomate_tv_pvr[IR_KEYTAB_SIZE]; 143extern struct ir_scancode_table ir_codes_videomate_tv_pvr_table;
134extern IR_KEYTAB_TYPE ir_codes_manli[IR_KEYTAB_SIZE]; 144extern struct ir_scancode_table ir_codes_manli_table;
135extern IR_KEYTAB_TYPE ir_codes_gotview7135[IR_KEYTAB_SIZE]; 145extern struct ir_scancode_table ir_codes_gotview7135_table;
136extern IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE]; 146extern struct ir_scancode_table ir_codes_purpletv_table;
137extern IR_KEYTAB_TYPE ir_codes_pctv_sedna[IR_KEYTAB_SIZE]; 147extern struct ir_scancode_table ir_codes_pctv_sedna_table;
138extern IR_KEYTAB_TYPE ir_codes_pv951[IR_KEYTAB_SIZE]; 148extern struct ir_scancode_table ir_codes_pv951_table;
139extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE]; 149extern struct ir_scancode_table ir_codes_rc5_tv_table;
140extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE]; 150extern struct ir_scancode_table ir_codes_winfast_table;
141extern IR_KEYTAB_TYPE ir_codes_pinnacle_color[IR_KEYTAB_SIZE]; 151extern struct ir_scancode_table ir_codes_pinnacle_color_table;
142extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE]; 152extern struct ir_scancode_table ir_codes_hauppauge_new_table;
143extern IR_KEYTAB_TYPE ir_codes_npgtech[IR_KEYTAB_SIZE]; 153extern struct ir_scancode_table ir_codes_npgtech_table;
144extern IR_KEYTAB_TYPE ir_codes_norwood[IR_KEYTAB_SIZE]; 154extern struct ir_scancode_table ir_codes_norwood_table;
145extern IR_KEYTAB_TYPE ir_codes_proteus_2309[IR_KEYTAB_SIZE]; 155extern struct ir_scancode_table ir_codes_proteus_2309_table;
146extern IR_KEYTAB_TYPE ir_codes_budget_ci_old[IR_KEYTAB_SIZE]; 156extern struct ir_scancode_table ir_codes_budget_ci_old_table;
147extern IR_KEYTAB_TYPE ir_codes_asus_pc39[IR_KEYTAB_SIZE]; 157extern struct ir_scancode_table ir_codes_asus_pc39_table;
148extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE]; 158extern struct ir_scancode_table ir_codes_encore_enltv_table;
149extern IR_KEYTAB_TYPE ir_codes_encore_enltv2[IR_KEYTAB_SIZE]; 159extern struct ir_scancode_table ir_codes_encore_enltv2_table;
150extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE]; 160extern struct ir_scancode_table ir_codes_tt_1500_table;
151extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE]; 161extern struct ir_scancode_table ir_codes_fusionhdtv_mce_table;
152extern IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE]; 162extern struct ir_scancode_table ir_codes_behold_table;
153extern IR_KEYTAB_TYPE ir_codes_behold_columbus[IR_KEYTAB_SIZE]; 163extern struct ir_scancode_table ir_codes_behold_columbus_table;
154extern IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE]; 164extern struct ir_scancode_table ir_codes_pinnacle_pctv_hd_table;
155extern IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE]; 165extern struct ir_scancode_table ir_codes_genius_tvgo_a11mce_table;
156extern IR_KEYTAB_TYPE ir_codes_powercolor_real_angel[IR_KEYTAB_SIZE]; 166extern struct ir_scancode_table ir_codes_powercolor_real_angel_table;
157extern IR_KEYTAB_TYPE ir_codes_avermedia_a16d[IR_KEYTAB_SIZE]; 167extern struct ir_scancode_table ir_codes_avermedia_a16d_table;
158extern IR_KEYTAB_TYPE ir_codes_encore_enltv_fm53[IR_KEYTAB_SIZE]; 168extern struct ir_scancode_table ir_codes_encore_enltv_fm53_table;
159extern IR_KEYTAB_TYPE ir_codes_real_audio_220_32_keys[IR_KEYTAB_SIZE]; 169extern struct ir_scancode_table ir_codes_real_audio_220_32_keys_table;
160extern IR_KEYTAB_TYPE ir_codes_msi_tvanywhere_plus[IR_KEYTAB_SIZE]; 170extern struct ir_scancode_table ir_codes_msi_tvanywhere_plus_table;
161extern IR_KEYTAB_TYPE ir_codes_ati_tv_wonder_hd_600[IR_KEYTAB_SIZE]; 171extern struct ir_scancode_table ir_codes_ati_tv_wonder_hd_600_table;
162extern IR_KEYTAB_TYPE ir_codes_kworld_plus_tv_analog[IR_KEYTAB_SIZE]; 172extern struct ir_scancode_table ir_codes_kworld_plus_tv_analog_table;
163extern IR_KEYTAB_TYPE ir_codes_kaiomy[IR_KEYTAB_SIZE]; 173extern struct ir_scancode_table ir_codes_kaiomy_table;
164extern IR_KEYTAB_TYPE ir_codes_dm1105_nec[IR_KEYTAB_SIZE]; 174extern struct ir_scancode_table ir_codes_dm1105_nec_table;
165extern IR_KEYTAB_TYPE ir_codes_evga_indtube[IR_KEYTAB_SIZE]; 175extern struct ir_scancode_table ir_codes_evga_indtube_table;
166 176extern struct ir_scancode_table ir_codes_terratec_cinergy_xs_table;
177extern struct ir_scancode_table ir_codes_videomate_s350_table;
178extern struct ir_scancode_table ir_codes_gadmei_rm008z_table;
167#endif 179#endif
168
169/*
170 * Local variables:
171 * c-basic-offset: 8
172 * End:
173 */
diff --git a/include/media/ir-kbd-i2c.h b/include/media/ir-kbd-i2c.h
index 3ad4ed5402fb..aaf65e8b1a40 100644
--- a/include/media/ir-kbd-i2c.h
+++ b/include/media/ir-kbd-i2c.h
@@ -6,7 +6,8 @@
6struct IR_i2c; 6struct IR_i2c;
7 7
8struct IR_i2c { 8struct IR_i2c {
9 IR_KEYTAB_TYPE *ir_codes; 9 struct ir_scancode_table *ir_codes;
10
10 struct i2c_client *c; 11 struct i2c_client *c;
11 struct input_dev *input; 12 struct input_dev *input;
12 struct ir_input_state ir; 13 struct ir_input_state ir;
@@ -20,10 +21,27 @@ struct IR_i2c {
20 int (*get_key)(struct IR_i2c*, u32*, u32*); 21 int (*get_key)(struct IR_i2c*, u32*, u32*);
21}; 22};
22 23
24enum ir_kbd_get_key_fn {
25 IR_KBD_GET_KEY_CUSTOM = 0,
26 IR_KBD_GET_KEY_PIXELVIEW,
27 IR_KBD_GET_KEY_PV951,
28 IR_KBD_GET_KEY_HAUP,
29 IR_KBD_GET_KEY_KNC1,
30 IR_KBD_GET_KEY_FUSIONHDTV,
31 IR_KBD_GET_KEY_HAUP_XVR,
32 IR_KBD_GET_KEY_AVERMEDIA_CARDBUS,
33};
34
23/* Can be passed when instantiating an ir_video i2c device */ 35/* Can be passed when instantiating an ir_video i2c device */
24struct IR_i2c_init_data { 36struct IR_i2c_init_data {
25 IR_KEYTAB_TYPE *ir_codes; 37 struct ir_scancode_table *ir_codes;
26 const char *name; 38 const char *name;
39 int type; /* IR_TYPE_RC5, IR_TYPE_PD, etc */
40 /*
41 * Specify either a function pointer or a value indicating one of
42 * ir_kbd_i2c's internal get_key functions
43 */
27 int (*get_key)(struct IR_i2c*, u32*, u32*); 44 int (*get_key)(struct IR_i2c*, u32*, u32*);
45 enum ir_kbd_get_key_fn internal_get_key_func;
28}; 46};
29#endif 47#endif
diff --git a/include/media/radio-si4713.h b/include/media/radio-si4713.h
new file mode 100644
index 000000000000..f6aae29c7741
--- /dev/null
+++ b/include/media/radio-si4713.h
@@ -0,0 +1,30 @@
1/*
2 * include/media/radio-si4713.h
3 *
4 * Board related data definitions for Si4713 radio transmitter chip.
5 *
6 * Copyright (c) 2009 Nokia Corporation
7 * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 *
13 */
14
15#ifndef RADIO_SI4713_H
16#define RADIO_SI4713_H
17
18#include <linux/i2c.h>
19
20#define SI4713_NAME "radio-si4713"
21
22/*
23 * Platform dependent definition
24 */
25struct radio_si4713_platform_data {
26 int i2c_bus;
27 struct i2c_board_info *subdev_board_info;
28};
29
30#endif /* ifndef RADIO_SI4713_H*/
diff --git a/include/media/si4713.h b/include/media/si4713.h
new file mode 100644
index 000000000000..99850a54ed09
--- /dev/null
+++ b/include/media/si4713.h
@@ -0,0 +1,49 @@
1/*
2 * include/media/si4713.h
3 *
4 * Board related data definitions for Si4713 i2c device driver.
5 *
6 * Copyright (c) 2009 Nokia Corporation
7 * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
8 *
9 * This file is licensed under the terms of the GNU General Public License
10 * version 2. This program is licensed "as is" without any warranty of any
11 * kind, whether express or implied.
12 *
13 */
14
15#ifndef SI4713_H
16#define SI4713_H
17
18/* The SI4713 I2C sensor chip has a fixed slave address of 0xc6 or 0x22. */
19#define SI4713_I2C_ADDR_BUSEN_HIGH 0x63
20#define SI4713_I2C_ADDR_BUSEN_LOW 0x11
21
22/*
23 * Platform dependent definition
24 */
25struct si4713_platform_data {
26 /* Set power state, zero is off, non-zero is on. */
27 int (*set_power)(int power);
28};
29
30/*
31 * Structure to query for Received Noise Level (RNL).
32 */
33struct si4713_rnl {
34 __u32 index; /* modulator index */
35 __u32 frequency; /* frequency to peform rnl measurement */
36 __s32 rnl; /* result of measurement in dBuV */
37 __u32 reserved[4]; /* drivers and apps must init this to 0 */
38};
39
40/*
41 * This is the ioctl number to query for rnl. Users must pass a
42 * struct si4713_rnl pointer specifying desired frequency in 'frequency' field
43 * following driver capabilities (i.e V4L2_TUNER_CAP_LOW).
44 * Driver must return measured value in the same struture, filling 'rnl' field.
45 */
46#define SI4713_IOC_MEASURE_RNL _IOWR('V', BASE_VIDIOC_PRIVATE + 0, \
47 struct si4713_rnl)
48
49#endif /* ifndef SI4713_H*/
diff --git a/include/media/tuner.h b/include/media/tuner.h
index cbf97f45fbec..c146f2f530b0 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -126,6 +126,7 @@
126#define TUNER_PHILIPS_FMD1216MEX_MK3 78 126#define TUNER_PHILIPS_FMD1216MEX_MK3 78
127#define TUNER_PHILIPS_FM1216MK5 79 127#define TUNER_PHILIPS_FM1216MK5 79
128#define TUNER_PHILIPS_FQ1216LME_MK3 80 /* Active loopthrough, no FM */ 128#define TUNER_PHILIPS_FQ1216LME_MK3 80 /* Active loopthrough, no FM */
129#define TUNER_PARTSNIC_PTI_5NF05 81
129 130
130/* tv card specific */ 131/* tv card specific */
131#define TDA9887_PRESENT (1<<0) 132#define TDA9887_PRESENT (1<<0)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 5dcb36785529..d411345f244b 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -137,6 +137,8 @@ struct v4l2_subdev_tuner_ops {
137 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); 137 int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
138 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); 138 int (*g_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
139 int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt); 139 int (*s_tuner)(struct v4l2_subdev *sd, struct v4l2_tuner *vt);
140 int (*g_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
141 int (*s_modulator)(struct v4l2_subdev *sd, struct v4l2_modulator *vm);
140 int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type); 142 int (*s_type_addr)(struct v4l2_subdev *sd, struct tuner_setup *type);
141 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config); 143 int (*s_config)(struct v4l2_subdev *sd, const struct v4l2_priv_tun_config *config);
142 int (*s_standby)(struct v4l2_subdev *sd); 144 int (*s_standby)(struct v4l2_subdev *sd);
@@ -220,6 +222,9 @@ struct v4l2_subdev_video_ops {
220 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt); 222 int (*g_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
221 int (*try_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt); 223 int (*try_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
222 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt); 224 int (*s_fmt)(struct v4l2_subdev *sd, struct v4l2_format *fmt);
225 int (*cropcap)(struct v4l2_subdev *sd, struct v4l2_cropcap *cc);
226 int (*g_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
227 int (*s_crop)(struct v4l2_subdev *sd, struct v4l2_crop *crop);
223 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 228 int (*g_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
224 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param); 229 int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
225 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize); 230 int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 7d8b5bc74185..8d433c4e3709 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -227,7 +227,6 @@ TRACE_EVENT(ext4_da_writepages,
227 __field( char, nonblocking ) 227 __field( char, nonblocking )
228 __field( char, for_kupdate ) 228 __field( char, for_kupdate )
229 __field( char, for_reclaim ) 229 __field( char, for_reclaim )
230 __field( char, for_writepages )
231 __field( char, range_cyclic ) 230 __field( char, range_cyclic )
232 ), 231 ),
233 232
@@ -241,16 +240,15 @@ TRACE_EVENT(ext4_da_writepages,
241 __entry->nonblocking = wbc->nonblocking; 240 __entry->nonblocking = wbc->nonblocking;
242 __entry->for_kupdate = wbc->for_kupdate; 241 __entry->for_kupdate = wbc->for_kupdate;
243 __entry->for_reclaim = wbc->for_reclaim; 242 __entry->for_reclaim = wbc->for_reclaim;
244 __entry->for_writepages = wbc->for_writepages;
245 __entry->range_cyclic = wbc->range_cyclic; 243 __entry->range_cyclic = wbc->range_cyclic;
246 ), 244 ),
247 245
248 TP_printk("dev %s ino %lu nr_t_write %ld pages_skipped %ld range_start %llu range_end %llu nonblocking %d for_kupdate %d for_reclaim %d for_writepages %d range_cyclic %d", 246 TP_printk("dev %s ino %lu nr_t_write %ld pages_skipped %ld range_start %llu range_end %llu nonblocking %d for_kupdate %d for_reclaim %d range_cyclic %d",
249 jbd2_dev_to_name(__entry->dev), __entry->ino, __entry->nr_to_write, 247 jbd2_dev_to_name(__entry->dev), __entry->ino, __entry->nr_to_write,
250 __entry->pages_skipped, __entry->range_start, 248 __entry->pages_skipped, __entry->range_start,
251 __entry->range_end, __entry->nonblocking, 249 __entry->range_end, __entry->nonblocking,
252 __entry->for_kupdate, __entry->for_reclaim, 250 __entry->for_kupdate, __entry->for_reclaim,
253 __entry->for_writepages, __entry->range_cyclic) 251 __entry->range_cyclic)
254); 252);
255 253
256TRACE_EVENT(ext4_da_writepages_result, 254TRACE_EVENT(ext4_da_writepages_result,
diff --git a/init/main.c b/init/main.c
index b34fd8e5edef..63904bb6ae37 100644
--- a/init/main.c
+++ b/init/main.c
@@ -353,7 +353,6 @@ static void __init smp_init(void)
353#define smp_init() do { } while (0) 353#define smp_init() do { } while (0)
354#endif 354#endif
355 355
356static inline void setup_per_cpu_areas(void) { }
357static inline void setup_nr_cpu_ids(void) { } 356static inline void setup_nr_cpu_ids(void) { }
358static inline void smp_prepare_cpus(unsigned int maxcpus) { } 357static inline void smp_prepare_cpus(unsigned int maxcpus) { }
359 358
@@ -374,29 +373,6 @@ static void __init setup_nr_cpu_ids(void)
374 nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1; 373 nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
375} 374}
376 375
377#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
378unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
379
380EXPORT_SYMBOL(__per_cpu_offset);
381
382static void __init setup_per_cpu_areas(void)
383{
384 unsigned long size, i;
385 char *ptr;
386 unsigned long nr_possible_cpus = num_possible_cpus();
387
388 /* Copy section for each CPU (we discard the original) */
389 size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
390 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
391
392 for_each_possible_cpu(i) {
393 __per_cpu_offset[i] = ptr - __per_cpu_start;
394 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
395 ptr += size;
396 }
397}
398#endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */
399
400/* Called by boot processor to activate the rest. */ 376/* Called by boot processor to activate the rest. */
401static void __init smp_init(void) 377static void __init smp_init(void)
402{ 378{
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 8ce10043e4ac..6ba0f1ecb212 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -401,6 +401,7 @@ int disable_nonboot_cpus(void)
401 break; 401 break;
402 } 402 }
403 } 403 }
404
404 if (!error) { 405 if (!error) {
405 BUG_ON(num_online_cpus() > 1); 406 BUG_ON(num_online_cpus() > 1);
406 /* Make sure the CPUs won't be enabled by someone else */ 407 /* Make sure the CPUs won't be enabled by someone else */
@@ -413,6 +414,14 @@ int disable_nonboot_cpus(void)
413 return error; 414 return error;
414} 415}
415 416
417void __weak arch_enable_nonboot_cpus_begin(void)
418{
419}
420
421void __weak arch_enable_nonboot_cpus_end(void)
422{
423}
424
416void __ref enable_nonboot_cpus(void) 425void __ref enable_nonboot_cpus(void)
417{ 426{
418 int cpu, error; 427 int cpu, error;
@@ -424,6 +433,9 @@ void __ref enable_nonboot_cpus(void)
424 goto out; 433 goto out;
425 434
426 printk("Enabling non-boot CPUs ...\n"); 435 printk("Enabling non-boot CPUs ...\n");
436
437 arch_enable_nonboot_cpus_begin();
438
427 for_each_cpu(cpu, frozen_cpus) { 439 for_each_cpu(cpu, frozen_cpus) {
428 error = _cpu_up(cpu, 1); 440 error = _cpu_up(cpu, 1);
429 if (!error) { 441 if (!error) {
@@ -432,6 +444,9 @@ void __ref enable_nonboot_cpus(void)
432 } 444 }
433 printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error); 445 printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error);
434 } 446 }
447
448 arch_enable_nonboot_cpus_end();
449
435 cpumask_clear(frozen_cpus); 450 cpumask_clear(frozen_cpus);
436out: 451out:
437 cpu_maps_update_done(); 452 cpu_maps_update_done();
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index 22e9dcfaa3d3..654efd09f6a9 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -34,7 +34,7 @@ config GCOV_KERNEL
34config GCOV_PROFILE_ALL 34config GCOV_PROFILE_ALL
35 bool "Profile entire Kernel" 35 bool "Profile entire Kernel"
36 depends on GCOV_KERNEL 36 depends on GCOV_KERNEL
37 depends on S390 || X86 37 depends on S390 || X86 || (PPC && EXPERIMENTAL)
38 default n 38 default n
39 ---help--- 39 ---help---
40 This options activates profiling for the entire kernel. 40 This options activates profiling for the entire kernel.
diff --git a/kernel/module.c b/kernel/module.c
index 46580edff0cb..05ce49ced8f6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -369,7 +369,7 @@ EXPORT_SYMBOL_GPL(find_module);
369 369
370#ifdef CONFIG_SMP 370#ifdef CONFIG_SMP
371 371
372#ifdef CONFIG_HAVE_DYNAMIC_PER_CPU_AREA 372#ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA
373 373
374static void *percpu_modalloc(unsigned long size, unsigned long align, 374static void *percpu_modalloc(unsigned long size, unsigned long align,
375 const char *name) 375 const char *name)
@@ -394,7 +394,7 @@ static void percpu_modfree(void *freeme)
394 free_percpu(freeme); 394 free_percpu(freeme);
395} 395}
396 396
397#else /* ... !CONFIG_HAVE_DYNAMIC_PER_CPU_AREA */ 397#else /* ... CONFIG_HAVE_LEGACY_PER_CPU_AREA */
398 398
399/* Number of blocks used and allocated. */ 399/* Number of blocks used and allocated. */
400static unsigned int pcpu_num_used, pcpu_num_allocated; 400static unsigned int pcpu_num_used, pcpu_num_allocated;
@@ -540,7 +540,7 @@ static int percpu_modinit(void)
540} 540}
541__initcall(percpu_modinit); 541__initcall(percpu_modinit);
542 542
543#endif /* CONFIG_HAVE_DYNAMIC_PER_CPU_AREA */ 543#endif /* CONFIG_HAVE_LEGACY_PER_CPU_AREA */
544 544
545static unsigned int find_pcpusec(Elf_Ehdr *hdr, 545static unsigned int find_pcpusec(Elf_Ehdr *hdr,
546 Elf_Shdr *sechdrs, 546 Elf_Shdr *sechdrs,
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index e0d91fdf0c3c..8cb94a52d1bb 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -106,16 +106,16 @@ hw_perf_group_sched_in(struct perf_counter *group_leader,
106 106
107void __weak perf_counter_print_debug(void) { } 107void __weak perf_counter_print_debug(void) { }
108 108
109static DEFINE_PER_CPU(int, disable_count); 109static DEFINE_PER_CPU(int, perf_disable_count);
110 110
111void __perf_disable(void) 111void __perf_disable(void)
112{ 112{
113 __get_cpu_var(disable_count)++; 113 __get_cpu_var(perf_disable_count)++;
114} 114}
115 115
116bool __perf_enable(void) 116bool __perf_enable(void)
117{ 117{
118 return !--__get_cpu_var(disable_count); 118 return !--__get_cpu_var(perf_disable_count);
119} 119}
120 120
121void perf_disable(void) 121void perf_disable(void)
@@ -4215,6 +4215,7 @@ static int perf_copy_attr(struct perf_counter_attr __user *uattr,
4215 if (val) 4215 if (val)
4216 goto err_size; 4216 goto err_size;
4217 } 4217 }
4218 size = sizeof(*attr);
4218 } 4219 }
4219 4220
4220 ret = copy_from_user(attr, uattr, size); 4221 ret = copy_from_user(attr, uattr, size);
diff --git a/kernel/sched.c b/kernel/sched.c
index e27a53685ed9..d9db3fb17573 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -295,12 +295,12 @@ struct task_group root_task_group;
295/* Default task group's sched entity on each cpu */ 295/* Default task group's sched entity on each cpu */
296static DEFINE_PER_CPU(struct sched_entity, init_sched_entity); 296static DEFINE_PER_CPU(struct sched_entity, init_sched_entity);
297/* Default task group's cfs_rq on each cpu */ 297/* Default task group's cfs_rq on each cpu */
298static DEFINE_PER_CPU(struct cfs_rq, init_tg_cfs_rq) ____cacheline_aligned_in_smp; 298static DEFINE_PER_CPU_SHARED_ALIGNED(struct cfs_rq, init_tg_cfs_rq);
299#endif /* CONFIG_FAIR_GROUP_SCHED */ 299#endif /* CONFIG_FAIR_GROUP_SCHED */
300 300
301#ifdef CONFIG_RT_GROUP_SCHED 301#ifdef CONFIG_RT_GROUP_SCHED
302static DEFINE_PER_CPU(struct sched_rt_entity, init_sched_rt_entity); 302static DEFINE_PER_CPU(struct sched_rt_entity, init_sched_rt_entity);
303static DEFINE_PER_CPU(struct rt_rq, init_rt_rq) ____cacheline_aligned_in_smp; 303static DEFINE_PER_CPU_SHARED_ALIGNED(struct rt_rq, init_rt_rq);
304#endif /* CONFIG_RT_GROUP_SCHED */ 304#endif /* CONFIG_RT_GROUP_SCHED */
305#else /* !CONFIG_USER_SCHED */ 305#else /* !CONFIG_USER_SCHED */
306#define root_task_group init_task_group 306#define root_task_group init_task_group
diff --git a/kernel/smp.c b/kernel/smp.c
index 94188b8ecc33..8e218500ab14 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -177,6 +177,11 @@ void generic_smp_call_function_interrupt(void)
177 int cpu = get_cpu(); 177 int cpu = get_cpu();
178 178
179 /* 179 /*
180 * Shouldn't receive this interrupt on a cpu that is not yet online.
181 */
182 WARN_ON_ONCE(!cpu_online(cpu));
183
184 /*
180 * Ensure entry is visible on call_function_queue after we have 185 * Ensure entry is visible on call_function_queue after we have
181 * entered the IPI. See comment in smp_call_function_many. 186 * entered the IPI. See comment in smp_call_function_many.
182 * If we don't have this, then we may miss an entry on the list 187 * If we don't have this, then we may miss an entry on the list
@@ -230,6 +235,11 @@ void generic_smp_call_function_single_interrupt(void)
230 unsigned int data_flags; 235 unsigned int data_flags;
231 LIST_HEAD(list); 236 LIST_HEAD(list);
232 237
238 /*
239 * Shouldn't receive this interrupt on a cpu that is not yet online.
240 */
241 WARN_ON_ONCE(!cpu_online(smp_processor_id()));
242
233 spin_lock(&q->lock); 243 spin_lock(&q->lock);
234 list_replace_init(&q->list, &list); 244 list_replace_init(&q->list, &list);
235 spin_unlock(&q->lock); 245 spin_unlock(&q->lock);
@@ -285,8 +295,14 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
285 */ 295 */
286 this_cpu = get_cpu(); 296 this_cpu = get_cpu();
287 297
288 /* Can deadlock when called with interrupts disabled */ 298 /*
289 WARN_ON_ONCE(irqs_disabled() && !oops_in_progress); 299 * Can deadlock when called with interrupts disabled.
300 * We allow cpu's that are not yet online though, as no one else can
301 * send smp call function interrupt to this cpu and as such deadlocks
302 * can't happen.
303 */
304 WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
305 && !oops_in_progress);
290 306
291 if (cpu == this_cpu) { 307 if (cpu == this_cpu) {
292 local_irq_save(flags); 308 local_irq_save(flags);
@@ -329,8 +345,14 @@ void __smp_call_function_single(int cpu, struct call_single_data *data,
329{ 345{
330 csd_lock(data); 346 csd_lock(data);
331 347
332 /* Can deadlock when called with interrupts disabled */ 348 /*
333 WARN_ON_ONCE(wait && irqs_disabled() && !oops_in_progress); 349 * Can deadlock when called with interrupts disabled.
350 * We allow cpu's that are not yet online though, as no one else can
351 * send smp call function interrupt to this cpu and as such deadlocks
352 * can't happen.
353 */
354 WARN_ON_ONCE(cpu_online(smp_processor_id()) && wait && irqs_disabled()
355 && !oops_in_progress);
334 356
335 generic_exec_single(cpu, data, wait); 357 generic_exec_single(cpu, data, wait);
336} 358}
@@ -365,8 +387,14 @@ void smp_call_function_many(const struct cpumask *mask,
365 unsigned long flags; 387 unsigned long flags;
366 int cpu, next_cpu, this_cpu = smp_processor_id(); 388 int cpu, next_cpu, this_cpu = smp_processor_id();
367 389
368 /* Can deadlock when called with interrupts disabled */ 390 /*
369 WARN_ON_ONCE(irqs_disabled() && !oops_in_progress); 391 * Can deadlock when called with interrupts disabled.
392 * We allow cpu's that are not yet online though, as no one else can
393 * send smp call function interrupt to this cpu and as such deadlocks
394 * can't happen.
395 */
396 WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
397 && !oops_in_progress);
370 398
371 /* So, what's a CPU they want? Ignoring this one. */ 399 /* So, what's a CPU they want? Ignoring this one. */
372 cpu = cpumask_first_and(mask, cpu_online_mask); 400 cpu = cpumask_first_and(mask, cpu_online_mask);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6bb59f707402..1a631ba684a4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -91,7 +91,9 @@ extern int sysctl_nr_trim_pages;
91#ifdef CONFIG_RCU_TORTURE_TEST 91#ifdef CONFIG_RCU_TORTURE_TEST
92extern int rcutorture_runnable; 92extern int rcutorture_runnable;
93#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */ 93#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
94#ifdef CONFIG_BLOCK
94extern int blk_iopoll_enabled; 95extern int blk_iopoll_enabled;
96#endif
95 97
96/* Constants used for minimum and maximum */ 98/* Constants used for minimum and maximum */
97#ifdef CONFIG_DETECT_SOFTLOCKUP 99#ifdef CONFIG_DETECT_SOFTLOCKUP
@@ -998,6 +1000,7 @@ static struct ctl_table kern_table[] = {
998 .proc_handler = &proc_dointvec, 1000 .proc_handler = &proc_dointvec,
999 }, 1001 },
1000#endif 1002#endif
1003#ifdef CONFIG_BLOCK
1001 { 1004 {
1002 .ctl_name = CTL_UNNUMBERED, 1005 .ctl_name = CTL_UNNUMBERED,
1003 .procname = "blk_iopoll", 1006 .procname = "blk_iopoll",
@@ -1006,6 +1009,7 @@ static struct ctl_table kern_table[] = {
1006 .mode = 0644, 1009 .mode = 0644,
1007 .proc_handler = &proc_dointvec, 1010 .proc_handler = &proc_dointvec,
1008 }, 1011 },
1012#endif
1009/* 1013/*
1010 * NOTE: do not add new entries to this table unless you have read 1014 * NOTE: do not add new entries to this table unless you have read
1011 * Documentation/sysctl/ctl_unnumbered.txt 1015 * Documentation/sysctl/ctl_unnumbered.txt
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 78b1ed230177..97e2c4d2e9eb 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1432,7 +1432,7 @@ static __init void event_trace_self_tests(void)
1432 1432
1433#ifdef CONFIG_FUNCTION_TRACER 1433#ifdef CONFIG_FUNCTION_TRACER
1434 1434
1435static DEFINE_PER_CPU(atomic_t, test_event_disable); 1435static DEFINE_PER_CPU(atomic_t, ftrace_test_event_disable);
1436 1436
1437static void 1437static void
1438function_test_events_call(unsigned long ip, unsigned long parent_ip) 1438function_test_events_call(unsigned long ip, unsigned long parent_ip)
@@ -1449,7 +1449,7 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip)
1449 pc = preempt_count(); 1449 pc = preempt_count();
1450 resched = ftrace_preempt_disable(); 1450 resched = ftrace_preempt_disable();
1451 cpu = raw_smp_processor_id(); 1451 cpu = raw_smp_processor_id();
1452 disabled = atomic_inc_return(&per_cpu(test_event_disable, cpu)); 1452 disabled = atomic_inc_return(&per_cpu(ftrace_test_event_disable, cpu));
1453 1453
1454 if (disabled != 1) 1454 if (disabled != 1)
1455 goto out; 1455 goto out;
@@ -1468,7 +1468,7 @@ function_test_events_call(unsigned long ip, unsigned long parent_ip)
1468 trace_nowake_buffer_unlock_commit(buffer, event, flags, pc); 1468 trace_nowake_buffer_unlock_commit(buffer, event, flags, pc);
1469 1469
1470 out: 1470 out:
1471 atomic_dec(&per_cpu(test_event_disable, cpu)); 1471 atomic_dec(&per_cpu(ftrace_test_event_disable, cpu));
1472 ftrace_preempt_enable(resched); 1472 ftrace_preempt_enable(resched);
1473} 1473}
1474 1474
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 7dbd5d9c29a4..d57b12f59c8c 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -338,7 +338,7 @@ config SLUB_STATS
338 338
339config DEBUG_KMEMLEAK 339config DEBUG_KMEMLEAK
340 bool "Kernel memory leak detector" 340 bool "Kernel memory leak detector"
341 depends on DEBUG_KERNEL && EXPERIMENTAL && (X86 || ARM) && \ 341 depends on DEBUG_KERNEL && EXPERIMENTAL && (X86 || ARM || PPC) && \
342 !MEMORY_HOTPLUG 342 !MEMORY_HOTPLUG
343 select DEBUG_FS if SYSFS 343 select DEBUG_FS if SYSFS
344 select STACKTRACE if STACKTRACE_SUPPORT 344 select STACKTRACE if STACKTRACE_SUPPORT
@@ -805,6 +805,21 @@ config DEBUG_BLOCK_EXT_DEVT
805 805
806 Say N if you are unsure. 806 Say N if you are unsure.
807 807
808config DEBUG_FORCE_WEAK_PER_CPU
809 bool "Force weak per-cpu definitions"
810 depends on DEBUG_KERNEL
811 help
812 s390 and alpha require percpu variables in modules to be
813 defined weak to work around addressing range issue which
814 puts the following two restrictions on percpu variable
815 definitions.
816
817 1. percpu symbols must be unique whether static or not
818 2. percpu variables can't be defined inside a function
819
820 To ensure that generic code follows the above rules, this
821 option forces all percpu variables to be defined as weak.
822
808config LKDTM 823config LKDTM
809 tristate "Linux Kernel Dump Test Tool Module" 824 tristate "Linux Kernel Dump Test Tool Module"
810 depends on DEBUG_KERNEL 825 depends on DEBUG_KERNEL
diff --git a/lib/inflate.c b/lib/inflate.c
index 1a8e8a978128..d10255973a9f 100644
--- a/lib/inflate.c
+++ b/lib/inflate.c
@@ -7,7 +7,7 @@
7 * Adapted for booting Linux by Hannu Savolainen 1993 7 * Adapted for booting Linux by Hannu Savolainen 1993
8 * based on gzip-1.0.3 8 * based on gzip-1.0.3
9 * 9 *
10 * Nicolas Pitre <nico@cam.org>, 1999/04/14 : 10 * Nicolas Pitre <nico@fluxnic.net>, 1999/04/14 :
11 * Little mods for all variable to reside either into rodata or bss segments 11 * Little mods for all variable to reside either into rodata or bss segments
12 * by marking constant variables with 'const' and initializing all the others 12 * by marking constant variables with 'const' and initializing all the others
13 * at run-time only. This allows for the kernel uncompressor to run 13 * at run-time only. This allows for the kernel uncompressor to run
diff --git a/mm/Kconfig b/mm/Kconfig
index fe5f674d7a7d..3aa519f52e18 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -153,7 +153,7 @@ config MEMORY_HOTREMOVE
153# 153#
154config PAGEFLAGS_EXTENDED 154config PAGEFLAGS_EXTENDED
155 def_bool y 155 def_bool y
156 depends on 64BIT || SPARSEMEM_VMEMMAP || !NUMA || !SPARSEMEM 156 depends on 64BIT || SPARSEMEM_VMEMMAP || !SPARSEMEM
157 157
158# Heavily threaded applications may benefit from splitting the mm-wide 158# Heavily threaded applications may benefit from splitting the mm-wide
159# page_table_lock, so that faults on different parts of the user address 159# page_table_lock, so that faults on different parts of the user address
diff --git a/mm/Makefile b/mm/Makefile
index 147a7a7873c4..ea4b18bd3960 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -33,7 +33,7 @@ obj-$(CONFIG_FAILSLAB) += failslab.o
33obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o 33obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
34obj-$(CONFIG_FS_XIP) += filemap_xip.o 34obj-$(CONFIG_FS_XIP) += filemap_xip.o
35obj-$(CONFIG_MIGRATION) += migrate.o 35obj-$(CONFIG_MIGRATION) += migrate.o
36ifdef CONFIG_HAVE_DYNAMIC_PER_CPU_AREA 36ifndef CONFIG_HAVE_LEGACY_PER_CPU_AREA
37obj-$(CONFIG_SMP) += percpu.o 37obj-$(CONFIG_SMP) += percpu.o
38else 38else
39obj-$(CONFIG_SMP) += allocpercpu.o 39obj-$(CONFIG_SMP) += allocpercpu.o
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c
index dfdee6a47359..df34ceae0c67 100644
--- a/mm/allocpercpu.c
+++ b/mm/allocpercpu.c
@@ -5,6 +5,8 @@
5 */ 5 */
6#include <linux/mm.h> 6#include <linux/mm.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/bootmem.h>
9#include <asm/sections.h>
8 10
9#ifndef cache_line_size 11#ifndef cache_line_size
10#define cache_line_size() L1_CACHE_BYTES 12#define cache_line_size() L1_CACHE_BYTES
@@ -147,3 +149,29 @@ void free_percpu(void *__pdata)
147 kfree(__percpu_disguise(__pdata)); 149 kfree(__percpu_disguise(__pdata));
148} 150}
149EXPORT_SYMBOL_GPL(free_percpu); 151EXPORT_SYMBOL_GPL(free_percpu);
152
153/*
154 * Generic percpu area setup.
155 */
156#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
157unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
158
159EXPORT_SYMBOL(__per_cpu_offset);
160
161void __init setup_per_cpu_areas(void)
162{
163 unsigned long size, i;
164 char *ptr;
165 unsigned long nr_possible_cpus = num_possible_cpus();
166
167 /* Copy section for each CPU (we discard the original) */
168 size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
169 ptr = alloc_bootmem_pages(size * nr_possible_cpus);
170
171 for_each_possible_cpu(i) {
172 __per_cpu_offset[i] = ptr - __per_cpu_start;
173 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
174 ptr += size;
175 }
176}
177#endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index d3ca0dac1111..3d3accb1f800 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -26,6 +26,12 @@ struct backing_dev_info default_backing_dev_info = {
26EXPORT_SYMBOL_GPL(default_backing_dev_info); 26EXPORT_SYMBOL_GPL(default_backing_dev_info);
27 27
28static struct class *bdi_class; 28static struct class *bdi_class;
29
30/*
31 * bdi_lock protects updates to bdi_list and bdi_pending_list, as well as
32 * reader side protection for bdi_pending_list. bdi_list has RCU reader side
33 * locking.
34 */
29DEFINE_SPINLOCK(bdi_lock); 35DEFINE_SPINLOCK(bdi_lock);
30LIST_HEAD(bdi_list); 36LIST_HEAD(bdi_list);
31LIST_HEAD(bdi_pending_list); 37LIST_HEAD(bdi_pending_list);
@@ -284,9 +290,9 @@ static int bdi_start_fn(void *ptr)
284 /* 290 /*
285 * Add us to the active bdi_list 291 * Add us to the active bdi_list
286 */ 292 */
287 spin_lock(&bdi_lock); 293 spin_lock_bh(&bdi_lock);
288 list_add(&bdi->bdi_list, &bdi_list); 294 list_add_rcu(&bdi->bdi_list, &bdi_list);
289 spin_unlock(&bdi_lock); 295 spin_unlock_bh(&bdi_lock);
290 296
291 bdi_task_init(bdi, wb); 297 bdi_task_init(bdi, wb);
292 298
@@ -389,7 +395,7 @@ static int bdi_forker_task(void *ptr)
389 if (wb_has_dirty_io(me) || !list_empty(&me->bdi->work_list)) 395 if (wb_has_dirty_io(me) || !list_empty(&me->bdi->work_list))
390 wb_do_writeback(me, 0); 396 wb_do_writeback(me, 0);
391 397
392 spin_lock(&bdi_lock); 398 spin_lock_bh(&bdi_lock);
393 399
394 /* 400 /*
395 * Check if any existing bdi's have dirty data without 401 * Check if any existing bdi's have dirty data without
@@ -410,7 +416,7 @@ static int bdi_forker_task(void *ptr)
410 if (list_empty(&bdi_pending_list)) { 416 if (list_empty(&bdi_pending_list)) {
411 unsigned long wait; 417 unsigned long wait;
412 418
413 spin_unlock(&bdi_lock); 419 spin_unlock_bh(&bdi_lock);
414 wait = msecs_to_jiffies(dirty_writeback_interval * 10); 420 wait = msecs_to_jiffies(dirty_writeback_interval * 10);
415 schedule_timeout(wait); 421 schedule_timeout(wait);
416 try_to_freeze(); 422 try_to_freeze();
@@ -426,7 +432,7 @@ static int bdi_forker_task(void *ptr)
426 bdi = list_entry(bdi_pending_list.next, struct backing_dev_info, 432 bdi = list_entry(bdi_pending_list.next, struct backing_dev_info,
427 bdi_list); 433 bdi_list);
428 list_del_init(&bdi->bdi_list); 434 list_del_init(&bdi->bdi_list);
429 spin_unlock(&bdi_lock); 435 spin_unlock_bh(&bdi_lock);
430 436
431 wb = &bdi->wb; 437 wb = &bdi->wb;
432 wb->task = kthread_run(bdi_start_fn, wb, "flush-%s", 438 wb->task = kthread_run(bdi_start_fn, wb, "flush-%s",
@@ -445,9 +451,9 @@ static int bdi_forker_task(void *ptr)
445 * a chance to flush other bdi's to free 451 * a chance to flush other bdi's to free
446 * memory. 452 * memory.
447 */ 453 */
448 spin_lock(&bdi_lock); 454 spin_lock_bh(&bdi_lock);
449 list_add_tail(&bdi->bdi_list, &bdi_pending_list); 455 list_add_tail(&bdi->bdi_list, &bdi_pending_list);
450 spin_unlock(&bdi_lock); 456 spin_unlock_bh(&bdi_lock);
451 457
452 bdi_flush_io(bdi); 458 bdi_flush_io(bdi);
453 } 459 }
@@ -456,6 +462,24 @@ static int bdi_forker_task(void *ptr)
456 return 0; 462 return 0;
457} 463}
458 464
465static void bdi_add_to_pending(struct rcu_head *head)
466{
467 struct backing_dev_info *bdi;
468
469 bdi = container_of(head, struct backing_dev_info, rcu_head);
470 INIT_LIST_HEAD(&bdi->bdi_list);
471
472 spin_lock(&bdi_lock);
473 list_add_tail(&bdi->bdi_list, &bdi_pending_list);
474 spin_unlock(&bdi_lock);
475
476 /*
477 * We are now on the pending list, wake up bdi_forker_task()
478 * to finish the job and add us back to the active bdi_list
479 */
480 wake_up_process(default_backing_dev_info.wb.task);
481}
482
459/* 483/*
460 * Add the default flusher task that gets created for any bdi 484 * Add the default flusher task that gets created for any bdi
461 * that has dirty data pending writeout 485 * that has dirty data pending writeout
@@ -478,16 +502,29 @@ void static bdi_add_default_flusher_task(struct backing_dev_info *bdi)
478 * waiting for previous additions to finish. 502 * waiting for previous additions to finish.
479 */ 503 */
480 if (!test_and_set_bit(BDI_pending, &bdi->state)) { 504 if (!test_and_set_bit(BDI_pending, &bdi->state)) {
481 list_move_tail(&bdi->bdi_list, &bdi_pending_list); 505 list_del_rcu(&bdi->bdi_list);
482 506
483 /* 507 /*
484 * We are now on the pending list, wake up bdi_forker_task() 508 * We must wait for the current RCU period to end before
485 * to finish the job and add us back to the active bdi_list 509 * moving to the pending list. So schedule that operation
510 * from an RCU callback.
486 */ 511 */
487 wake_up_process(default_backing_dev_info.wb.task); 512 call_rcu(&bdi->rcu_head, bdi_add_to_pending);
488 } 513 }
489} 514}
490 515
516/*
517 * Remove bdi from bdi_list, and ensure that it is no longer visible
518 */
519static void bdi_remove_from_list(struct backing_dev_info *bdi)
520{
521 spin_lock_bh(&bdi_lock);
522 list_del_rcu(&bdi->bdi_list);
523 spin_unlock_bh(&bdi_lock);
524
525 synchronize_rcu();
526}
527
491int bdi_register(struct backing_dev_info *bdi, struct device *parent, 528int bdi_register(struct backing_dev_info *bdi, struct device *parent,
492 const char *fmt, ...) 529 const char *fmt, ...)
493{ 530{
@@ -506,9 +543,9 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
506 goto exit; 543 goto exit;
507 } 544 }
508 545
509 spin_lock(&bdi_lock); 546 spin_lock_bh(&bdi_lock);
510 list_add_tail(&bdi->bdi_list, &bdi_list); 547 list_add_tail_rcu(&bdi->bdi_list, &bdi_list);
511 spin_unlock(&bdi_lock); 548 spin_unlock_bh(&bdi_lock);
512 549
513 bdi->dev = dev; 550 bdi->dev = dev;
514 551
@@ -526,9 +563,7 @@ int bdi_register(struct backing_dev_info *bdi, struct device *parent,
526 wb->task = NULL; 563 wb->task = NULL;
527 ret = -ENOMEM; 564 ret = -ENOMEM;
528 565
529 spin_lock(&bdi_lock); 566 bdi_remove_from_list(bdi);
530 list_del(&bdi->bdi_list);
531 spin_unlock(&bdi_lock);
532 goto exit; 567 goto exit;
533 } 568 }
534 } 569 }
@@ -565,9 +600,7 @@ static void bdi_wb_shutdown(struct backing_dev_info *bdi)
565 /* 600 /*
566 * Make sure nobody finds us on the bdi_list anymore 601 * Make sure nobody finds us on the bdi_list anymore
567 */ 602 */
568 spin_lock(&bdi_lock); 603 bdi_remove_from_list(bdi);
569 list_del(&bdi->bdi_list);
570 spin_unlock(&bdi_lock);
571 604
572 /* 605 /*
573 * Finally, kill the kernel threads. We don't need to be RCU 606 * Finally, kill the kernel threads. We don't need to be RCU
@@ -599,6 +632,7 @@ int bdi_init(struct backing_dev_info *bdi)
599 bdi->max_ratio = 100; 632 bdi->max_ratio = 100;
600 bdi->max_prop_frac = PROP_FRAC_BASE; 633 bdi->max_prop_frac = PROP_FRAC_BASE;
601 spin_lock_init(&bdi->wb_lock); 634 spin_lock_init(&bdi->wb_lock);
635 INIT_RCU_HEAD(&bdi->rcu_head);
602 INIT_LIST_HEAD(&bdi->bdi_list); 636 INIT_LIST_HEAD(&bdi->bdi_list);
603 INIT_LIST_HEAD(&bdi->wb_list); 637 INIT_LIST_HEAD(&bdi->wb_list);
604 INIT_LIST_HEAD(&bdi->work_list); 638 INIT_LIST_HEAD(&bdi->work_list);
@@ -634,7 +668,19 @@ void bdi_destroy(struct backing_dev_info *bdi)
634{ 668{
635 int i; 669 int i;
636 670
637 WARN_ON(bdi_has_dirty_io(bdi)); 671 /*
672 * Splice our entries to the default_backing_dev_info, if this
673 * bdi disappears
674 */
675 if (bdi_has_dirty_io(bdi)) {
676 struct bdi_writeback *dst = &default_backing_dev_info.wb;
677
678 spin_lock(&inode_lock);
679 list_splice(&bdi->wb.b_dirty, &dst->b_dirty);
680 list_splice(&bdi->wb.b_io, &dst->b_io);
681 list_splice(&bdi->wb.b_more_io, &dst->b_more_io);
682 spin_unlock(&inode_lock);
683 }
638 684
639 bdi_unregister(bdi); 685 bdi_unregister(bdi);
640 686
diff --git a/mm/kmemleak-test.c b/mm/kmemleak-test.c
index d5292fc6f523..177a5169bbde 100644
--- a/mm/kmemleak-test.c
+++ b/mm/kmemleak-test.c
@@ -36,7 +36,7 @@ struct test_node {
36}; 36};
37 37
38static LIST_HEAD(test_list); 38static LIST_HEAD(test_list);
39static DEFINE_PER_CPU(void *, test_pointer); 39static DEFINE_PER_CPU(void *, kmemleak_test_pointer);
40 40
41/* 41/*
42 * Some very simple testing. This function needs to be extended for 42 * Some very simple testing. This function needs to be extended for
@@ -86,9 +86,9 @@ static int __init kmemleak_test_init(void)
86 } 86 }
87 87
88 for_each_possible_cpu(i) { 88 for_each_possible_cpu(i) {
89 per_cpu(test_pointer, i) = kmalloc(129, GFP_KERNEL); 89 per_cpu(kmemleak_test_pointer, i) = kmalloc(129, GFP_KERNEL);
90 pr_info("kmemleak: kmalloc(129) = %p\n", 90 pr_info("kmemleak: kmalloc(129) = %p\n",
91 per_cpu(test_pointer, i)); 91 per_cpu(kmemleak_test_pointer, i));
92 } 92 }
93 93
94 return 0; 94 return 0;
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 25e7770309b8..1eea4fa0d410 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -315,7 +315,7 @@ int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio)
315{ 315{
316 int ret = 0; 316 int ret = 0;
317 317
318 spin_lock(&bdi_lock); 318 spin_lock_bh(&bdi_lock);
319 if (min_ratio > bdi->max_ratio) { 319 if (min_ratio > bdi->max_ratio) {
320 ret = -EINVAL; 320 ret = -EINVAL;
321 } else { 321 } else {
@@ -327,7 +327,7 @@ int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio)
327 ret = -EINVAL; 327 ret = -EINVAL;
328 } 328 }
329 } 329 }
330 spin_unlock(&bdi_lock); 330 spin_unlock_bh(&bdi_lock);
331 331
332 return ret; 332 return ret;
333} 333}
@@ -339,14 +339,14 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio)
339 if (max_ratio > 100) 339 if (max_ratio > 100)
340 return -EINVAL; 340 return -EINVAL;
341 341
342 spin_lock(&bdi_lock); 342 spin_lock_bh(&bdi_lock);
343 if (bdi->min_ratio > max_ratio) { 343 if (bdi->min_ratio > max_ratio) {
344 ret = -EINVAL; 344 ret = -EINVAL;
345 } else { 345 } else {
346 bdi->max_ratio = max_ratio; 346 bdi->max_ratio = max_ratio;
347 bdi->max_prop_frac = (PROP_FRAC_BASE * max_ratio) / 100; 347 bdi->max_prop_frac = (PROP_FRAC_BASE * max_ratio) / 100;
348 } 348 }
349 spin_unlock(&bdi_lock); 349 spin_unlock_bh(&bdi_lock);
350 350
351 return ret; 351 return ret;
352} 352}
@@ -582,16 +582,8 @@ static void balance_dirty_pages(struct address_space *mapping)
582 if ((laptop_mode && pages_written) || 582 if ((laptop_mode && pages_written) ||
583 (!laptop_mode && ((nr_writeback = global_page_state(NR_FILE_DIRTY) 583 (!laptop_mode && ((nr_writeback = global_page_state(NR_FILE_DIRTY)
584 + global_page_state(NR_UNSTABLE_NFS)) 584 + global_page_state(NR_UNSTABLE_NFS))
585 > background_thresh))) { 585 > background_thresh)))
586 struct writeback_control wbc = { 586 bdi_start_writeback(bdi, nr_writeback);
587 .bdi = bdi,
588 .sync_mode = WB_SYNC_NONE,
589 .nr_to_write = nr_writeback,
590 };
591
592
593 bdi_start_writeback(&wbc);
594 }
595} 587}
596 588
597void set_page_dirty_balance(struct page *page, int page_mkwrite) 589void set_page_dirty_balance(struct page *page, int page_mkwrite)
@@ -604,6 +596,8 @@ void set_page_dirty_balance(struct page *page, int page_mkwrite)
604 } 596 }
605} 597}
606 598
599static DEFINE_PER_CPU(unsigned long, bdp_ratelimits) = 0;
600
607/** 601/**
608 * balance_dirty_pages_ratelimited_nr - balance dirty memory state 602 * balance_dirty_pages_ratelimited_nr - balance dirty memory state
609 * @mapping: address_space which was dirtied 603 * @mapping: address_space which was dirtied
@@ -621,7 +615,6 @@ void set_page_dirty_balance(struct page *page, int page_mkwrite)
621void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, 615void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
622 unsigned long nr_pages_dirtied) 616 unsigned long nr_pages_dirtied)
623{ 617{
624 static DEFINE_PER_CPU(unsigned long, ratelimits) = 0;
625 unsigned long ratelimit; 618 unsigned long ratelimit;
626 unsigned long *p; 619 unsigned long *p;
627 620
@@ -634,7 +627,7 @@ void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
634 * tasks in balance_dirty_pages(). Period. 627 * tasks in balance_dirty_pages(). Period.
635 */ 628 */
636 preempt_disable(); 629 preempt_disable();
637 p = &__get_cpu_var(ratelimits); 630 p = &__get_cpu_var(bdp_ratelimits);
638 *p += nr_pages_dirtied; 631 *p += nr_pages_dirtied;
639 if (unlikely(*p >= ratelimit)) { 632 if (unlikely(*p >= ratelimit)) {
640 *p = 0; 633 *p = 0;
@@ -1019,12 +1012,10 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
1019 1012
1020 if (wbc->nr_to_write <= 0) 1013 if (wbc->nr_to_write <= 0)
1021 return 0; 1014 return 0;
1022 wbc->for_writepages = 1;
1023 if (mapping->a_ops->writepages) 1015 if (mapping->a_ops->writepages)
1024 ret = mapping->a_ops->writepages(mapping, wbc); 1016 ret = mapping->a_ops->writepages(mapping, wbc);
1025 else 1017 else
1026 ret = generic_writepages(mapping, wbc); 1018 ret = generic_writepages(mapping, wbc);
1027 wbc->for_writepages = 0;
1028 return ret; 1019 return ret;
1029} 1020}
1030 1021
diff --git a/mm/percpu.c b/mm/percpu.c
index 3311c8919f37..43d8cacfdaa5 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -8,12 +8,13 @@
8 * 8 *
9 * This is percpu allocator which can handle both static and dynamic 9 * This is percpu allocator which can handle both static and dynamic
10 * areas. Percpu areas are allocated in chunks in vmalloc area. Each 10 * areas. Percpu areas are allocated in chunks in vmalloc area. Each
11 * chunk is consisted of nr_cpu_ids units and the first chunk is used 11 * chunk is consisted of boot-time determined number of units and the
12 * for static percpu variables in the kernel image (special boot time 12 * first chunk is used for static percpu variables in the kernel image
13 * alloc/init handling necessary as these areas need to be brought up 13 * (special boot time alloc/init handling necessary as these areas
14 * before allocation services are running). Unit grows as necessary 14 * need to be brought up before allocation services are running).
15 * and all units grow or shrink in unison. When a chunk is filled up, 15 * Unit grows as necessary and all units grow or shrink in unison.
16 * another chunk is allocated. ie. in vmalloc area 16 * When a chunk is filled up, another chunk is allocated. ie. in
17 * vmalloc area
17 * 18 *
18 * c0 c1 c2 19 * c0 c1 c2
19 * ------------------- ------------------- ------------ 20 * ------------------- ------------------- ------------
@@ -22,11 +23,13 @@
22 * 23 *
23 * Allocation is done in offset-size areas of single unit space. Ie, 24 * Allocation is done in offset-size areas of single unit space. Ie,
24 * an area of 512 bytes at 6k in c1 occupies 512 bytes at 6k of c1:u0, 25 * an area of 512 bytes at 6k in c1 occupies 512 bytes at 6k of c1:u0,
25 * c1:u1, c1:u2 and c1:u3. Percpu access can be done by configuring 26 * c1:u1, c1:u2 and c1:u3. On UMA, units corresponds directly to
26 * percpu base registers pcpu_unit_size apart. 27 * cpus. On NUMA, the mapping can be non-linear and even sparse.
28 * Percpu access can be done by configuring percpu base registers
29 * according to cpu to unit mapping and pcpu_unit_size.
27 * 30 *
28 * There are usually many small percpu allocations many of them as 31 * There are usually many small percpu allocations many of them being
29 * small as 4 bytes. The allocator organizes chunks into lists 32 * as small as 4 bytes. The allocator organizes chunks into lists
30 * according to free size and tries to allocate from the fullest one. 33 * according to free size and tries to allocate from the fullest one.
31 * Each chunk keeps the maximum contiguous area size hint which is 34 * Each chunk keeps the maximum contiguous area size hint which is
32 * guaranteed to be eqaul to or larger than the maximum contiguous 35 * guaranteed to be eqaul to or larger than the maximum contiguous
@@ -43,7 +46,7 @@
43 * 46 *
44 * To use this allocator, arch code should do the followings. 47 * To use this allocator, arch code should do the followings.
45 * 48 *
46 * - define CONFIG_HAVE_DYNAMIC_PER_CPU_AREA 49 * - drop CONFIG_HAVE_LEGACY_PER_CPU_AREA
47 * 50 *
48 * - define __addr_to_pcpu_ptr() and __pcpu_ptr_to_addr() to translate 51 * - define __addr_to_pcpu_ptr() and __pcpu_ptr_to_addr() to translate
49 * regular address to percpu pointer and back if they need to be 52 * regular address to percpu pointer and back if they need to be
@@ -55,7 +58,9 @@
55 58
56#include <linux/bitmap.h> 59#include <linux/bitmap.h>
57#include <linux/bootmem.h> 60#include <linux/bootmem.h>
61#include <linux/err.h>
58#include <linux/list.h> 62#include <linux/list.h>
63#include <linux/log2.h>
59#include <linux/mm.h> 64#include <linux/mm.h>
60#include <linux/module.h> 65#include <linux/module.h>
61#include <linux/mutex.h> 66#include <linux/mutex.h>
@@ -89,25 +94,38 @@ struct pcpu_chunk {
89 struct list_head list; /* linked to pcpu_slot lists */ 94 struct list_head list; /* linked to pcpu_slot lists */
90 int free_size; /* free bytes in the chunk */ 95 int free_size; /* free bytes in the chunk */
91 int contig_hint; /* max contiguous size hint */ 96 int contig_hint; /* max contiguous size hint */
92 struct vm_struct *vm; /* mapped vmalloc region */ 97 void *base_addr; /* base address of this chunk */
93 int map_used; /* # of map entries used */ 98 int map_used; /* # of map entries used */
94 int map_alloc; /* # of map entries allocated */ 99 int map_alloc; /* # of map entries allocated */
95 int *map; /* allocation map */ 100 int *map; /* allocation map */
101 struct vm_struct **vms; /* mapped vmalloc regions */
96 bool immutable; /* no [de]population allowed */ 102 bool immutable; /* no [de]population allowed */
97 struct page **page; /* points to page array */ 103 unsigned long populated[]; /* populated bitmap */
98 struct page *page_ar[]; /* #cpus * UNIT_PAGES */
99}; 104};
100 105
101static int pcpu_unit_pages __read_mostly; 106static int pcpu_unit_pages __read_mostly;
102static int pcpu_unit_size __read_mostly; 107static int pcpu_unit_size __read_mostly;
103static int pcpu_chunk_size __read_mostly; 108static int pcpu_nr_units __read_mostly;
109static int pcpu_atom_size __read_mostly;
104static int pcpu_nr_slots __read_mostly; 110static int pcpu_nr_slots __read_mostly;
105static size_t pcpu_chunk_struct_size __read_mostly; 111static size_t pcpu_chunk_struct_size __read_mostly;
106 112
113/* cpus with the lowest and highest unit numbers */
114static unsigned int pcpu_first_unit_cpu __read_mostly;
115static unsigned int pcpu_last_unit_cpu __read_mostly;
116
107/* the address of the first chunk which starts with the kernel static area */ 117/* the address of the first chunk which starts with the kernel static area */
108void *pcpu_base_addr __read_mostly; 118void *pcpu_base_addr __read_mostly;
109EXPORT_SYMBOL_GPL(pcpu_base_addr); 119EXPORT_SYMBOL_GPL(pcpu_base_addr);
110 120
121static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
122const unsigned long *pcpu_unit_offsets __read_mostly; /* cpu -> unit offset */
123
124/* group information, used for vm allocation */
125static int pcpu_nr_groups __read_mostly;
126static const unsigned long *pcpu_group_offsets __read_mostly;
127static const size_t *pcpu_group_sizes __read_mostly;
128
111/* 129/*
112 * The first chunk which always exists. Note that unlike other 130 * The first chunk which always exists. Note that unlike other
113 * chunks, this one can be allocated and mapped in several different 131 * chunks, this one can be allocated and mapped in several different
@@ -129,9 +147,9 @@ static int pcpu_reserved_chunk_limit;
129 * Synchronization rules. 147 * Synchronization rules.
130 * 148 *
131 * There are two locks - pcpu_alloc_mutex and pcpu_lock. The former 149 * There are two locks - pcpu_alloc_mutex and pcpu_lock. The former
132 * protects allocation/reclaim paths, chunks and chunk->page arrays. 150 * protects allocation/reclaim paths, chunks, populated bitmap and
133 * The latter is a spinlock and protects the index data structures - 151 * vmalloc mapping. The latter is a spinlock and protects the index
134 * chunk slots, chunks and area maps in chunks. 152 * data structures - chunk slots, chunks and area maps in chunks.
135 * 153 *
136 * During allocation, pcpu_alloc_mutex is kept locked all the time and 154 * During allocation, pcpu_alloc_mutex is kept locked all the time and
137 * pcpu_lock is grabbed and released as necessary. All actual memory 155 * pcpu_lock is grabbed and released as necessary. All actual memory
@@ -178,31 +196,23 @@ static int pcpu_chunk_slot(const struct pcpu_chunk *chunk)
178 196
179static int pcpu_page_idx(unsigned int cpu, int page_idx) 197static int pcpu_page_idx(unsigned int cpu, int page_idx)
180{ 198{
181 return cpu * pcpu_unit_pages + page_idx; 199 return pcpu_unit_map[cpu] * pcpu_unit_pages + page_idx;
182}
183
184static struct page **pcpu_chunk_pagep(struct pcpu_chunk *chunk,
185 unsigned int cpu, int page_idx)
186{
187 return &chunk->page[pcpu_page_idx(cpu, page_idx)];
188} 200}
189 201
190static unsigned long pcpu_chunk_addr(struct pcpu_chunk *chunk, 202static unsigned long pcpu_chunk_addr(struct pcpu_chunk *chunk,
191 unsigned int cpu, int page_idx) 203 unsigned int cpu, int page_idx)
192{ 204{
193 return (unsigned long)chunk->vm->addr + 205 return (unsigned long)chunk->base_addr + pcpu_unit_offsets[cpu] +
194 (pcpu_page_idx(cpu, page_idx) << PAGE_SHIFT); 206 (page_idx << PAGE_SHIFT);
195} 207}
196 208
197static bool pcpu_chunk_page_occupied(struct pcpu_chunk *chunk, 209static struct page *pcpu_chunk_page(struct pcpu_chunk *chunk,
198 int page_idx) 210 unsigned int cpu, int page_idx)
199{ 211{
200 /* 212 /* must not be used on pre-mapped chunk */
201 * Any possible cpu id can be used here, so there's no need to 213 WARN_ON(chunk->immutable);
202 * worry about preemption or cpu hotplug. 214
203 */ 215 return vmalloc_to_page((void *)pcpu_chunk_addr(chunk, cpu, page_idx));
204 return *pcpu_chunk_pagep(chunk, raw_smp_processor_id(),
205 page_idx) != NULL;
206} 216}
207 217
208/* set the pointer to a chunk in a page struct */ 218/* set the pointer to a chunk in a page struct */
@@ -217,6 +227,34 @@ static struct pcpu_chunk *pcpu_get_page_chunk(struct page *page)
217 return (struct pcpu_chunk *)page->index; 227 return (struct pcpu_chunk *)page->index;
218} 228}
219 229
230static void pcpu_next_unpop(struct pcpu_chunk *chunk, int *rs, int *re, int end)
231{
232 *rs = find_next_zero_bit(chunk->populated, end, *rs);
233 *re = find_next_bit(chunk->populated, end, *rs + 1);
234}
235
236static void pcpu_next_pop(struct pcpu_chunk *chunk, int *rs, int *re, int end)
237{
238 *rs = find_next_bit(chunk->populated, end, *rs);
239 *re = find_next_zero_bit(chunk->populated, end, *rs + 1);
240}
241
242/*
243 * (Un)populated page region iterators. Iterate over (un)populated
244 * page regions betwen @start and @end in @chunk. @rs and @re should
245 * be integer variables and will be set to start and end page index of
246 * the current region.
247 */
248#define pcpu_for_each_unpop_region(chunk, rs, re, start, end) \
249 for ((rs) = (start), pcpu_next_unpop((chunk), &(rs), &(re), (end)); \
250 (rs) < (re); \
251 (rs) = (re) + 1, pcpu_next_unpop((chunk), &(rs), &(re), (end)))
252
253#define pcpu_for_each_pop_region(chunk, rs, re, start, end) \
254 for ((rs) = (start), pcpu_next_pop((chunk), &(rs), &(re), (end)); \
255 (rs) < (re); \
256 (rs) = (re) + 1, pcpu_next_pop((chunk), &(rs), &(re), (end)))
257
220/** 258/**
221 * pcpu_mem_alloc - allocate memory 259 * pcpu_mem_alloc - allocate memory
222 * @size: bytes to allocate 260 * @size: bytes to allocate
@@ -292,10 +330,10 @@ static void pcpu_chunk_relocate(struct pcpu_chunk *chunk, int oslot)
292 */ 330 */
293static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr) 331static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
294{ 332{
295 void *first_start = pcpu_first_chunk->vm->addr; 333 void *first_start = pcpu_first_chunk->base_addr;
296 334
297 /* is it in the first chunk? */ 335 /* is it in the first chunk? */
298 if (addr >= first_start && addr < first_start + pcpu_chunk_size) { 336 if (addr >= first_start && addr < first_start + pcpu_unit_size) {
299 /* is it in the reserved area? */ 337 /* is it in the reserved area? */
300 if (addr < first_start + pcpu_reserved_chunk_limit) 338 if (addr < first_start + pcpu_reserved_chunk_limit)
301 return pcpu_reserved_chunk; 339 return pcpu_reserved_chunk;
@@ -309,7 +347,7 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr)
309 * space. Note that any possible cpu id can be used here, so 347 * space. Note that any possible cpu id can be used here, so
310 * there's no need to worry about preemption or cpu hotplug. 348 * there's no need to worry about preemption or cpu hotplug.
311 */ 349 */
312 addr += raw_smp_processor_id() * pcpu_unit_size; 350 addr += pcpu_unit_offsets[raw_smp_processor_id()];
313 return pcpu_get_page_chunk(vmalloc_to_page(addr)); 351 return pcpu_get_page_chunk(vmalloc_to_page(addr));
314} 352}
315 353
@@ -558,125 +596,327 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int freeme)
558} 596}
559 597
560/** 598/**
561 * pcpu_unmap - unmap pages out of a pcpu_chunk 599 * pcpu_get_pages_and_bitmap - get temp pages array and bitmap
562 * @chunk: chunk of interest 600 * @chunk: chunk of interest
563 * @page_start: page index of the first page to unmap 601 * @bitmapp: output parameter for bitmap
564 * @page_end: page index of the last page to unmap + 1 602 * @may_alloc: may allocate the array
565 * @flush_tlb: whether to flush tlb or not
566 * 603 *
567 * For each cpu, unmap pages [@page_start,@page_end) out of @chunk. 604 * Returns pointer to array of pointers to struct page and bitmap,
568 * If @flush is true, vcache is flushed before unmapping and tlb 605 * both of which can be indexed with pcpu_page_idx(). The returned
569 * after. 606 * array is cleared to zero and *@bitmapp is copied from
607 * @chunk->populated. Note that there is only one array and bitmap
608 * and access exclusion is the caller's responsibility.
609 *
610 * CONTEXT:
611 * pcpu_alloc_mutex and does GFP_KERNEL allocation if @may_alloc.
612 * Otherwise, don't care.
613 *
614 * RETURNS:
615 * Pointer to temp pages array on success, NULL on failure.
570 */ 616 */
571static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end, 617static struct page **pcpu_get_pages_and_bitmap(struct pcpu_chunk *chunk,
572 bool flush_tlb) 618 unsigned long **bitmapp,
619 bool may_alloc)
573{ 620{
574 unsigned int last = nr_cpu_ids - 1; 621 static struct page **pages;
575 unsigned int cpu; 622 static unsigned long *bitmap;
623 size_t pages_size = pcpu_nr_units * pcpu_unit_pages * sizeof(pages[0]);
624 size_t bitmap_size = BITS_TO_LONGS(pcpu_unit_pages) *
625 sizeof(unsigned long);
626
627 if (!pages || !bitmap) {
628 if (may_alloc && !pages)
629 pages = pcpu_mem_alloc(pages_size);
630 if (may_alloc && !bitmap)
631 bitmap = pcpu_mem_alloc(bitmap_size);
632 if (!pages || !bitmap)
633 return NULL;
634 }
576 635
577 /* unmap must not be done on immutable chunk */ 636 memset(pages, 0, pages_size);
578 WARN_ON(chunk->immutable); 637 bitmap_copy(bitmap, chunk->populated, pcpu_unit_pages);
579 638
580 /* 639 *bitmapp = bitmap;
581 * Each flushing trial can be very expensive, issue flush on 640 return pages;
582 * the whole region at once rather than doing it for each cpu. 641}
583 * This could be an overkill but is more scalable.
584 */
585 flush_cache_vunmap(pcpu_chunk_addr(chunk, 0, page_start),
586 pcpu_chunk_addr(chunk, last, page_end));
587 642
588 for_each_possible_cpu(cpu) 643/**
589 unmap_kernel_range_noflush( 644 * pcpu_free_pages - free pages which were allocated for @chunk
590 pcpu_chunk_addr(chunk, cpu, page_start), 645 * @chunk: chunk pages were allocated for
591 (page_end - page_start) << PAGE_SHIFT); 646 * @pages: array of pages to be freed, indexed by pcpu_page_idx()
592 647 * @populated: populated bitmap
593 /* ditto as flush_cache_vunmap() */ 648 * @page_start: page index of the first page to be freed
594 if (flush_tlb) 649 * @page_end: page index of the last page to be freed + 1
595 flush_tlb_kernel_range(pcpu_chunk_addr(chunk, 0, page_start), 650 *
596 pcpu_chunk_addr(chunk, last, page_end)); 651 * Free pages [@page_start and @page_end) in @pages for all units.
652 * The pages were allocated for @chunk.
653 */
654static void pcpu_free_pages(struct pcpu_chunk *chunk,
655 struct page **pages, unsigned long *populated,
656 int page_start, int page_end)
657{
658 unsigned int cpu;
659 int i;
660
661 for_each_possible_cpu(cpu) {
662 for (i = page_start; i < page_end; i++) {
663 struct page *page = pages[pcpu_page_idx(cpu, i)];
664
665 if (page)
666 __free_page(page);
667 }
668 }
597} 669}
598 670
599/** 671/**
600 * pcpu_depopulate_chunk - depopulate and unmap an area of a pcpu_chunk 672 * pcpu_alloc_pages - allocates pages for @chunk
601 * @chunk: chunk to depopulate 673 * @chunk: target chunk
602 * @off: offset to the area to depopulate 674 * @pages: array to put the allocated pages into, indexed by pcpu_page_idx()
603 * @size: size of the area to depopulate in bytes 675 * @populated: populated bitmap
604 * @flush: whether to flush cache and tlb or not 676 * @page_start: page index of the first page to be allocated
605 * 677 * @page_end: page index of the last page to be allocated + 1
606 * For each cpu, depopulate and unmap pages [@page_start,@page_end) 678 *
607 * from @chunk. If @flush is true, vcache is flushed before unmapping 679 * Allocate pages [@page_start,@page_end) into @pages for all units.
608 * and tlb after. 680 * The allocation is for @chunk. Percpu core doesn't care about the
609 * 681 * content of @pages and will pass it verbatim to pcpu_map_pages().
610 * CONTEXT:
611 * pcpu_alloc_mutex.
612 */ 682 */
613static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size, 683static int pcpu_alloc_pages(struct pcpu_chunk *chunk,
614 bool flush) 684 struct page **pages, unsigned long *populated,
685 int page_start, int page_end)
615{ 686{
616 int page_start = PFN_DOWN(off); 687 const gfp_t gfp = GFP_KERNEL | __GFP_HIGHMEM | __GFP_COLD;
617 int page_end = PFN_UP(off + size);
618 int unmap_start = -1;
619 int uninitialized_var(unmap_end);
620 unsigned int cpu; 688 unsigned int cpu;
621 int i; 689 int i;
622 690
623 for (i = page_start; i < page_end; i++) { 691 for_each_possible_cpu(cpu) {
624 for_each_possible_cpu(cpu) { 692 for (i = page_start; i < page_end; i++) {
625 struct page **pagep = pcpu_chunk_pagep(chunk, cpu, i); 693 struct page **pagep = &pages[pcpu_page_idx(cpu, i)];
694
695 *pagep = alloc_pages_node(cpu_to_node(cpu), gfp, 0);
696 if (!*pagep) {
697 pcpu_free_pages(chunk, pages, populated,
698 page_start, page_end);
699 return -ENOMEM;
700 }
701 }
702 }
703 return 0;
704}
626 705
627 if (!*pagep) 706/**
628 continue; 707 * pcpu_pre_unmap_flush - flush cache prior to unmapping
708 * @chunk: chunk the regions to be flushed belongs to
709 * @page_start: page index of the first page to be flushed
710 * @page_end: page index of the last page to be flushed + 1
711 *
712 * Pages in [@page_start,@page_end) of @chunk are about to be
713 * unmapped. Flush cache. As each flushing trial can be very
714 * expensive, issue flush on the whole region at once rather than
715 * doing it for each cpu. This could be an overkill but is more
716 * scalable.
717 */
718static void pcpu_pre_unmap_flush(struct pcpu_chunk *chunk,
719 int page_start, int page_end)
720{
721 flush_cache_vunmap(
722 pcpu_chunk_addr(chunk, pcpu_first_unit_cpu, page_start),
723 pcpu_chunk_addr(chunk, pcpu_last_unit_cpu, page_end));
724}
725
726static void __pcpu_unmap_pages(unsigned long addr, int nr_pages)
727{
728 unmap_kernel_range_noflush(addr, nr_pages << PAGE_SHIFT);
729}
629 730
630 __free_page(*pagep); 731/**
732 * pcpu_unmap_pages - unmap pages out of a pcpu_chunk
733 * @chunk: chunk of interest
734 * @pages: pages array which can be used to pass information to free
735 * @populated: populated bitmap
736 * @page_start: page index of the first page to unmap
737 * @page_end: page index of the last page to unmap + 1
738 *
739 * For each cpu, unmap pages [@page_start,@page_end) out of @chunk.
740 * Corresponding elements in @pages were cleared by the caller and can
741 * be used to carry information to pcpu_free_pages() which will be
742 * called after all unmaps are finished. The caller should call
743 * proper pre/post flush functions.
744 */
745static void pcpu_unmap_pages(struct pcpu_chunk *chunk,
746 struct page **pages, unsigned long *populated,
747 int page_start, int page_end)
748{
749 unsigned int cpu;
750 int i;
631 751
632 /* 752 for_each_possible_cpu(cpu) {
633 * If it's partial depopulation, it might get 753 for (i = page_start; i < page_end; i++) {
634 * populated or depopulated again. Mark the 754 struct page *page;
635 * page gone.
636 */
637 *pagep = NULL;
638 755
639 unmap_start = unmap_start < 0 ? i : unmap_start; 756 page = pcpu_chunk_page(chunk, cpu, i);
640 unmap_end = i + 1; 757 WARN_ON(!page);
758 pages[pcpu_page_idx(cpu, i)] = page;
641 } 759 }
760 __pcpu_unmap_pages(pcpu_chunk_addr(chunk, cpu, page_start),
761 page_end - page_start);
642 } 762 }
643 763
644 if (unmap_start >= 0) 764 for (i = page_start; i < page_end; i++)
645 pcpu_unmap(chunk, unmap_start, unmap_end, flush); 765 __clear_bit(i, populated);
766}
767
768/**
769 * pcpu_post_unmap_tlb_flush - flush TLB after unmapping
770 * @chunk: pcpu_chunk the regions to be flushed belong to
771 * @page_start: page index of the first page to be flushed
772 * @page_end: page index of the last page to be flushed + 1
773 *
774 * Pages [@page_start,@page_end) of @chunk have been unmapped. Flush
775 * TLB for the regions. This can be skipped if the area is to be
776 * returned to vmalloc as vmalloc will handle TLB flushing lazily.
777 *
778 * As with pcpu_pre_unmap_flush(), TLB flushing also is done at once
779 * for the whole region.
780 */
781static void pcpu_post_unmap_tlb_flush(struct pcpu_chunk *chunk,
782 int page_start, int page_end)
783{
784 flush_tlb_kernel_range(
785 pcpu_chunk_addr(chunk, pcpu_first_unit_cpu, page_start),
786 pcpu_chunk_addr(chunk, pcpu_last_unit_cpu, page_end));
787}
788
789static int __pcpu_map_pages(unsigned long addr, struct page **pages,
790 int nr_pages)
791{
792 return map_kernel_range_noflush(addr, nr_pages << PAGE_SHIFT,
793 PAGE_KERNEL, pages);
646} 794}
647 795
648/** 796/**
649 * pcpu_map - map pages into a pcpu_chunk 797 * pcpu_map_pages - map pages into a pcpu_chunk
650 * @chunk: chunk of interest 798 * @chunk: chunk of interest
799 * @pages: pages array containing pages to be mapped
800 * @populated: populated bitmap
651 * @page_start: page index of the first page to map 801 * @page_start: page index of the first page to map
652 * @page_end: page index of the last page to map + 1 802 * @page_end: page index of the last page to map + 1
653 * 803 *
654 * For each cpu, map pages [@page_start,@page_end) into @chunk. 804 * For each cpu, map pages [@page_start,@page_end) into @chunk. The
655 * vcache is flushed afterwards. 805 * caller is responsible for calling pcpu_post_map_flush() after all
806 * mappings are complete.
807 *
808 * This function is responsible for setting corresponding bits in
809 * @chunk->populated bitmap and whatever is necessary for reverse
810 * lookup (addr -> chunk).
656 */ 811 */
657static int pcpu_map(struct pcpu_chunk *chunk, int page_start, int page_end) 812static int pcpu_map_pages(struct pcpu_chunk *chunk,
813 struct page **pages, unsigned long *populated,
814 int page_start, int page_end)
658{ 815{
659 unsigned int last = nr_cpu_ids - 1; 816 unsigned int cpu, tcpu;
660 unsigned int cpu; 817 int i, err;
661 int err;
662
663 /* map must not be done on immutable chunk */
664 WARN_ON(chunk->immutable);
665 818
666 for_each_possible_cpu(cpu) { 819 for_each_possible_cpu(cpu) {
667 err = map_kernel_range_noflush( 820 err = __pcpu_map_pages(pcpu_chunk_addr(chunk, cpu, page_start),
668 pcpu_chunk_addr(chunk, cpu, page_start), 821 &pages[pcpu_page_idx(cpu, page_start)],
669 (page_end - page_start) << PAGE_SHIFT, 822 page_end - page_start);
670 PAGE_KERNEL,
671 pcpu_chunk_pagep(chunk, cpu, page_start));
672 if (err < 0) 823 if (err < 0)
673 return err; 824 goto err;
825 }
826
827 /* mapping successful, link chunk and mark populated */
828 for (i = page_start; i < page_end; i++) {
829 for_each_possible_cpu(cpu)
830 pcpu_set_page_chunk(pages[pcpu_page_idx(cpu, i)],
831 chunk);
832 __set_bit(i, populated);
674 } 833 }
675 834
676 /* flush at once, please read comments in pcpu_unmap() */
677 flush_cache_vmap(pcpu_chunk_addr(chunk, 0, page_start),
678 pcpu_chunk_addr(chunk, last, page_end));
679 return 0; 835 return 0;
836
837err:
838 for_each_possible_cpu(tcpu) {
839 if (tcpu == cpu)
840 break;
841 __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start),
842 page_end - page_start);
843 }
844 return err;
845}
846
847/**
848 * pcpu_post_map_flush - flush cache after mapping
849 * @chunk: pcpu_chunk the regions to be flushed belong to
850 * @page_start: page index of the first page to be flushed
851 * @page_end: page index of the last page to be flushed + 1
852 *
853 * Pages [@page_start,@page_end) of @chunk have been mapped. Flush
854 * cache.
855 *
856 * As with pcpu_pre_unmap_flush(), TLB flushing also is done at once
857 * for the whole region.
858 */
859static void pcpu_post_map_flush(struct pcpu_chunk *chunk,
860 int page_start, int page_end)
861{
862 flush_cache_vmap(
863 pcpu_chunk_addr(chunk, pcpu_first_unit_cpu, page_start),
864 pcpu_chunk_addr(chunk, pcpu_last_unit_cpu, page_end));
865}
866
867/**
868 * pcpu_depopulate_chunk - depopulate and unmap an area of a pcpu_chunk
869 * @chunk: chunk to depopulate
870 * @off: offset to the area to depopulate
871 * @size: size of the area to depopulate in bytes
872 * @flush: whether to flush cache and tlb or not
873 *
874 * For each cpu, depopulate and unmap pages [@page_start,@page_end)
875 * from @chunk. If @flush is true, vcache is flushed before unmapping
876 * and tlb after.
877 *
878 * CONTEXT:
879 * pcpu_alloc_mutex.
880 */
881static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size)
882{
883 int page_start = PFN_DOWN(off);
884 int page_end = PFN_UP(off + size);
885 struct page **pages;
886 unsigned long *populated;
887 int rs, re;
888
889 /* quick path, check whether it's empty already */
890 pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
891 if (rs == page_start && re == page_end)
892 return;
893 break;
894 }
895
896 /* immutable chunks can't be depopulated */
897 WARN_ON(chunk->immutable);
898
899 /*
900 * If control reaches here, there must have been at least one
901 * successful population attempt so the temp pages array must
902 * be available now.
903 */
904 pages = pcpu_get_pages_and_bitmap(chunk, &populated, false);
905 BUG_ON(!pages);
906
907 /* unmap and free */
908 pcpu_pre_unmap_flush(chunk, page_start, page_end);
909
910 pcpu_for_each_pop_region(chunk, rs, re, page_start, page_end)
911 pcpu_unmap_pages(chunk, pages, populated, rs, re);
912
913 /* no need to flush tlb, vmalloc will handle it lazily */
914
915 pcpu_for_each_pop_region(chunk, rs, re, page_start, page_end)
916 pcpu_free_pages(chunk, pages, populated, rs, re);
917
918 /* commit new bitmap */
919 bitmap_copy(chunk->populated, populated, pcpu_unit_pages);
680} 920}
681 921
682/** 922/**
@@ -693,58 +933,68 @@ static int pcpu_map(struct pcpu_chunk *chunk, int page_start, int page_end)
693 */ 933 */
694static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size) 934static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size)
695{ 935{
696 const gfp_t alloc_mask = GFP_KERNEL | __GFP_HIGHMEM | __GFP_COLD;
697 int page_start = PFN_DOWN(off); 936 int page_start = PFN_DOWN(off);
698 int page_end = PFN_UP(off + size); 937 int page_end = PFN_UP(off + size);
699 int map_start = -1; 938 int free_end = page_start, unmap_end = page_start;
700 int uninitialized_var(map_end); 939 struct page **pages;
940 unsigned long *populated;
701 unsigned int cpu; 941 unsigned int cpu;
702 int i; 942 int rs, re, rc;
703 943
704 for (i = page_start; i < page_end; i++) { 944 /* quick path, check whether all pages are already there */
705 if (pcpu_chunk_page_occupied(chunk, i)) { 945 pcpu_for_each_pop_region(chunk, rs, re, page_start, page_end) {
706 if (map_start >= 0) { 946 if (rs == page_start && re == page_end)
707 if (pcpu_map(chunk, map_start, map_end)) 947 goto clear;
708 goto err; 948 break;
709 map_start = -1; 949 }
710 }
711 continue;
712 }
713 950
714 map_start = map_start < 0 ? i : map_start; 951 /* need to allocate and map pages, this chunk can't be immutable */
715 map_end = i + 1; 952 WARN_ON(chunk->immutable);
716 953
717 for_each_possible_cpu(cpu) { 954 pages = pcpu_get_pages_and_bitmap(chunk, &populated, true);
718 struct page **pagep = pcpu_chunk_pagep(chunk, cpu, i); 955 if (!pages)
956 return -ENOMEM;
719 957
720 *pagep = alloc_pages_node(cpu_to_node(cpu), 958 /* alloc and map */
721 alloc_mask, 0); 959 pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
722 if (!*pagep) 960 rc = pcpu_alloc_pages(chunk, pages, populated, rs, re);
723 goto err; 961 if (rc)
724 pcpu_set_page_chunk(*pagep, chunk); 962 goto err_free;
725 } 963 free_end = re;
726 } 964 }
727 965
728 if (map_start >= 0 && pcpu_map(chunk, map_start, map_end)) 966 pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
729 goto err; 967 rc = pcpu_map_pages(chunk, pages, populated, rs, re);
968 if (rc)
969 goto err_unmap;
970 unmap_end = re;
971 }
972 pcpu_post_map_flush(chunk, page_start, page_end);
730 973
974 /* commit new bitmap */
975 bitmap_copy(chunk->populated, populated, pcpu_unit_pages);
976clear:
731 for_each_possible_cpu(cpu) 977 for_each_possible_cpu(cpu)
732 memset(chunk->vm->addr + cpu * pcpu_unit_size + off, 0, 978 memset((void *)pcpu_chunk_addr(chunk, cpu, 0) + off, 0, size);
733 size);
734
735 return 0; 979 return 0;
736err: 980
737 /* likely under heavy memory pressure, give memory back */ 981err_unmap:
738 pcpu_depopulate_chunk(chunk, off, size, true); 982 pcpu_pre_unmap_flush(chunk, page_start, unmap_end);
739 return -ENOMEM; 983 pcpu_for_each_unpop_region(chunk, rs, re, page_start, unmap_end)
984 pcpu_unmap_pages(chunk, pages, populated, rs, re);
985 pcpu_post_unmap_tlb_flush(chunk, page_start, unmap_end);
986err_free:
987 pcpu_for_each_unpop_region(chunk, rs, re, page_start, free_end)
988 pcpu_free_pages(chunk, pages, populated, rs, re);
989 return rc;
740} 990}
741 991
742static void free_pcpu_chunk(struct pcpu_chunk *chunk) 992static void free_pcpu_chunk(struct pcpu_chunk *chunk)
743{ 993{
744 if (!chunk) 994 if (!chunk)
745 return; 995 return;
746 if (chunk->vm) 996 if (chunk->vms)
747 free_vm_area(chunk->vm); 997 pcpu_free_vm_areas(chunk->vms, pcpu_nr_groups);
748 pcpu_mem_free(chunk->map, chunk->map_alloc * sizeof(chunk->map[0])); 998 pcpu_mem_free(chunk->map, chunk->map_alloc * sizeof(chunk->map[0]));
749 kfree(chunk); 999 kfree(chunk);
750} 1000}
@@ -760,10 +1010,11 @@ static struct pcpu_chunk *alloc_pcpu_chunk(void)
760 chunk->map = pcpu_mem_alloc(PCPU_DFL_MAP_ALLOC * sizeof(chunk->map[0])); 1010 chunk->map = pcpu_mem_alloc(PCPU_DFL_MAP_ALLOC * sizeof(chunk->map[0]));
761 chunk->map_alloc = PCPU_DFL_MAP_ALLOC; 1011 chunk->map_alloc = PCPU_DFL_MAP_ALLOC;
762 chunk->map[chunk->map_used++] = pcpu_unit_size; 1012 chunk->map[chunk->map_used++] = pcpu_unit_size;
763 chunk->page = chunk->page_ar;
764 1013
765 chunk->vm = get_vm_area(pcpu_chunk_size, VM_ALLOC); 1014 chunk->vms = pcpu_get_vm_areas(pcpu_group_offsets, pcpu_group_sizes,
766 if (!chunk->vm) { 1015 pcpu_nr_groups, pcpu_atom_size,
1016 GFP_KERNEL);
1017 if (!chunk->vms) {
767 free_pcpu_chunk(chunk); 1018 free_pcpu_chunk(chunk);
768 return NULL; 1019 return NULL;
769 } 1020 }
@@ -771,6 +1022,7 @@ static struct pcpu_chunk *alloc_pcpu_chunk(void)
771 INIT_LIST_HEAD(&chunk->list); 1022 INIT_LIST_HEAD(&chunk->list);
772 chunk->free_size = pcpu_unit_size; 1023 chunk->free_size = pcpu_unit_size;
773 chunk->contig_hint = pcpu_unit_size; 1024 chunk->contig_hint = pcpu_unit_size;
1025 chunk->base_addr = chunk->vms[0]->addr - pcpu_group_offsets[0];
774 1026
775 return chunk; 1027 return chunk;
776} 1028}
@@ -860,7 +1112,8 @@ area_found:
860 1112
861 mutex_unlock(&pcpu_alloc_mutex); 1113 mutex_unlock(&pcpu_alloc_mutex);
862 1114
863 return __addr_to_pcpu_ptr(chunk->vm->addr + off); 1115 /* return address relative to base address */
1116 return __addr_to_pcpu_ptr(chunk->base_addr + off);
864 1117
865fail_unlock: 1118fail_unlock:
866 spin_unlock_irq(&pcpu_lock); 1119 spin_unlock_irq(&pcpu_lock);
@@ -938,12 +1191,13 @@ static void pcpu_reclaim(struct work_struct *work)
938 } 1191 }
939 1192
940 spin_unlock_irq(&pcpu_lock); 1193 spin_unlock_irq(&pcpu_lock);
941 mutex_unlock(&pcpu_alloc_mutex);
942 1194
943 list_for_each_entry_safe(chunk, next, &todo, list) { 1195 list_for_each_entry_safe(chunk, next, &todo, list) {
944 pcpu_depopulate_chunk(chunk, 0, pcpu_unit_size, false); 1196 pcpu_depopulate_chunk(chunk, 0, pcpu_unit_size);
945 free_pcpu_chunk(chunk); 1197 free_pcpu_chunk(chunk);
946 } 1198 }
1199
1200 mutex_unlock(&pcpu_alloc_mutex);
947} 1201}
948 1202
949/** 1203/**
@@ -968,7 +1222,7 @@ void free_percpu(void *ptr)
968 spin_lock_irqsave(&pcpu_lock, flags); 1222 spin_lock_irqsave(&pcpu_lock, flags);
969 1223
970 chunk = pcpu_chunk_addr_search(addr); 1224 chunk = pcpu_chunk_addr_search(addr);
971 off = addr - chunk->vm->addr; 1225 off = addr - chunk->base_addr;
972 1226
973 pcpu_free_area(chunk, off); 1227 pcpu_free_area(chunk, off);
974 1228
@@ -987,30 +1241,295 @@ void free_percpu(void *ptr)
987} 1241}
988EXPORT_SYMBOL_GPL(free_percpu); 1242EXPORT_SYMBOL_GPL(free_percpu);
989 1243
1244static inline size_t pcpu_calc_fc_sizes(size_t static_size,
1245 size_t reserved_size,
1246 ssize_t *dyn_sizep)
1247{
1248 size_t size_sum;
1249
1250 size_sum = PFN_ALIGN(static_size + reserved_size +
1251 (*dyn_sizep >= 0 ? *dyn_sizep : 0));
1252 if (*dyn_sizep != 0)
1253 *dyn_sizep = size_sum - static_size - reserved_size;
1254
1255 return size_sum;
1256}
1257
990/** 1258/**
991 * pcpu_setup_first_chunk - initialize the first percpu chunk 1259 * pcpu_alloc_alloc_info - allocate percpu allocation info
992 * @get_page_fn: callback to fetch page pointer 1260 * @nr_groups: the number of groups
993 * @static_size: the size of static percpu area in bytes 1261 * @nr_units: the number of units
1262 *
1263 * Allocate ai which is large enough for @nr_groups groups containing
1264 * @nr_units units. The returned ai's groups[0].cpu_map points to the
1265 * cpu_map array which is long enough for @nr_units and filled with
1266 * NR_CPUS. It's the caller's responsibility to initialize cpu_map
1267 * pointer of other groups.
1268 *
1269 * RETURNS:
1270 * Pointer to the allocated pcpu_alloc_info on success, NULL on
1271 * failure.
1272 */
1273struct pcpu_alloc_info * __init pcpu_alloc_alloc_info(int nr_groups,
1274 int nr_units)
1275{
1276 struct pcpu_alloc_info *ai;
1277 size_t base_size, ai_size;
1278 void *ptr;
1279 int unit;
1280
1281 base_size = ALIGN(sizeof(*ai) + nr_groups * sizeof(ai->groups[0]),
1282 __alignof__(ai->groups[0].cpu_map[0]));
1283 ai_size = base_size + nr_units * sizeof(ai->groups[0].cpu_map[0]);
1284
1285 ptr = alloc_bootmem_nopanic(PFN_ALIGN(ai_size));
1286 if (!ptr)
1287 return NULL;
1288 ai = ptr;
1289 ptr += base_size;
1290
1291 ai->groups[0].cpu_map = ptr;
1292
1293 for (unit = 0; unit < nr_units; unit++)
1294 ai->groups[0].cpu_map[unit] = NR_CPUS;
1295
1296 ai->nr_groups = nr_groups;
1297 ai->__ai_size = PFN_ALIGN(ai_size);
1298
1299 return ai;
1300}
1301
1302/**
1303 * pcpu_free_alloc_info - free percpu allocation info
1304 * @ai: pcpu_alloc_info to free
1305 *
1306 * Free @ai which was allocated by pcpu_alloc_alloc_info().
1307 */
1308void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai)
1309{
1310 free_bootmem(__pa(ai), ai->__ai_size);
1311}
1312
1313/**
1314 * pcpu_build_alloc_info - build alloc_info considering distances between CPUs
994 * @reserved_size: the size of reserved percpu area in bytes 1315 * @reserved_size: the size of reserved percpu area in bytes
995 * @dyn_size: free size for dynamic allocation in bytes, -1 for auto 1316 * @dyn_size: free size for dynamic allocation in bytes, -1 for auto
996 * @unit_size: unit size in bytes, must be multiple of PAGE_SIZE, -1 for auto 1317 * @atom_size: allocation atom size
997 * @base_addr: mapped address, NULL for auto 1318 * @cpu_distance_fn: callback to determine distance between cpus, optional
998 * @populate_pte_fn: callback to allocate pagetable, NULL if unnecessary 1319 *
1320 * This function determines grouping of units, their mappings to cpus
1321 * and other parameters considering needed percpu size, allocation
1322 * atom size and distances between CPUs.
1323 *
1324 * Groups are always mutliples of atom size and CPUs which are of
1325 * LOCAL_DISTANCE both ways are grouped together and share space for
1326 * units in the same group. The returned configuration is guaranteed
1327 * to have CPUs on different nodes on different groups and >=75% usage
1328 * of allocated virtual address space.
1329 *
1330 * RETURNS:
1331 * On success, pointer to the new allocation_info is returned. On
1332 * failure, ERR_PTR value is returned.
1333 */
1334struct pcpu_alloc_info * __init pcpu_build_alloc_info(
1335 size_t reserved_size, ssize_t dyn_size,
1336 size_t atom_size,
1337 pcpu_fc_cpu_distance_fn_t cpu_distance_fn)
1338{
1339 static int group_map[NR_CPUS] __initdata;
1340 static int group_cnt[NR_CPUS] __initdata;
1341 const size_t static_size = __per_cpu_end - __per_cpu_start;
1342 int group_cnt_max = 0, nr_groups = 1, nr_units = 0;
1343 size_t size_sum, min_unit_size, alloc_size;
1344 int upa, max_upa, uninitialized_var(best_upa); /* units_per_alloc */
1345 int last_allocs, group, unit;
1346 unsigned int cpu, tcpu;
1347 struct pcpu_alloc_info *ai;
1348 unsigned int *cpu_map;
1349
1350 /*
1351 * Determine min_unit_size, alloc_size and max_upa such that
1352 * alloc_size is multiple of atom_size and is the smallest
1353 * which can accomodate 4k aligned segments which are equal to
1354 * or larger than min_unit_size.
1355 */
1356 size_sum = pcpu_calc_fc_sizes(static_size, reserved_size, &dyn_size);
1357 min_unit_size = max_t(size_t, size_sum, PCPU_MIN_UNIT_SIZE);
1358
1359 alloc_size = roundup(min_unit_size, atom_size);
1360 upa = alloc_size / min_unit_size;
1361 while (alloc_size % upa || ((alloc_size / upa) & ~PAGE_MASK))
1362 upa--;
1363 max_upa = upa;
1364
1365 /* group cpus according to their proximity */
1366 for_each_possible_cpu(cpu) {
1367 group = 0;
1368 next_group:
1369 for_each_possible_cpu(tcpu) {
1370 if (cpu == tcpu)
1371 break;
1372 if (group_map[tcpu] == group && cpu_distance_fn &&
1373 (cpu_distance_fn(cpu, tcpu) > LOCAL_DISTANCE ||
1374 cpu_distance_fn(tcpu, cpu) > LOCAL_DISTANCE)) {
1375 group++;
1376 nr_groups = max(nr_groups, group + 1);
1377 goto next_group;
1378 }
1379 }
1380 group_map[cpu] = group;
1381 group_cnt[group]++;
1382 group_cnt_max = max(group_cnt_max, group_cnt[group]);
1383 }
1384
1385 /*
1386 * Expand unit size until address space usage goes over 75%
1387 * and then as much as possible without using more address
1388 * space.
1389 */
1390 last_allocs = INT_MAX;
1391 for (upa = max_upa; upa; upa--) {
1392 int allocs = 0, wasted = 0;
1393
1394 if (alloc_size % upa || ((alloc_size / upa) & ~PAGE_MASK))
1395 continue;
1396
1397 for (group = 0; group < nr_groups; group++) {
1398 int this_allocs = DIV_ROUND_UP(group_cnt[group], upa);
1399 allocs += this_allocs;
1400 wasted += this_allocs * upa - group_cnt[group];
1401 }
1402
1403 /*
1404 * Don't accept if wastage is over 25%. The
1405 * greater-than comparison ensures upa==1 always
1406 * passes the following check.
1407 */
1408 if (wasted > num_possible_cpus() / 3)
1409 continue;
1410
1411 /* and then don't consume more memory */
1412 if (allocs > last_allocs)
1413 break;
1414 last_allocs = allocs;
1415 best_upa = upa;
1416 }
1417 upa = best_upa;
1418
1419 /* allocate and fill alloc_info */
1420 for (group = 0; group < nr_groups; group++)
1421 nr_units += roundup(group_cnt[group], upa);
1422
1423 ai = pcpu_alloc_alloc_info(nr_groups, nr_units);
1424 if (!ai)
1425 return ERR_PTR(-ENOMEM);
1426 cpu_map = ai->groups[0].cpu_map;
1427
1428 for (group = 0; group < nr_groups; group++) {
1429 ai->groups[group].cpu_map = cpu_map;
1430 cpu_map += roundup(group_cnt[group], upa);
1431 }
1432
1433 ai->static_size = static_size;
1434 ai->reserved_size = reserved_size;
1435 ai->dyn_size = dyn_size;
1436 ai->unit_size = alloc_size / upa;
1437 ai->atom_size = atom_size;
1438 ai->alloc_size = alloc_size;
1439
1440 for (group = 0, unit = 0; group_cnt[group]; group++) {
1441 struct pcpu_group_info *gi = &ai->groups[group];
1442
1443 /*
1444 * Initialize base_offset as if all groups are located
1445 * back-to-back. The caller should update this to
1446 * reflect actual allocation.
1447 */
1448 gi->base_offset = unit * ai->unit_size;
1449
1450 for_each_possible_cpu(cpu)
1451 if (group_map[cpu] == group)
1452 gi->cpu_map[gi->nr_units++] = cpu;
1453 gi->nr_units = roundup(gi->nr_units, upa);
1454 unit += gi->nr_units;
1455 }
1456 BUG_ON(unit != nr_units);
1457
1458 return ai;
1459}
1460
1461/**
1462 * pcpu_dump_alloc_info - print out information about pcpu_alloc_info
1463 * @lvl: loglevel
1464 * @ai: allocation info to dump
1465 *
1466 * Print out information about @ai using loglevel @lvl.
1467 */
1468static void pcpu_dump_alloc_info(const char *lvl,
1469 const struct pcpu_alloc_info *ai)
1470{
1471 int group_width = 1, cpu_width = 1, width;
1472 char empty_str[] = "--------";
1473 int alloc = 0, alloc_end = 0;
1474 int group, v;
1475 int upa, apl; /* units per alloc, allocs per line */
1476
1477 v = ai->nr_groups;
1478 while (v /= 10)
1479 group_width++;
1480
1481 v = num_possible_cpus();
1482 while (v /= 10)
1483 cpu_width++;
1484 empty_str[min_t(int, cpu_width, sizeof(empty_str) - 1)] = '\0';
1485
1486 upa = ai->alloc_size / ai->unit_size;
1487 width = upa * (cpu_width + 1) + group_width + 3;
1488 apl = rounddown_pow_of_two(max(60 / width, 1));
1489
1490 printk("%spcpu-alloc: s%zu r%zu d%zu u%zu alloc=%zu*%zu",
1491 lvl, ai->static_size, ai->reserved_size, ai->dyn_size,
1492 ai->unit_size, ai->alloc_size / ai->atom_size, ai->atom_size);
1493
1494 for (group = 0; group < ai->nr_groups; group++) {
1495 const struct pcpu_group_info *gi = &ai->groups[group];
1496 int unit = 0, unit_end = 0;
1497
1498 BUG_ON(gi->nr_units % upa);
1499 for (alloc_end += gi->nr_units / upa;
1500 alloc < alloc_end; alloc++) {
1501 if (!(alloc % apl)) {
1502 printk("\n");
1503 printk("%spcpu-alloc: ", lvl);
1504 }
1505 printk("[%0*d] ", group_width, group);
1506
1507 for (unit_end += upa; unit < unit_end; unit++)
1508 if (gi->cpu_map[unit] != NR_CPUS)
1509 printk("%0*d ", cpu_width,
1510 gi->cpu_map[unit]);
1511 else
1512 printk("%s ", empty_str);
1513 }
1514 }
1515 printk("\n");
1516}
1517
1518/**
1519 * pcpu_setup_first_chunk - initialize the first percpu chunk
1520 * @ai: pcpu_alloc_info describing how to percpu area is shaped
1521 * @base_addr: mapped address
999 * 1522 *
1000 * Initialize the first percpu chunk which contains the kernel static 1523 * Initialize the first percpu chunk which contains the kernel static
1001 * perpcu area. This function is to be called from arch percpu area 1524 * perpcu area. This function is to be called from arch percpu area
1002 * setup path. The first two parameters are mandatory. The rest are 1525 * setup path.
1003 * optional. 1526 *
1004 * 1527 * @ai contains all information necessary to initialize the first
1005 * @get_page_fn() should return pointer to percpu page given cpu 1528 * chunk and prime the dynamic percpu allocator.
1006 * number and page number. It should at least return enough pages to 1529 *
1007 * cover the static area. The returned pages for static area should 1530 * @ai->static_size is the size of static percpu area.
1008 * have been initialized with valid data. If @unit_size is specified, 1531 *
1009 * it can also return pages after the static area. NULL return 1532 * @ai->reserved_size, if non-zero, specifies the amount of bytes to
1010 * indicates end of pages for the cpu. Note that @get_page_fn() must
1011 * return the same number of pages for all cpus.
1012 *
1013 * @reserved_size, if non-zero, specifies the amount of bytes to
1014 * reserve after the static area in the first chunk. This reserves 1533 * reserve after the static area in the first chunk. This reserves
1015 * the first chunk such that it's available only through reserved 1534 * the first chunk such that it's available only through reserved
1016 * percpu allocation. This is primarily used to serve module percpu 1535 * percpu allocation. This is primarily used to serve module percpu
@@ -1018,22 +1537,29 @@ EXPORT_SYMBOL_GPL(free_percpu);
1018 * limited offset range for symbol relocations to guarantee module 1537 * limited offset range for symbol relocations to guarantee module
1019 * percpu symbols fall inside the relocatable range. 1538 * percpu symbols fall inside the relocatable range.
1020 * 1539 *
1021 * @dyn_size, if non-negative, determines the number of bytes 1540 * @ai->dyn_size determines the number of bytes available for dynamic
1022 * available for dynamic allocation in the first chunk. Specifying 1541 * allocation in the first chunk. The area between @ai->static_size +
1023 * non-negative value makes percpu leave alone the area beyond 1542 * @ai->reserved_size + @ai->dyn_size and @ai->unit_size is unused.
1024 * @static_size + @reserved_size + @dyn_size.
1025 * 1543 *
1026 * @unit_size, if non-negative, specifies unit size and must be 1544 * @ai->unit_size specifies unit size and must be aligned to PAGE_SIZE
1027 * aligned to PAGE_SIZE and equal to or larger than @static_size + 1545 * and equal to or larger than @ai->static_size + @ai->reserved_size +
1028 * @reserved_size + if non-negative, @dyn_size. 1546 * @ai->dyn_size.
1029 * 1547 *
1030 * Non-null @base_addr means that the caller already allocated virtual 1548 * @ai->atom_size is the allocation atom size and used as alignment
1031 * region for the first chunk and mapped it. percpu must not mess 1549 * for vm areas.
1032 * with the chunk. Note that @base_addr with 0 @unit_size or non-NULL
1033 * @populate_pte_fn doesn't make any sense.
1034 * 1550 *
1035 * @populate_pte_fn is used to populate the pagetable. NULL means the 1551 * @ai->alloc_size is the allocation size and always multiple of
1036 * caller already populated the pagetable. 1552 * @ai->atom_size. This is larger than @ai->atom_size if
1553 * @ai->unit_size is larger than @ai->atom_size.
1554 *
1555 * @ai->nr_groups and @ai->groups describe virtual memory layout of
1556 * percpu areas. Units which should be colocated are put into the
1557 * same group. Dynamic VM areas will be allocated according to these
1558 * groupings. If @ai->nr_groups is zero, a single group containing
1559 * all units is assumed.
1560 *
1561 * The caller should have mapped the first chunk at @base_addr and
1562 * copied static data to each unit.
1037 * 1563 *
1038 * If the first chunk ends up with both reserved and dynamic areas, it 1564 * If the first chunk ends up with both reserved and dynamic areas, it
1039 * is served by two chunks - one to serve the core static and reserved 1565 * is served by two chunks - one to serve the core static and reserved
@@ -1043,49 +1569,83 @@ EXPORT_SYMBOL_GPL(free_percpu);
1043 * and available for dynamic allocation like any other chunks. 1569 * and available for dynamic allocation like any other chunks.
1044 * 1570 *
1045 * RETURNS: 1571 * RETURNS:
1046 * The determined pcpu_unit_size which can be used to initialize 1572 * 0 on success, -errno on failure.
1047 * percpu access.
1048 */ 1573 */
1049size_t __init pcpu_setup_first_chunk(pcpu_get_page_fn_t get_page_fn, 1574int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
1050 size_t static_size, size_t reserved_size, 1575 void *base_addr)
1051 ssize_t dyn_size, ssize_t unit_size,
1052 void *base_addr,
1053 pcpu_populate_pte_fn_t populate_pte_fn)
1054{ 1576{
1055 static struct vm_struct first_vm;
1056 static int smap[2], dmap[2]; 1577 static int smap[2], dmap[2];
1057 size_t size_sum = static_size + reserved_size + 1578 size_t dyn_size = ai->dyn_size;
1058 (dyn_size >= 0 ? dyn_size : 0); 1579 size_t size_sum = ai->static_size + ai->reserved_size + dyn_size;
1059 struct pcpu_chunk *schunk, *dchunk = NULL; 1580 struct pcpu_chunk *schunk, *dchunk = NULL;
1581 unsigned long *group_offsets;
1582 size_t *group_sizes;
1583 unsigned long *unit_off;
1060 unsigned int cpu; 1584 unsigned int cpu;
1061 int nr_pages; 1585 int *unit_map;
1062 int err, i; 1586 int group, unit, i;
1063 1587
1064 /* santiy checks */ 1588 /* sanity checks */
1065 BUILD_BUG_ON(ARRAY_SIZE(smap) >= PCPU_DFL_MAP_ALLOC || 1589 BUILD_BUG_ON(ARRAY_SIZE(smap) >= PCPU_DFL_MAP_ALLOC ||
1066 ARRAY_SIZE(dmap) >= PCPU_DFL_MAP_ALLOC); 1590 ARRAY_SIZE(dmap) >= PCPU_DFL_MAP_ALLOC);
1067 BUG_ON(!static_size); 1591 BUG_ON(ai->nr_groups <= 0);
1068 if (unit_size >= 0) { 1592 BUG_ON(!ai->static_size);
1069 BUG_ON(unit_size < size_sum); 1593 BUG_ON(!base_addr);
1070 BUG_ON(unit_size & ~PAGE_MASK); 1594 BUG_ON(ai->unit_size < size_sum);
1071 BUG_ON(unit_size < PCPU_MIN_UNIT_SIZE); 1595 BUG_ON(ai->unit_size & ~PAGE_MASK);
1072 } else 1596 BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE);
1073 BUG_ON(base_addr); 1597
1074 BUG_ON(base_addr && populate_pte_fn); 1598 pcpu_dump_alloc_info(KERN_DEBUG, ai);
1075 1599
1076 if (unit_size >= 0) 1600 /* process group information and build config tables accordingly */
1077 pcpu_unit_pages = unit_size >> PAGE_SHIFT; 1601 group_offsets = alloc_bootmem(ai->nr_groups * sizeof(group_offsets[0]));
1078 else 1602 group_sizes = alloc_bootmem(ai->nr_groups * sizeof(group_sizes[0]));
1079 pcpu_unit_pages = max_t(int, PCPU_MIN_UNIT_SIZE >> PAGE_SHIFT, 1603 unit_map = alloc_bootmem(nr_cpu_ids * sizeof(unit_map[0]));
1080 PFN_UP(size_sum)); 1604 unit_off = alloc_bootmem(nr_cpu_ids * sizeof(unit_off[0]));
1605
1606 for (cpu = 0; cpu < nr_cpu_ids; cpu++)
1607 unit_map[cpu] = NR_CPUS;
1608 pcpu_first_unit_cpu = NR_CPUS;
1609
1610 for (group = 0, unit = 0; group < ai->nr_groups; group++, unit += i) {
1611 const struct pcpu_group_info *gi = &ai->groups[group];
1612
1613 group_offsets[group] = gi->base_offset;
1614 group_sizes[group] = gi->nr_units * ai->unit_size;
1615
1616 for (i = 0; i < gi->nr_units; i++) {
1617 cpu = gi->cpu_map[i];
1618 if (cpu == NR_CPUS)
1619 continue;
1081 1620
1082 pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT; 1621 BUG_ON(cpu > nr_cpu_ids || !cpu_possible(cpu));
1083 pcpu_chunk_size = nr_cpu_ids * pcpu_unit_size; 1622 BUG_ON(unit_map[cpu] != NR_CPUS);
1084 pcpu_chunk_struct_size = sizeof(struct pcpu_chunk)
1085 + nr_cpu_ids * pcpu_unit_pages * sizeof(struct page *);
1086 1623
1087 if (dyn_size < 0) 1624 unit_map[cpu] = unit + i;
1088 dyn_size = pcpu_unit_size - static_size - reserved_size; 1625 unit_off[cpu] = gi->base_offset + i * ai->unit_size;
1626
1627 if (pcpu_first_unit_cpu == NR_CPUS)
1628 pcpu_first_unit_cpu = cpu;
1629 }
1630 }
1631 pcpu_last_unit_cpu = cpu;
1632 pcpu_nr_units = unit;
1633
1634 for_each_possible_cpu(cpu)
1635 BUG_ON(unit_map[cpu] == NR_CPUS);
1636
1637 pcpu_nr_groups = ai->nr_groups;
1638 pcpu_group_offsets = group_offsets;
1639 pcpu_group_sizes = group_sizes;
1640 pcpu_unit_map = unit_map;
1641 pcpu_unit_offsets = unit_off;
1642
1643 /* determine basic parameters */
1644 pcpu_unit_pages = ai->unit_size >> PAGE_SHIFT;
1645 pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT;
1646 pcpu_atom_size = ai->atom_size;
1647 pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) +
1648 BITS_TO_LONGS(pcpu_unit_pages) * sizeof(unsigned long);
1089 1649
1090 /* 1650 /*
1091 * Allocate chunk slots. The additional last slot is for 1651 * Allocate chunk slots. The additional last slot is for
@@ -1105,189 +1665,351 @@ size_t __init pcpu_setup_first_chunk(pcpu_get_page_fn_t get_page_fn,
1105 */ 1665 */
1106 schunk = alloc_bootmem(pcpu_chunk_struct_size); 1666 schunk = alloc_bootmem(pcpu_chunk_struct_size);
1107 INIT_LIST_HEAD(&schunk->list); 1667 INIT_LIST_HEAD(&schunk->list);
1108 schunk->vm = &first_vm; 1668 schunk->base_addr = base_addr;
1109 schunk->map = smap; 1669 schunk->map = smap;
1110 schunk->map_alloc = ARRAY_SIZE(smap); 1670 schunk->map_alloc = ARRAY_SIZE(smap);
1111 schunk->page = schunk->page_ar; 1671 schunk->immutable = true;
1672 bitmap_fill(schunk->populated, pcpu_unit_pages);
1112 1673
1113 if (reserved_size) { 1674 if (ai->reserved_size) {
1114 schunk->free_size = reserved_size; 1675 schunk->free_size = ai->reserved_size;
1115 pcpu_reserved_chunk = schunk; 1676 pcpu_reserved_chunk = schunk;
1116 pcpu_reserved_chunk_limit = static_size + reserved_size; 1677 pcpu_reserved_chunk_limit = ai->static_size + ai->reserved_size;
1117 } else { 1678 } else {
1118 schunk->free_size = dyn_size; 1679 schunk->free_size = dyn_size;
1119 dyn_size = 0; /* dynamic area covered */ 1680 dyn_size = 0; /* dynamic area covered */
1120 } 1681 }
1121 schunk->contig_hint = schunk->free_size; 1682 schunk->contig_hint = schunk->free_size;
1122 1683
1123 schunk->map[schunk->map_used++] = -static_size; 1684 schunk->map[schunk->map_used++] = -ai->static_size;
1124 if (schunk->free_size) 1685 if (schunk->free_size)
1125 schunk->map[schunk->map_used++] = schunk->free_size; 1686 schunk->map[schunk->map_used++] = schunk->free_size;
1126 1687
1127 /* init dynamic chunk if necessary */ 1688 /* init dynamic chunk if necessary */
1128 if (dyn_size) { 1689 if (dyn_size) {
1129 dchunk = alloc_bootmem(sizeof(struct pcpu_chunk)); 1690 dchunk = alloc_bootmem(pcpu_chunk_struct_size);
1130 INIT_LIST_HEAD(&dchunk->list); 1691 INIT_LIST_HEAD(&dchunk->list);
1131 dchunk->vm = &first_vm; 1692 dchunk->base_addr = base_addr;
1132 dchunk->map = dmap; 1693 dchunk->map = dmap;
1133 dchunk->map_alloc = ARRAY_SIZE(dmap); 1694 dchunk->map_alloc = ARRAY_SIZE(dmap);
1134 dchunk->page = schunk->page_ar; /* share page map with schunk */ 1695 dchunk->immutable = true;
1696 bitmap_fill(dchunk->populated, pcpu_unit_pages);
1135 1697
1136 dchunk->contig_hint = dchunk->free_size = dyn_size; 1698 dchunk->contig_hint = dchunk->free_size = dyn_size;
1137 dchunk->map[dchunk->map_used++] = -pcpu_reserved_chunk_limit; 1699 dchunk->map[dchunk->map_used++] = -pcpu_reserved_chunk_limit;
1138 dchunk->map[dchunk->map_used++] = dchunk->free_size; 1700 dchunk->map[dchunk->map_used++] = dchunk->free_size;
1139 } 1701 }
1140 1702
1141 /* allocate vm address */
1142 first_vm.flags = VM_ALLOC;
1143 first_vm.size = pcpu_chunk_size;
1144
1145 if (!base_addr)
1146 vm_area_register_early(&first_vm, PAGE_SIZE);
1147 else {
1148 /*
1149 * Pages already mapped. No need to remap into
1150 * vmalloc area. In this case the first chunks can't
1151 * be mapped or unmapped by percpu and are marked
1152 * immutable.
1153 */
1154 first_vm.addr = base_addr;
1155 schunk->immutable = true;
1156 if (dchunk)
1157 dchunk->immutable = true;
1158 }
1159
1160 /* assign pages */
1161 nr_pages = -1;
1162 for_each_possible_cpu(cpu) {
1163 for (i = 0; i < pcpu_unit_pages; i++) {
1164 struct page *page = get_page_fn(cpu, i);
1165
1166 if (!page)
1167 break;
1168 *pcpu_chunk_pagep(schunk, cpu, i) = page;
1169 }
1170
1171 BUG_ON(i < PFN_UP(static_size));
1172
1173 if (nr_pages < 0)
1174 nr_pages = i;
1175 else
1176 BUG_ON(nr_pages != i);
1177 }
1178
1179 /* map them */
1180 if (populate_pte_fn) {
1181 for_each_possible_cpu(cpu)
1182 for (i = 0; i < nr_pages; i++)
1183 populate_pte_fn(pcpu_chunk_addr(schunk,
1184 cpu, i));
1185
1186 err = pcpu_map(schunk, 0, nr_pages);
1187 if (err)
1188 panic("failed to setup static percpu area, err=%d\n",
1189 err);
1190 }
1191
1192 /* link the first chunk in */ 1703 /* link the first chunk in */
1193 pcpu_first_chunk = dchunk ?: schunk; 1704 pcpu_first_chunk = dchunk ?: schunk;
1194 pcpu_chunk_relocate(pcpu_first_chunk, -1); 1705 pcpu_chunk_relocate(pcpu_first_chunk, -1);
1195 1706
1196 /* we're done */ 1707 /* we're done */
1197 pcpu_base_addr = (void *)pcpu_chunk_addr(schunk, 0, 0); 1708 pcpu_base_addr = base_addr;
1198 return pcpu_unit_size; 1709 return 0;
1199} 1710}
1200 1711
1201/* 1712const char *pcpu_fc_names[PCPU_FC_NR] __initdata = {
1202 * Embedding first chunk setup helper. 1713 [PCPU_FC_AUTO] = "auto",
1203 */ 1714 [PCPU_FC_EMBED] = "embed",
1204static void *pcpue_ptr __initdata; 1715 [PCPU_FC_PAGE] = "page",
1205static size_t pcpue_size __initdata; 1716};
1206static size_t pcpue_unit_size __initdata;
1207 1717
1208static struct page * __init pcpue_get_page(unsigned int cpu, int pageno) 1718enum pcpu_fc pcpu_chosen_fc __initdata = PCPU_FC_AUTO;
1209{
1210 size_t off = (size_t)pageno << PAGE_SHIFT;
1211 1719
1212 if (off >= pcpue_size) 1720static int __init percpu_alloc_setup(char *str)
1213 return NULL; 1721{
1722 if (0)
1723 /* nada */;
1724#ifdef CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK
1725 else if (!strcmp(str, "embed"))
1726 pcpu_chosen_fc = PCPU_FC_EMBED;
1727#endif
1728#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
1729 else if (!strcmp(str, "page"))
1730 pcpu_chosen_fc = PCPU_FC_PAGE;
1731#endif
1732 else
1733 pr_warning("PERCPU: unknown allocator %s specified\n", str);
1214 1734
1215 return virt_to_page(pcpue_ptr + cpu * pcpue_unit_size + off); 1735 return 0;
1216} 1736}
1737early_param("percpu_alloc", percpu_alloc_setup);
1217 1738
1739#if defined(CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK) || \
1740 !defined(CONFIG_HAVE_SETUP_PER_CPU_AREA)
1218/** 1741/**
1219 * pcpu_embed_first_chunk - embed the first percpu chunk into bootmem 1742 * pcpu_embed_first_chunk - embed the first percpu chunk into bootmem
1220 * @static_size: the size of static percpu area in bytes
1221 * @reserved_size: the size of reserved percpu area in bytes 1743 * @reserved_size: the size of reserved percpu area in bytes
1222 * @dyn_size: free size for dynamic allocation in bytes, -1 for auto 1744 * @dyn_size: free size for dynamic allocation in bytes, -1 for auto
1223 * @unit_size: unit size in bytes, must be multiple of PAGE_SIZE, -1 for auto 1745 * @atom_size: allocation atom size
1746 * @cpu_distance_fn: callback to determine distance between cpus, optional
1747 * @alloc_fn: function to allocate percpu page
1748 * @free_fn: funtion to free percpu page
1224 * 1749 *
1225 * This is a helper to ease setting up embedded first percpu chunk and 1750 * This is a helper to ease setting up embedded first percpu chunk and
1226 * can be called where pcpu_setup_first_chunk() is expected. 1751 * can be called where pcpu_setup_first_chunk() is expected.
1227 * 1752 *
1228 * If this function is used to setup the first chunk, it is allocated 1753 * If this function is used to setup the first chunk, it is allocated
1229 * as a contiguous area using bootmem allocator and used as-is without 1754 * by calling @alloc_fn and used as-is without being mapped into
1230 * being mapped into vmalloc area. This enables the first chunk to 1755 * vmalloc area. Allocations are always whole multiples of @atom_size
1231 * piggy back on the linear physical mapping which often uses larger 1756 * aligned to @atom_size.
1232 * page size. 1757 *
1758 * This enables the first chunk to piggy back on the linear physical
1759 * mapping which often uses larger page size. Please note that this
1760 * can result in very sparse cpu->unit mapping on NUMA machines thus
1761 * requiring large vmalloc address space. Don't use this allocator if
1762 * vmalloc space is not orders of magnitude larger than distances
1763 * between node memory addresses (ie. 32bit NUMA machines).
1233 * 1764 *
1234 * When @dyn_size is positive, dynamic area might be larger than 1765 * When @dyn_size is positive, dynamic area might be larger than
1235 * specified to fill page alignment. Also, when @dyn_size is auto, 1766 * specified to fill page alignment. When @dyn_size is auto,
1236 * @dyn_size does not fill the whole first chunk but only what's 1767 * @dyn_size is just big enough to fill page alignment after static
1237 * necessary for page alignment after static and reserved areas. 1768 * and reserved areas.
1238 * 1769 *
1239 * If the needed size is smaller than the minimum or specified unit 1770 * If the needed size is smaller than the minimum or specified unit
1240 * size, the leftover is returned to the bootmem allocator. 1771 * size, the leftover is returned using @free_fn.
1241 * 1772 *
1242 * RETURNS: 1773 * RETURNS:
1243 * The determined pcpu_unit_size which can be used to initialize 1774 * 0 on success, -errno on failure.
1244 * percpu access on success, -errno on failure.
1245 */ 1775 */
1246ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size, 1776int __init pcpu_embed_first_chunk(size_t reserved_size, ssize_t dyn_size,
1247 ssize_t dyn_size, ssize_t unit_size) 1777 size_t atom_size,
1778 pcpu_fc_cpu_distance_fn_t cpu_distance_fn,
1779 pcpu_fc_alloc_fn_t alloc_fn,
1780 pcpu_fc_free_fn_t free_fn)
1248{ 1781{
1249 size_t chunk_size; 1782 void *base = (void *)ULONG_MAX;
1250 unsigned int cpu; 1783 void **areas = NULL;
1784 struct pcpu_alloc_info *ai;
1785 size_t size_sum, areas_size;
1786 int group, i, rc;
1787
1788 ai = pcpu_build_alloc_info(reserved_size, dyn_size, atom_size,
1789 cpu_distance_fn);
1790 if (IS_ERR(ai))
1791 return PTR_ERR(ai);
1792
1793 size_sum = ai->static_size + ai->reserved_size + ai->dyn_size;
1794 areas_size = PFN_ALIGN(ai->nr_groups * sizeof(void *));
1795
1796 areas = alloc_bootmem_nopanic(areas_size);
1797 if (!areas) {
1798 rc = -ENOMEM;
1799 goto out_free;
1800 }
1251 1801
1252 /* determine parameters and allocate */ 1802 /* allocate, copy and determine base address */
1253 pcpue_size = PFN_ALIGN(static_size + reserved_size + 1803 for (group = 0; group < ai->nr_groups; group++) {
1254 (dyn_size >= 0 ? dyn_size : 0)); 1804 struct pcpu_group_info *gi = &ai->groups[group];
1255 if (dyn_size != 0) 1805 unsigned int cpu = NR_CPUS;
1256 dyn_size = pcpue_size - static_size - reserved_size; 1806 void *ptr;
1257 1807
1258 if (unit_size >= 0) { 1808 for (i = 0; i < gi->nr_units && cpu == NR_CPUS; i++)
1259 BUG_ON(unit_size < pcpue_size); 1809 cpu = gi->cpu_map[i];
1260 pcpue_unit_size = unit_size; 1810 BUG_ON(cpu == NR_CPUS);
1261 } else 1811
1262 pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE); 1812 /* allocate space for the whole group */
1263 1813 ptr = alloc_fn(cpu, gi->nr_units * ai->unit_size, atom_size);
1264 chunk_size = pcpue_unit_size * nr_cpu_ids; 1814 if (!ptr) {
1265 1815 rc = -ENOMEM;
1266 pcpue_ptr = __alloc_bootmem_nopanic(chunk_size, PAGE_SIZE, 1816 goto out_free_areas;
1267 __pa(MAX_DMA_ADDRESS)); 1817 }
1268 if (!pcpue_ptr) { 1818 areas[group] = ptr;
1269 pr_warning("PERCPU: failed to allocate %zu bytes for " 1819
1270 "embedding\n", chunk_size); 1820 base = min(ptr, base);
1271 return -ENOMEM; 1821
1822 for (i = 0; i < gi->nr_units; i++, ptr += ai->unit_size) {
1823 if (gi->cpu_map[i] == NR_CPUS) {
1824 /* unused unit, free whole */
1825 free_fn(ptr, ai->unit_size);
1826 continue;
1827 }
1828 /* copy and return the unused part */
1829 memcpy(ptr, __per_cpu_load, ai->static_size);
1830 free_fn(ptr + size_sum, ai->unit_size - size_sum);
1831 }
1272 } 1832 }
1273 1833
1274 /* return the leftover and copy */ 1834 /* base address is now known, determine group base offsets */
1275 for (cpu = 0; cpu < nr_cpu_ids; cpu++) { 1835 for (group = 0; group < ai->nr_groups; group++)
1276 void *ptr = pcpue_ptr + cpu * pcpue_unit_size; 1836 ai->groups[group].base_offset = areas[group] - base;
1837
1838 pr_info("PERCPU: Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n",
1839 PFN_DOWN(size_sum), base, ai->static_size, ai->reserved_size,
1840 ai->dyn_size, ai->unit_size);
1841
1842 rc = pcpu_setup_first_chunk(ai, base);
1843 goto out_free;
1844
1845out_free_areas:
1846 for (group = 0; group < ai->nr_groups; group++)
1847 free_fn(areas[group],
1848 ai->groups[group].nr_units * ai->unit_size);
1849out_free:
1850 pcpu_free_alloc_info(ai);
1851 if (areas)
1852 free_bootmem(__pa(areas), areas_size);
1853 return rc;
1854}
1855#endif /* CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK ||
1856 !CONFIG_HAVE_SETUP_PER_CPU_AREA */
1857
1858#ifdef CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK
1859/**
1860 * pcpu_page_first_chunk - map the first chunk using PAGE_SIZE pages
1861 * @reserved_size: the size of reserved percpu area in bytes
1862 * @alloc_fn: function to allocate percpu page, always called with PAGE_SIZE
1863 * @free_fn: funtion to free percpu page, always called with PAGE_SIZE
1864 * @populate_pte_fn: function to populate pte
1865 *
1866 * This is a helper to ease setting up page-remapped first percpu
1867 * chunk and can be called where pcpu_setup_first_chunk() is expected.
1868 *
1869 * This is the basic allocator. Static percpu area is allocated
1870 * page-by-page into vmalloc area.
1871 *
1872 * RETURNS:
1873 * 0 on success, -errno on failure.
1874 */
1875int __init pcpu_page_first_chunk(size_t reserved_size,
1876 pcpu_fc_alloc_fn_t alloc_fn,
1877 pcpu_fc_free_fn_t free_fn,
1878 pcpu_fc_populate_pte_fn_t populate_pte_fn)
1879{
1880 static struct vm_struct vm;
1881 struct pcpu_alloc_info *ai;
1882 char psize_str[16];
1883 int unit_pages;
1884 size_t pages_size;
1885 struct page **pages;
1886 int unit, i, j, rc;
1887
1888 snprintf(psize_str, sizeof(psize_str), "%luK", PAGE_SIZE >> 10);
1889
1890 ai = pcpu_build_alloc_info(reserved_size, -1, PAGE_SIZE, NULL);
1891 if (IS_ERR(ai))
1892 return PTR_ERR(ai);
1893 BUG_ON(ai->nr_groups != 1);
1894 BUG_ON(ai->groups[0].nr_units != num_possible_cpus());
1895
1896 unit_pages = ai->unit_size >> PAGE_SHIFT;
1897
1898 /* unaligned allocations can't be freed, round up to page size */
1899 pages_size = PFN_ALIGN(unit_pages * num_possible_cpus() *
1900 sizeof(pages[0]));
1901 pages = alloc_bootmem(pages_size);
1902
1903 /* allocate pages */
1904 j = 0;
1905 for (unit = 0; unit < num_possible_cpus(); unit++)
1906 for (i = 0; i < unit_pages; i++) {
1907 unsigned int cpu = ai->groups[0].cpu_map[unit];
1908 void *ptr;
1909
1910 ptr = alloc_fn(cpu, PAGE_SIZE, PAGE_SIZE);
1911 if (!ptr) {
1912 pr_warning("PERCPU: failed to allocate %s page "
1913 "for cpu%u\n", psize_str, cpu);
1914 goto enomem;
1915 }
1916 pages[j++] = virt_to_page(ptr);
1917 }
1918
1919 /* allocate vm area, map the pages and copy static data */
1920 vm.flags = VM_ALLOC;
1921 vm.size = num_possible_cpus() * ai->unit_size;
1922 vm_area_register_early(&vm, PAGE_SIZE);
1923
1924 for (unit = 0; unit < num_possible_cpus(); unit++) {
1925 unsigned long unit_addr =
1926 (unsigned long)vm.addr + unit * ai->unit_size;
1927
1928 for (i = 0; i < unit_pages; i++)
1929 populate_pte_fn(unit_addr + (i << PAGE_SHIFT));
1930
1931 /* pte already populated, the following shouldn't fail */
1932 rc = __pcpu_map_pages(unit_addr, &pages[unit * unit_pages],
1933 unit_pages);
1934 if (rc < 0)
1935 panic("failed to map percpu area, err=%d\n", rc);
1277 1936
1278 if (cpu_possible(cpu)) { 1937 /*
1279 free_bootmem(__pa(ptr + pcpue_size), 1938 * FIXME: Archs with virtual cache should flush local
1280 pcpue_unit_size - pcpue_size); 1939 * cache for the linear mapping here - something
1281 memcpy(ptr, __per_cpu_load, static_size); 1940 * equivalent to flush_cache_vmap() on the local cpu.
1282 } else 1941 * flush_cache_vmap() can't be used as most supporting
1283 free_bootmem(__pa(ptr), pcpue_unit_size); 1942 * data structures are not set up yet.
1943 */
1944
1945 /* copy static data */
1946 memcpy((void *)unit_addr, __per_cpu_load, ai->static_size);
1284 } 1947 }
1285 1948
1286 /* we're ready, commit */ 1949 /* we're ready, commit */
1287 pr_info("PERCPU: Embedded %zu pages at %p, static data %zu bytes\n", 1950 pr_info("PERCPU: %d %s pages/cpu @%p s%zu r%zu d%zu\n",
1288 pcpue_size >> PAGE_SHIFT, pcpue_ptr, static_size); 1951 unit_pages, psize_str, vm.addr, ai->static_size,
1952 ai->reserved_size, ai->dyn_size);
1953
1954 rc = pcpu_setup_first_chunk(ai, vm.addr);
1955 goto out_free_ar;
1956
1957enomem:
1958 while (--j >= 0)
1959 free_fn(page_address(pages[j]), PAGE_SIZE);
1960 rc = -ENOMEM;
1961out_free_ar:
1962 free_bootmem(__pa(pages), pages_size);
1963 pcpu_free_alloc_info(ai);
1964 return rc;
1965}
1966#endif /* CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK */
1967
1968/*
1969 * Generic percpu area setup.
1970 *
1971 * The embedding helper is used because its behavior closely resembles
1972 * the original non-dynamic generic percpu area setup. This is
1973 * important because many archs have addressing restrictions and might
1974 * fail if the percpu area is located far away from the previous
1975 * location. As an added bonus, in non-NUMA cases, embedding is
1976 * generally a good idea TLB-wise because percpu area can piggy back
1977 * on the physical linear memory mapping which uses large page
1978 * mappings on applicable archs.
1979 */
1980#ifndef CONFIG_HAVE_SETUP_PER_CPU_AREA
1981unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
1982EXPORT_SYMBOL(__per_cpu_offset);
1983
1984static void * __init pcpu_dfl_fc_alloc(unsigned int cpu, size_t size,
1985 size_t align)
1986{
1987 return __alloc_bootmem_nopanic(size, align, __pa(MAX_DMA_ADDRESS));
1988}
1289 1989
1290 return pcpu_setup_first_chunk(pcpue_get_page, static_size, 1990static void __init pcpu_dfl_fc_free(void *ptr, size_t size)
1291 reserved_size, dyn_size, 1991{
1292 pcpue_unit_size, pcpue_ptr, NULL); 1992 free_bootmem(__pa(ptr), size);
1993}
1994
1995void __init setup_per_cpu_areas(void)
1996{
1997 unsigned long delta;
1998 unsigned int cpu;
1999 int rc;
2000
2001 /*
2002 * Always reserve area for module percpu variables. That's
2003 * what the legacy allocator did.
2004 */
2005 rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
2006 PERCPU_DYNAMIC_RESERVE, PAGE_SIZE, NULL,
2007 pcpu_dfl_fc_alloc, pcpu_dfl_fc_free);
2008 if (rc < 0)
2009 panic("Failed to initialized percpu areas.");
2010
2011 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
2012 for_each_possible_cpu(cpu)
2013 __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu];
1293} 2014}
2015#endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */
diff --git a/mm/quicklist.c b/mm/quicklist.c
index e66d07d1b4ff..6eedf7e473d1 100644
--- a/mm/quicklist.c
+++ b/mm/quicklist.c
@@ -19,7 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/quicklist.h> 20#include <linux/quicklist.h>
21 21
22DEFINE_PER_CPU(struct quicklist, quicklist)[CONFIG_NR_QUICK]; 22DEFINE_PER_CPU(struct quicklist [CONFIG_NR_QUICK], quicklist);
23 23
24#define FRACTION_OF_NODE_MEM 16 24#define FRACTION_OF_NODE_MEM 16
25 25
diff --git a/mm/slub.c b/mm/slub.c
index 417ed843b251..0a216aae227e 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1071,6 +1071,8 @@ static inline unsigned long kmem_cache_flags(unsigned long objsize,
1071} 1071}
1072#define slub_debug 0 1072#define slub_debug 0
1073 1073
1074#define disable_higher_order_debug 0
1075
1074static inline unsigned long slabs_node(struct kmem_cache *s, int node) 1076static inline unsigned long slabs_node(struct kmem_cache *s, int node)
1075 { return 0; } 1077 { return 0; }
1076static inline unsigned long node_nr_slabs(struct kmem_cache_node *n) 1078static inline unsigned long node_nr_slabs(struct kmem_cache_node *n)
@@ -2111,8 +2113,8 @@ init_kmem_cache_node(struct kmem_cache_node *n, struct kmem_cache *s)
2111 */ 2113 */
2112#define NR_KMEM_CACHE_CPU 100 2114#define NR_KMEM_CACHE_CPU 100
2113 2115
2114static DEFINE_PER_CPU(struct kmem_cache_cpu, 2116static DEFINE_PER_CPU(struct kmem_cache_cpu [NR_KMEM_CACHE_CPU],
2115 kmem_cache_cpu)[NR_KMEM_CACHE_CPU]; 2117 kmem_cache_cpu);
2116 2118
2117static DEFINE_PER_CPU(struct kmem_cache_cpu *, kmem_cache_cpu_free); 2119static DEFINE_PER_CPU(struct kmem_cache_cpu *, kmem_cache_cpu_free);
2118static DECLARE_BITMAP(kmem_cach_cpu_free_init_once, CONFIG_NR_CPUS); 2120static DECLARE_BITMAP(kmem_cach_cpu_free_init_once, CONFIG_NR_CPUS);
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index f8189a4b3e13..204b8243d8ab 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -265,6 +265,7 @@ struct vmap_area {
265static DEFINE_SPINLOCK(vmap_area_lock); 265static DEFINE_SPINLOCK(vmap_area_lock);
266static struct rb_root vmap_area_root = RB_ROOT; 266static struct rb_root vmap_area_root = RB_ROOT;
267static LIST_HEAD(vmap_area_list); 267static LIST_HEAD(vmap_area_list);
268static unsigned long vmap_area_pcpu_hole;
268 269
269static struct vmap_area *__find_vmap_area(unsigned long addr) 270static struct vmap_area *__find_vmap_area(unsigned long addr)
270{ 271{
@@ -431,6 +432,15 @@ static void __free_vmap_area(struct vmap_area *va)
431 RB_CLEAR_NODE(&va->rb_node); 432 RB_CLEAR_NODE(&va->rb_node);
432 list_del_rcu(&va->list); 433 list_del_rcu(&va->list);
433 434
435 /*
436 * Track the highest possible candidate for pcpu area
437 * allocation. Areas outside of vmalloc area can be returned
438 * here too, consider only end addresses which fall inside
439 * vmalloc area proper.
440 */
441 if (va->va_end > VMALLOC_START && va->va_end <= VMALLOC_END)
442 vmap_area_pcpu_hole = max(vmap_area_pcpu_hole, va->va_end);
443
434 call_rcu(&va->rcu_head, rcu_free_va); 444 call_rcu(&va->rcu_head, rcu_free_va);
435} 445}
436 446
@@ -1038,6 +1048,9 @@ void __init vmalloc_init(void)
1038 va->va_end = va->va_start + tmp->size; 1048 va->va_end = va->va_start + tmp->size;
1039 __insert_vmap_area(va); 1049 __insert_vmap_area(va);
1040 } 1050 }
1051
1052 vmap_area_pcpu_hole = VMALLOC_END;
1053
1041 vmap_initialized = true; 1054 vmap_initialized = true;
1042} 1055}
1043 1056
@@ -1122,13 +1135,34 @@ EXPORT_SYMBOL_GPL(map_vm_area);
1122DEFINE_RWLOCK(vmlist_lock); 1135DEFINE_RWLOCK(vmlist_lock);
1123struct vm_struct *vmlist; 1136struct vm_struct *vmlist;
1124 1137
1138static void insert_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
1139 unsigned long flags, void *caller)
1140{
1141 struct vm_struct *tmp, **p;
1142
1143 vm->flags = flags;
1144 vm->addr = (void *)va->va_start;
1145 vm->size = va->va_end - va->va_start;
1146 vm->caller = caller;
1147 va->private = vm;
1148 va->flags |= VM_VM_AREA;
1149
1150 write_lock(&vmlist_lock);
1151 for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
1152 if (tmp->addr >= vm->addr)
1153 break;
1154 }
1155 vm->next = *p;
1156 *p = vm;
1157 write_unlock(&vmlist_lock);
1158}
1159
1125static struct vm_struct *__get_vm_area_node(unsigned long size, 1160static struct vm_struct *__get_vm_area_node(unsigned long size,
1126 unsigned long flags, unsigned long start, unsigned long end, 1161 unsigned long flags, unsigned long start, unsigned long end,
1127 int node, gfp_t gfp_mask, void *caller) 1162 int node, gfp_t gfp_mask, void *caller)
1128{ 1163{
1129 static struct vmap_area *va; 1164 static struct vmap_area *va;
1130 struct vm_struct *area; 1165 struct vm_struct *area;
1131 struct vm_struct *tmp, **p;
1132 unsigned long align = 1; 1166 unsigned long align = 1;
1133 1167
1134 BUG_ON(in_interrupt()); 1168 BUG_ON(in_interrupt());
@@ -1147,7 +1181,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
1147 if (unlikely(!size)) 1181 if (unlikely(!size))
1148 return NULL; 1182 return NULL;
1149 1183
1150 area = kmalloc_node(sizeof(*area), gfp_mask & GFP_RECLAIM_MASK, node); 1184 area = kzalloc_node(sizeof(*area), gfp_mask & GFP_RECLAIM_MASK, node);
1151 if (unlikely(!area)) 1185 if (unlikely(!area))
1152 return NULL; 1186 return NULL;
1153 1187
@@ -1162,25 +1196,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
1162 return NULL; 1196 return NULL;
1163 } 1197 }
1164 1198
1165 area->flags = flags; 1199 insert_vmalloc_vm(area, va, flags, caller);
1166 area->addr = (void *)va->va_start;
1167 area->size = size;
1168 area->pages = NULL;
1169 area->nr_pages = 0;
1170 area->phys_addr = 0;
1171 area->caller = caller;
1172 va->private = area;
1173 va->flags |= VM_VM_AREA;
1174
1175 write_lock(&vmlist_lock);
1176 for (p = &vmlist; (tmp = *p) != NULL; p = &tmp->next) {
1177 if (tmp->addr >= area->addr)
1178 break;
1179 }
1180 area->next = *p;
1181 *p = area;
1182 write_unlock(&vmlist_lock);
1183
1184 return area; 1200 return area;
1185} 1201}
1186 1202
@@ -1818,6 +1834,286 @@ void free_vm_area(struct vm_struct *area)
1818} 1834}
1819EXPORT_SYMBOL_GPL(free_vm_area); 1835EXPORT_SYMBOL_GPL(free_vm_area);
1820 1836
1837static struct vmap_area *node_to_va(struct rb_node *n)
1838{
1839 return n ? rb_entry(n, struct vmap_area, rb_node) : NULL;
1840}
1841
1842/**
1843 * pvm_find_next_prev - find the next and prev vmap_area surrounding @end
1844 * @end: target address
1845 * @pnext: out arg for the next vmap_area
1846 * @pprev: out arg for the previous vmap_area
1847 *
1848 * Returns: %true if either or both of next and prev are found,
1849 * %false if no vmap_area exists
1850 *
1851 * Find vmap_areas end addresses of which enclose @end. ie. if not
1852 * NULL, *pnext->va_end > @end and *pprev->va_end <= @end.
1853 */
1854static bool pvm_find_next_prev(unsigned long end,
1855 struct vmap_area **pnext,
1856 struct vmap_area **pprev)
1857{
1858 struct rb_node *n = vmap_area_root.rb_node;
1859 struct vmap_area *va = NULL;
1860
1861 while (n) {
1862 va = rb_entry(n, struct vmap_area, rb_node);
1863 if (end < va->va_end)
1864 n = n->rb_left;
1865 else if (end > va->va_end)
1866 n = n->rb_right;
1867 else
1868 break;
1869 }
1870
1871 if (!va)
1872 return false;
1873
1874 if (va->va_end > end) {
1875 *pnext = va;
1876 *pprev = node_to_va(rb_prev(&(*pnext)->rb_node));
1877 } else {
1878 *pprev = va;
1879 *pnext = node_to_va(rb_next(&(*pprev)->rb_node));
1880 }
1881 return true;
1882}
1883
1884/**
1885 * pvm_determine_end - find the highest aligned address between two vmap_areas
1886 * @pnext: in/out arg for the next vmap_area
1887 * @pprev: in/out arg for the previous vmap_area
1888 * @align: alignment
1889 *
1890 * Returns: determined end address
1891 *
1892 * Find the highest aligned address between *@pnext and *@pprev below
1893 * VMALLOC_END. *@pnext and *@pprev are adjusted so that the aligned
1894 * down address is between the end addresses of the two vmap_areas.
1895 *
1896 * Please note that the address returned by this function may fall
1897 * inside *@pnext vmap_area. The caller is responsible for checking
1898 * that.
1899 */
1900static unsigned long pvm_determine_end(struct vmap_area **pnext,
1901 struct vmap_area **pprev,
1902 unsigned long align)
1903{
1904 const unsigned long vmalloc_end = VMALLOC_END & ~(align - 1);
1905 unsigned long addr;
1906
1907 if (*pnext)
1908 addr = min((*pnext)->va_start & ~(align - 1), vmalloc_end);
1909 else
1910 addr = vmalloc_end;
1911
1912 while (*pprev && (*pprev)->va_end > addr) {
1913 *pnext = *pprev;
1914 *pprev = node_to_va(rb_prev(&(*pnext)->rb_node));
1915 }
1916
1917 return addr;
1918}
1919
1920/**
1921 * pcpu_get_vm_areas - allocate vmalloc areas for percpu allocator
1922 * @offsets: array containing offset of each area
1923 * @sizes: array containing size of each area
1924 * @nr_vms: the number of areas to allocate
1925 * @align: alignment, all entries in @offsets and @sizes must be aligned to this
1926 * @gfp_mask: allocation mask
1927 *
1928 * Returns: kmalloc'd vm_struct pointer array pointing to allocated
1929 * vm_structs on success, %NULL on failure
1930 *
1931 * Percpu allocator wants to use congruent vm areas so that it can
1932 * maintain the offsets among percpu areas. This function allocates
1933 * congruent vmalloc areas for it. These areas tend to be scattered
1934 * pretty far, distance between two areas easily going up to
1935 * gigabytes. To avoid interacting with regular vmallocs, these areas
1936 * are allocated from top.
1937 *
1938 * Despite its complicated look, this allocator is rather simple. It
1939 * does everything top-down and scans areas from the end looking for
1940 * matching slot. While scanning, if any of the areas overlaps with
1941 * existing vmap_area, the base address is pulled down to fit the
1942 * area. Scanning is repeated till all the areas fit and then all
1943 * necessary data structres are inserted and the result is returned.
1944 */
1945struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
1946 const size_t *sizes, int nr_vms,
1947 size_t align, gfp_t gfp_mask)
1948{
1949 const unsigned long vmalloc_start = ALIGN(VMALLOC_START, align);
1950 const unsigned long vmalloc_end = VMALLOC_END & ~(align - 1);
1951 struct vmap_area **vas, *prev, *next;
1952 struct vm_struct **vms;
1953 int area, area2, last_area, term_area;
1954 unsigned long base, start, end, last_end;
1955 bool purged = false;
1956
1957 gfp_mask &= GFP_RECLAIM_MASK;
1958
1959 /* verify parameters and allocate data structures */
1960 BUG_ON(align & ~PAGE_MASK || !is_power_of_2(align));
1961 for (last_area = 0, area = 0; area < nr_vms; area++) {
1962 start = offsets[area];
1963 end = start + sizes[area];
1964
1965 /* is everything aligned properly? */
1966 BUG_ON(!IS_ALIGNED(offsets[area], align));
1967 BUG_ON(!IS_ALIGNED(sizes[area], align));
1968
1969 /* detect the area with the highest address */
1970 if (start > offsets[last_area])
1971 last_area = area;
1972
1973 for (area2 = 0; area2 < nr_vms; area2++) {
1974 unsigned long start2 = offsets[area2];
1975 unsigned long end2 = start2 + sizes[area2];
1976
1977 if (area2 == area)
1978 continue;
1979
1980 BUG_ON(start2 >= start && start2 < end);
1981 BUG_ON(end2 <= end && end2 > start);
1982 }
1983 }
1984 last_end = offsets[last_area] + sizes[last_area];
1985
1986 if (vmalloc_end - vmalloc_start < last_end) {
1987 WARN_ON(true);
1988 return NULL;
1989 }
1990
1991 vms = kzalloc(sizeof(vms[0]) * nr_vms, gfp_mask);
1992 vas = kzalloc(sizeof(vas[0]) * nr_vms, gfp_mask);
1993 if (!vas || !vms)
1994 goto err_free;
1995
1996 for (area = 0; area < nr_vms; area++) {
1997 vas[area] = kzalloc(sizeof(struct vmap_area), gfp_mask);
1998 vms[area] = kzalloc(sizeof(struct vm_struct), gfp_mask);
1999 if (!vas[area] || !vms[area])
2000 goto err_free;
2001 }
2002retry:
2003 spin_lock(&vmap_area_lock);
2004
2005 /* start scanning - we scan from the top, begin with the last area */
2006 area = term_area = last_area;
2007 start = offsets[area];
2008 end = start + sizes[area];
2009
2010 if (!pvm_find_next_prev(vmap_area_pcpu_hole, &next, &prev)) {
2011 base = vmalloc_end - last_end;
2012 goto found;
2013 }
2014 base = pvm_determine_end(&next, &prev, align) - end;
2015
2016 while (true) {
2017 BUG_ON(next && next->va_end <= base + end);
2018 BUG_ON(prev && prev->va_end > base + end);
2019
2020 /*
2021 * base might have underflowed, add last_end before
2022 * comparing.
2023 */
2024 if (base + last_end < vmalloc_start + last_end) {
2025 spin_unlock(&vmap_area_lock);
2026 if (!purged) {
2027 purge_vmap_area_lazy();
2028 purged = true;
2029 goto retry;
2030 }
2031 goto err_free;
2032 }
2033
2034 /*
2035 * If next overlaps, move base downwards so that it's
2036 * right below next and then recheck.
2037 */
2038 if (next && next->va_start < base + end) {
2039 base = pvm_determine_end(&next, &prev, align) - end;
2040 term_area = area;
2041 continue;
2042 }
2043
2044 /*
2045 * If prev overlaps, shift down next and prev and move
2046 * base so that it's right below new next and then
2047 * recheck.
2048 */
2049 if (prev && prev->va_end > base + start) {
2050 next = prev;
2051 prev = node_to_va(rb_prev(&next->rb_node));
2052 base = pvm_determine_end(&next, &prev, align) - end;
2053 term_area = area;
2054 continue;
2055 }
2056
2057 /*
2058 * This area fits, move on to the previous one. If
2059 * the previous one is the terminal one, we're done.
2060 */
2061 area = (area + nr_vms - 1) % nr_vms;
2062 if (area == term_area)
2063 break;
2064 start = offsets[area];
2065 end = start + sizes[area];
2066 pvm_find_next_prev(base + end, &next, &prev);
2067 }
2068found:
2069 /* we've found a fitting base, insert all va's */
2070 for (area = 0; area < nr_vms; area++) {
2071 struct vmap_area *va = vas[area];
2072
2073 va->va_start = base + offsets[area];
2074 va->va_end = va->va_start + sizes[area];
2075 __insert_vmap_area(va);
2076 }
2077
2078 vmap_area_pcpu_hole = base + offsets[last_area];
2079
2080 spin_unlock(&vmap_area_lock);
2081
2082 /* insert all vm's */
2083 for (area = 0; area < nr_vms; area++)
2084 insert_vmalloc_vm(vms[area], vas[area], VM_ALLOC,
2085 pcpu_get_vm_areas);
2086
2087 kfree(vas);
2088 return vms;
2089
2090err_free:
2091 for (area = 0; area < nr_vms; area++) {
2092 if (vas)
2093 kfree(vas[area]);
2094 if (vms)
2095 kfree(vms[area]);
2096 }
2097 kfree(vas);
2098 kfree(vms);
2099 return NULL;
2100}
2101
2102/**
2103 * pcpu_free_vm_areas - free vmalloc areas for percpu allocator
2104 * @vms: vm_struct pointer array returned by pcpu_get_vm_areas()
2105 * @nr_vms: the number of allocated areas
2106 *
2107 * Free vm_structs and the array allocated by pcpu_get_vm_areas().
2108 */
2109void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
2110{
2111 int i;
2112
2113 for (i = 0; i < nr_vms; i++)
2114 free_vm_area(vms[i]);
2115 kfree(vms);
2116}
1821 2117
1822#ifdef CONFIG_PROC_FS 2118#ifdef CONFIG_PROC_FS
1823static void *s_start(struct seq_file *m, loff_t *pos) 2119static void *s_start(struct seq_file *m, loff_t *pos)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index cd2b97f1b6e1..a6e0e077ac33 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -37,12 +37,13 @@ __initcall(init_syncookies);
37#define COOKIEBITS 24 /* Upper bits store count */ 37#define COOKIEBITS 24 /* Upper bits store count */
38#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) 38#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
39 39
40static DEFINE_PER_CPU(__u32, cookie_scratch)[16 + 5 + SHA_WORKSPACE_WORDS]; 40static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS],
41 ipv4_cookie_scratch);
41 42
42static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport, 43static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport,
43 u32 count, int c) 44 u32 count, int c)
44{ 45{
45 __u32 *tmp = __get_cpu_var(cookie_scratch); 46 __u32 *tmp = __get_cpu_var(ipv4_cookie_scratch);
46 47
47 memcpy(tmp + 4, syncookie_secret[c], sizeof(syncookie_secret[c])); 48 memcpy(tmp + 4, syncookie_secret[c], sizeof(syncookie_secret[c]));
48 tmp[0] = (__force u32)saddr; 49 tmp[0] = (__force u32)saddr;
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 8c2513982b61..6b6ae913b5d4 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -74,12 +74,13 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
74 return child; 74 return child;
75} 75}
76 76
77static DEFINE_PER_CPU(__u32, cookie_scratch)[16 + 5 + SHA_WORKSPACE_WORDS]; 77static DEFINE_PER_CPU(__u32 [16 + 5 + SHA_WORKSPACE_WORDS],
78 ipv6_cookie_scratch);
78 79
79static u32 cookie_hash(struct in6_addr *saddr, struct in6_addr *daddr, 80static u32 cookie_hash(struct in6_addr *saddr, struct in6_addr *daddr,
80 __be16 sport, __be16 dport, u32 count, int c) 81 __be16 sport, __be16 dport, u32 count, int c)
81{ 82{
82 __u32 *tmp = __get_cpu_var(cookie_scratch); 83 __u32 *tmp = __get_cpu_var(ipv6_cookie_scratch);
83 84
84 /* 85 /*
85 * we have 320 bits of information to hash, copy in the remaining 86 * we have 320 bits of information to hash, copy in the remaining
diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c
index 8d8488306fe4..d2c904dd6fbc 100644
--- a/net/rds/ib_stats.c
+++ b/net/rds/ib_stats.c
@@ -37,7 +37,7 @@
37#include "rds.h" 37#include "rds.h"
38#include "ib.h" 38#include "ib.h"
39 39
40DEFINE_PER_CPU(struct rds_ib_statistics, rds_ib_stats) ____cacheline_aligned; 40DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_ib_statistics, rds_ib_stats);
41 41
42static const char *const rds_ib_stat_names[] = { 42static const char *const rds_ib_stat_names[] = {
43 "ib_connect_raced", 43 "ib_connect_raced",
diff --git a/net/rds/iw_stats.c b/net/rds/iw_stats.c
index d33ea790484e..5fe67f6a1d80 100644
--- a/net/rds/iw_stats.c
+++ b/net/rds/iw_stats.c
@@ -37,7 +37,7 @@
37#include "rds.h" 37#include "rds.h"
38#include "iw.h" 38#include "iw.h"
39 39
40DEFINE_PER_CPU(struct rds_iw_statistics, rds_iw_stats) ____cacheline_aligned; 40DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_iw_statistics, rds_iw_stats);
41 41
42static const char *const rds_iw_stat_names[] = { 42static const char *const rds_iw_stat_names[] = {
43 "iw_connect_raced", 43 "iw_connect_raced",
diff --git a/net/rds/page.c b/net/rds/page.c
index 55c21efdb62e..36790122dfd4 100644
--- a/net/rds/page.c
+++ b/net/rds/page.c
@@ -39,7 +39,7 @@ struct rds_page_remainder {
39 unsigned long r_offset; 39 unsigned long r_offset;
40}; 40};
41 41
42DEFINE_PER_CPU(struct rds_page_remainder, rds_page_remainders) ____cacheline_aligned; 42DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_page_remainder, rds_page_remainders);
43 43
44/* 44/*
45 * returns 0 on success or -errno on failure. 45 * returns 0 on success or -errno on failure.
diff --git a/scripts/module-common.lds b/scripts/module-common.lds
new file mode 100644
index 000000000000..47a1f9ae0ede
--- /dev/null
+++ b/scripts/module-common.lds
@@ -0,0 +1,8 @@
1/*
2 * Common module linker script, always used when linking a module.
3 * Archs are free to supply their own linker scripts. ld will
4 * combine them automatically.
5 */
6SECTIONS {
7 /DISCARD/ : { *(.discard) }
8}
diff --git a/security/Kconfig b/security/Kconfig
index 4c865345caa0..fb363cd81cf6 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -113,6 +113,36 @@ config SECURITY_ROOTPLUG
113 113
114 If you are unsure how to answer this question, answer N. 114 If you are unsure how to answer this question, answer N.
115 115
116config INTEL_TXT
117 bool "Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)"
118 depends on HAVE_INTEL_TXT
119 help
120 This option enables support for booting the kernel with the
121 Trusted Boot (tboot) module. This will utilize
122 Intel(R) Trusted Execution Technology to perform a measured launch
123 of the kernel. If the system does not support Intel(R) TXT, this
124 will have no effect.
125
126 Intel TXT will provide higher assurance of system configuration and
127 initial state as well as data reset protection. This is used to
128 create a robust initial kernel measurement and verification, which
129 helps to ensure that kernel security mechanisms are functioning
130 correctly. This level of protection requires a root of trust outside
131 of the kernel itself.
132
133 Intel TXT also helps solve real end user concerns about having
134 confidence that their hardware is running the VMM or kernel that
135 it was configured with, especially since they may be responsible for
136 providing such assurances to VMs and services running on it.
137
138 See <http://www.intel.com/technology/security/> for more information
139 about Intel(R) TXT.
140 See <http://tboot.sourceforge.net> for more information about tboot.
141 See Documentation/intel_txt.txt for a description of how to enable
142 Intel TXT support in a kernel boot.
143
144 If you are unsure as to whether this is required, answer N.
145
116config LSM_MMAP_MIN_ADDR 146config LSM_MMAP_MIN_ADDR
117 int "Low address space for LSM to protect from user allocation" 147 int "Low address space for LSM to protect from user allocation"
118 depends on SECURITY && SECURITY_SELINUX 148 depends on SECURITY && SECURITY_SELINUX